Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: Split file using perl and regexp

by brad_nov (Novice)
on Jan 17, 2013 at 22:03 UTC ( #1013900=note: print w/replies, xml ) Need Help??


in reply to Re^3: Split file using perl and regexp
in thread Split file using perl and regexp

Currently I am using the below script to split into multiple files:
$split_file=$ARGV[0]; $split_file=~ s{.*/}{}; $split_file=~ s{\.[^.]+$}{}; print "split_file=$split_file\n"; while (<>) { if ( my ($m_id) = /^\d+\|(\d+?)\|/ ) { open my $fh, '>>', "${split_file}_" . $m_id . '.txt'; print $fh $_; } }