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 (Chaplain) 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.