Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: split a line by control ^D character

by eyepopslikeamosquito (Canon)
on Dec 02, 2012 at 10:55 UTC ( #1006699=note: print w/ replies, xml ) Need Help??


in reply to split a line by control ^D character

The problem is that the chr(4) inside your /chr(4)/ regex is not being interpreted as a function call; rather it is being interpreted literally, with the parens in chr(4) being interpreted as regex metacharacters to capture the 4 in a matching chr4, for example!

There are a number of ways to fix this, for example:

@LineDetails = split /\04/, $line; # ... or @LineDetails = split chr(4), $line;


Comment on Re: split a line by control ^D character
Select or Download Code
Re^2: split a line by control ^D character
by selva (Scribe) on Dec 02, 2012 at 11:12 UTC
    @ eyepopslikeamosquito

    Thanks so much!! It is working fine now.

      You're welcome. One more thing I noticed is that you will probably want to add a line:

      chomp @arr;
      right after my @arr = <$FILE>; to avoid the last field on each line containing a newline.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-10-22 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (122 votes), past polls