in reply to Re^3: Recover a path from a config file
in thread Recover a path from a config file

for example the local $/ doesn't assign anything so doesn't do anything.

local $/; has the effect of setting $/ to undef; thus the subsequent <$fh> reads the entire file. (Slurps it per the comment.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

Replies are listed 'Best First'.
Re^5: Recover a path from a config file
by anonymized user 468275 (Curate) on Jun 07, 2016 at 17:52 UTC
    thanks for that browser. I would still advocate assigning undef to it explicitly though for clarity.
    local $/ = undef; $slurp = <fh>;
    is in fact the example given in perlsub and I feel with good reason.

    One world, one people

      Do you write: my $c = undef; for all your lexicals?

      local declares & initialises a new, scoped copy of a variable.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.
        Yes but because it's a copy of a global variable it creates expectations of inheritance that "my" doesn't. The documentation has changed over time owing to confusion it caused about what local is or isn't supposed to do. The latest version has at least as much warning about what it isn't than clarity about what it is.

        Your own definition looks good to me and I'd like to see it reflected in perldoc just as clearly.

        One world, one people