Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Recover a path from a config file

by Anonymous Monk
on Jun 06, 2016 at 20:35 UTC ( [id://1165012]=note: print w/replies, xml ) Need Help??


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

See Re^3: Recover a path from a config file
  • Comment on Re^2: Recover a path from a config file

Replies are listed 'Best First'.
Re^3: Recover a path from a config file
by anonymized user 468275 (Curate) on Jun 07, 2016 at 13:53 UTC
    I don't want to get into that example in too much detail as it serves no proper purpose. However, I do have issues with it, for example the local $/ doesn't assign anything so doesn't do anything. Meanwhile I have been thinking what would a proper solution be and I keep getting back to the fact that this is not the best way write a config file. Better would be to have
    { folder => 'path',
    in the following hash, instead of
    my $folder = 'path';
    In any case, unless the config file is used to load all configuration data rather than pick just one item, then it is being misused as well as ill-conceived. There are two types of config file. The language portable one that is just a list of identifiers followed by their values and the "normal" perl way: a class-qualified symbol and a hash assigned to it, which is intended to be loaded in easily enough using just one "require" statement.

    Unfortunately, the OP seems to be suffering from an organisation culture that stubbornly resists change even to fix bad implementations. In the wider Perl community we know who they are by reputation and simply avoid working there!

    One world, one people

      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.
        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

      Thanks for the improvements.

      Problem is that i am not allowed to touch config.file.I use this kind of config.file in order to improve my Perl approach.

       unless the config file is used to load all configuration data rather than pick just one item

      Yes, it is the case in part

       In the wider Perl community we know who they are by reputation and simply avoid working there!

      Hope i will be one of this wider community !

      Thanks

      *****Lost in translation****TIMTOWTOI****
Re^3: Recover a path from a config file
by Chaoui05 (Scribe) on Jun 07, 2016 at 08:33 UTC
    Yes. exact
    *****Lost in translation****TIMTOWTOI****

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2024-04-23 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found