![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Split problem using limitby NovMonk (Chaplain) |
on Aug 20, 2004 at 15:10 UTC ( #384613=perlquestion: print w/replies, xml ) | Need Help?? |
NovMonk has asked for the wisdom of the Perl Monks concerning the following question:
Greetings wise brothers and sisters, As the saying goes, "It is better to remain silent and be thought a fool, than to speak up and remove all doubt." I'm going to go for it anyway, though. My problem is this: I am creating a utility to parse a simple text file. I need to capture the text on certain lines into a single scalar variable, so I thought to use split thus:
where the 0 is the Limit. Fine, but when the text on one of my lines is this: 10 minutes or less, my variable for that line comes back as a "1". All the other lines come back as expected. I get that when it sees the 0 in the line, it assumes it's the delimiter instead of the default whitespace. I tried the following,($spectext) = split (" ",$_,0); which, from my handy copy of Perl by Example, looks like it should work, (specifying delimiter,string and limit) but now all I get is the first word of every line, which is not at all what I want. My code is here
Pax, NovMonk
Back to
Seekers of Perl Wisdom
|
|