in reply to extracting data and saving into seperate files
or few more:perl -ne 'if(/(\w+\.csv)/){close $fh if defined $fh;open $fh,">$1"} el +sif(/([0-9.-]+)/){print $fh "$1\n"}' file.txt
open FILE, "<file.txt"; # Open the file while( <FILE> ) { # read a line if ( /(\w+\.csv)/ ) { # If the line is a filename... close $fh if defined $fh; # close previous open $fh,">$1"; # and open new for writing } elsif ( /([0-9.-]+)/ ) { # If the line is a number... print $fh "$1\n"; # write it } } close $fh; # close the files opened close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extracting data and saving into seperate files
by pKai (Priest) on Jan 09, 2006 at 13:39 UTC |