Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Regex Split and Formatting

by reaper9187 (Scribe)
on Apr 03, 2013 at 12:09 UTC ( #1026843=note: print w/replies, xml ) Need Help??

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 ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026843]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2016-10-23 04:33 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (300 votes). Check out past polls.