in reply to Re^3: split one file into many on finding a new line
in thread split one file into many on finding a new line
but the files created are MyFileName0001,MyFileName0002 etc...is there a way i can have the file anme as the tabels name itself...i tried following:#!/sw/perl5/1.1/bin/perl use strict; my $filename = "MyFileName0000"; local $/ = "\n\n"; my $temp_line; my $filehandle; open ( INFILE, $filename ) || ( die "Cant read $filename: $!"); while ( <INFILE> ) { chomp; ++$filename; print "**** Open file $filename here\n"; open ( IFILE, ">>$filename" ); print IFILE "$_\n"; close(IFILE); print "**** Close file $filename here\n"; } select INFILE; close(INFILE);
But the scriptname is not being extracted properly..i am getting null.... Thanks#!/sw/perl5/1.1/bin/perl use strict; my $filename = "MyFileName0000"; local $/ = "\n\n"; my $scriptname; my $filehandle; open ( INFILE, $filename ) || ( die "Cant read $filename: $!"); while (<INFILE> ) { chomp; #++$filename; $scriptname=~ /CREATE TABLE ([\S]*)/; print "**** Open file $scriptname here\n"; open ( IFILE, ">>$scriptname" ); print IFILE "$_\n"; close(IFILE); print "**** Close file $scriptname here\n"; } select INFILE; close(INFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: split one file into many on finding a new line
by repellent (Priest) on Sep 16, 2008 at 02:55 UTC |