Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.476.295 Times

IO::InSitu 0.0.2

  Date Added: October 08, 2010  |  Visits: 1.683

IO::InSitu

Report Broken Link
Printer Friendly Version


Product Homepage
Download (87 downloads)

IO::InSitu is a Perl module to avoid clobbering files opened for both input and output. SYNOPSIS use IO::InSitu; my ($in, $out) = open_rw($infile_name, $outfile_name); for my $line (<$in>) { $line =~ s/foo/bar/g; print {$out} $line; } When users want to do in-situ processing on a file, they often specify it as both the input and output file: > myapp -i sample_data -o sample_data -op=normalize But, if the -i and -o flags are processed independently, the program will usually open the file for input, open it again for output (at which point the file will be truncated to zero length), and then attempt to read in the first line of the now-empty file: # Open both filehandles... use Fatal qw( open ); open my $src, <, $source_file; open my $dest, >, $destination_file; # Read, process, and output data, line-by-line... while (my $line = < $src >) { print {$dest} transform($line); } Not only does this not perform the requested transformation on the file, it also destroys the original data. Fortunately, this problem is extremely easy to avoid: just make sure that you unlink the output file before you open it: # Open both filehandles... use Fatal qw( open ); open my $src, <, $source_file; unlink $destination_file; open my $dest, >, $destination_file; # Read, process, and output data, line-by-line... while (my $line = <$src>) { print {$dest} transform($line); } If the input and output files are different, unlinking the output file merely removes a file that was about to be rewritten anyway. Then the second open simply recreates the output file, ready for writing. If the two filenames actually refer to a single in-situ file, unlinking the output filename removes that filename from its directory, but doesnt remove the file itself from the filesystem. The file is already open through the filehandle in $input, so the filesystem will preserve the unlinked file until that input filehandle is closed. The second open then creates a new version of the in-situ file, ready for writing. The only limitation of this technique is that it changes the inode of any in-situ file . That can be a problem if the file has any hard-linked aliases, or if other applications are identifying the file by its inode number. If either of those situations is possible, you can preserve the in-situ files inode by using the open_rw() subroutine that is exported from this module: # Open both filehandles... use IO::InSitu; my ($src, $dest) = open_rw($source_file, $destination_file); # Read, process, and output data, line-by-line... while (my $line = <$src>) { print {$dest} transform($line); }.

Requirements: No special requirements
Platforms: Linux
Keyword: File Files Input Input And Output Insitu Io Ioinsitu Libraries Line Open Output Perl Module Programming
Users rating: 0/10

License: Freeware Size: 6.14 KB
IO::INSITU RELATED
Libraries  -  Bio::Phylo::IO 0.17 RC6
Bio::Phylo::IO Perl module contains input and output of phylogenetic data. SYNOPSIS use Bio::Phylo::IO; # parsing a tree from a newick string my $tree_string = (((A,B),C),D);; my $tree = Bio::Phylo::IO->parse( -string => $tree_string, #...
143.36 KB  
Libraries  -  libspectrum 0.2.2
libspectrum is a library designed to make the input and output of some ZX Spectrum emulator files slightly easier. libspectrum is intended to be usable on Unix variants, Mac OS X and Win32. Currently, it is mainly (only?) used by Fuse, but other...
 
Networking Tools  -  lifstat 2006-10-31
lifstat is a small Linux utility that reads /proc/net/dev and reports input and output statistics for network interfaces. Edit the Makefile to change PREFIX from the default /usr/local if you want. $ make ($ su) $ make instal Whats New in...
5.12 KB  
Audio Tools  -  oss2jack 0.24
oss2jack creates an OSS device which redirects its input and output to the Jack Audio Connection Kit. oss2jack supports a large subset of the OSS specification, including full duplex I/O and mmap. oss2jack uses Jeremy Elsons useful fusd library...
92.16 KB  
Development Tools  -  Colorize xml source 1.0
This script takes an xml file as input and output a colorized version of this file, using html or docbook (with emphasis elements and a particular role). It provides a little command line interface and it's really easy to configure your output.
 
Libraries  -  GNU CD Input and Control Library 0.78.2
GNU CD Input and Control Library (libcdio) encapsulates CD-ROM reading and control. The libcdio package contains a library which encapsulates CD-ROM reading and control. Applications wishing to be oblivious of the OS- and device-dependent...
1.7 MB  
Audio Tools  -  OpenAL mixer For Linux 1.2.0
OpenAL mixer aims to provide a multiplatform API built on top of OpenAL to get/set volume values (including support for capture devices) and list, select and mute input and output lines.
10.24 KB  
Libraries  -  IO::Prompt 0.99.4
IO::Prompt is a Perl module to interactively prompt for user input. SYNOPSIS use IO::Prompt; while( prompt "next: " ) { print "You said $_n"; } By default, this module exports a single function prompt. It prompts the user to enter some...
14.34 KB  
Libraries  -  IO::Multiplex 1.08
IO::Multiplex is a Perl module that can manage IO on many file handles. SYNOPSIS use IO::Multiplex; my $mux = new IO::Multiplex; $mux->add($fh1); $mux->add(*FH2); $mux->set_callback_object(...); $mux->listen($server_socket); $mux->loop;...
14.34 KB  
Text Management  -  Echo input with a time delay after each line 1.0
This script echos the input with a time delay after each line. The input can be from standard input or a list of files on the command line, like the Unix 'cat' command. The delay between lines is adjustable, and defaults to 1 second.
 
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB