Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Recover a path from a config file

by BrowserUk (Patriarch)
on Jun 07, 2016 at 14:06 UTC ( [id://1165077]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-18 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found