in reply to Read from a header file like C
This sounds very much like an XY Problem. What are you trying to accomplish through this obfuscation? It seems unlikely that you will be in an environment where perl runs with different permissions than the individual who is perusing your script. There is value in abstracting common constants that are shared across scripts, but that should probably be done with modules, e.g.
andpackage Gvenkat5; use strict; use warnings; use DBI; require Exporter; @EXPORT_OK = 'connect'; sub connect { my $port = shift || 1000; my $dbnam = ''; return DBI->connect("DBI:mysql:database=$dbnam; host=abc01.xyz.com; port=$port", 'gvenkat', 'ganesh99') }
or, for literal values, YAML or equivalent as suggested.use Gvenkat5 'connect'; my $dbh = connect($ARGV[0]);
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|