Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Why doesn't this work?

by ww (Archbishop)
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!

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028452]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2017-11-21 08:43 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (297 votes). Check out past polls.