Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Nico,

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
say  substr+lc crypt(qw $i3 SI$),4,5

In reply to Re: Perl File Parsing - My Code Works, but it's Ugly! by golux
in thread Perl File Parsing - My Code Works, but it's Ugly! by Nico

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found