http://www.perlmonks.org?node_id=1026843


in reply to Regex Split and Formatting

Thank you so much for the prompt reply ...
I did try using regex but failed miserably.. I got thus far :
$out_file = "testout.txt"; #this is the file to be edited open (OUT, "<$out_file") or die "Can't open $out_file: $!\n"; $/ = "\n"; while ($line = <OUT>) { my $first = (split /,/, $line)[0]; $first =~ tr/"//d; $first =~ s/^\s+//; ....... } close OUT;
*Tried to use the first numeric element as matching criteria and the split that line into an array(but that got way too complicated)
* Then tried using splice to split the entire file into equal sized arrays( but i did not know how to do that)

I did not know how to proceed(hence the "...." in the code) The method i'm using is long (since I'm a newbie to perl and don't understand all the nuances)..Appreciate the help ..

P.S: This is not my homework.. Just something i'm working on currently ...