Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Why doesn't this work?

by ww (Bishop)
on Apr 12, 2013 at 21:59 UTC ( #1028452=note: print w/ replies, xml ) Need Help??


in reply to Why doesn't this work?

You might want to read about $/ in perldoc perlvar. It would also be well to recognize that settng "$/=\000" is far from the same thing as $/=undef or $/="\000".

Not an issue in your one-liners, but you should probably use any modified $/ ( or local $/=... ) in as narrow a scope as possible when you change it, or make sure you reset it in any other instance (other'n your one-liners).


If you didn't program your executable by toggling in binary, it wasn't really programming!


Comment on Re: Why doesn't this work?
Select or Download Code
Re^2: Why doesn't this work?
by perl-diddler (Hermit) on Apr 12, 2013 at 22:08 UTC
    I forgot the 'my' in the braces, but know the point you were making -- i.e. that's why it was in braces.

    I wasn't trying to use slurp mode & $/=undef in the one example, -- was trying to recognize "\000" (NUL) as the line delimiter (in this case a list of NUL-terminated filenames) and use that to read the whole thing into an array and then seeing how many array members I had.

      Make that 'my' a 'local'... geez... trying to respond too fast. Just to be sure I checked my code and only find one place where I used slurp mode that wasn't in a 1-liner, and I used local there. Glad you reminded me -- as I'd started to get it in my head that braces or my were needed...

      Looks like most common usage for me is shell-1-liners where Shell can't deal with NUL terminated lines, so need perl to do that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (17)
As of 2015-07-01 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (8 votes), past polls