in reply to Perl File Parsing - My Code Works, but it's Ugly!
Hi Nico,
say
substr+lc crypt(qw $i3 SI$),4,5
One other suggestion concerning your escaping of underscores "_":
$outfolder = "REPORT_output\_$year\_$mon\_$mday\_\_$hour\_$min +\_$sec";
The underscore character doesn't need to be escaped like this everywhere in a string. If you were doing so to separate it from the preceding variable (ie. "$year\_$mon" in order to interpolate $year instead of $year_), there's another, more common way to do so which is arguably a little easier to read:
$outfolder = "REPORT_output_${year}_${mon}_${mday}__${hour}_${ +min}_$sec";
This syntax is also often used to separate variables from other chars which could be part of the variable name; eg.:
my $msg = "Hello world"; my $color = 101; # Red background print "\e[${color}m $msg \e[m\n"; # Embed $color in escape sequence
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl File Parsing - My Code Works, but it's Ugly!
by aaron_baugher (Curate) on May 31, 2015 at 22:03 UTC | |
Re^2: Perl File Parsing - My Code Works, but it's Ugly!
by Anonymous Monk on Jun 01, 2015 at 10:22 UTC | |
by BillKSmith (Monsignor) on Jun 01, 2015 at 14:08 UTC |
In Section
Seekers of Perl Wisdom