in reply to Re: perl and Docker
in thread perl and Docker

Careful. You might get nominated for the useless use of cat award, and actually get it.

This is a horrible way of loading configuration

Indeed. Instead of

my $file = '1174639.conf'; my $buf = `cat $file`; my @conf; eval( $buf );

I'd rather say

my @conf = do '1174639.conf';

since duplicating a static file name into a variable is pointless, as is allocating a buffer to eval a file, and invoking /bin/sh to read it.

update: The award should go to the author of nlpfit, since lines 227-244 read as follows

# set up the @conf array my(@conf); if(defined($opt{config_file})){ my($buf); $buf = `cat $opt{config_file}`; # slurp if (eval($buf)){ print STDOUT "$me: Read config from $opt{config_file}\n" if $opt +{verbose}; } else{ die "$me: Error reading config from $opt{config_file} (fix it!)\ +n\n"; } } else{ @conf = @default_conf; }

and that's where 1nickt got that abomination. It shouldn't have been repeated without correction, though.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'