Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Prepocessing perl code / substing variables

by LanX (Saint)
on Apr 16, 2019 at 00:59 UTC ( [id://1232621]=note: print w/replies, xml ) Need Help??


in reply to Prepocessing perl code / substing variables

I can't see any reasonable use-case for regexing Perl° since it's incredible flexible already.

Either

  • use a config file like already mentioned
  • require or do a dedicated file with constants only
  • pass values as arguments at startup and read them from @ARGV
  • set environment variables in %ENV
or combine all of theses solutions.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

°) only exception is probably $VERSION in modules

  • Comment on Re: Prepocessing perl code / substing variables

Replies are listed 'Best First'.
Re^2: Prepocessing perl code / substing variables
by afoken (Chancellor) on Apr 16, 2019 at 07:11 UTC

      Sure. And the world is a bad place. Did you ever avoid to load a module because it can execute arbitrary code?

      I would prefer command-line parameters but if the OP insists loading constants from a module isn't so bad IMHO:

      package MyConf { use constant NOSE => q(cuke); use feature qw(say); say __PACKAGE__; 1; }
      #!/usr/bin/env perl use strict; use warnings; use feature qw(say); use lib q(.); use MyConf; say qq(My nose isa @{[MyConf::NOSE]}!); __END__

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found