Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: PERL $/variable

by Animator (Hermit)
on Mar 11, 2010 at 18:23 UTC ( [id://828110]=note: print w/replies, xml ) Need Help??


in reply to PERL $/variable

You really should enable warnings in your code...

Your first example: $/ = m/\d..../;.
What this really means: $/ = ($_ =~ m/\d..../);.
That is: you are first doing a match on $_ with the regex m/\d.../ and then assign the result of the match to $/.

Your second example: $/ == m/\d.../;.
What this really means: my $foo = ($_ =~ m/\d..../);$/ == $foo;.
That is: That is: you are first doing a match on $_ with the regex m/\d.../ and then comparing the result of the match with $/ in a void context. (=> useless comparison)

What you want to do is not possible with $/. $/ has to be a string (or a reference to a integer). It can not be a regex.

What you could do is set $/ to undef; then read from the file and then use: while ($data =~ m/\d.../g) { ... }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found