Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: looking for feedback on my first script

by Discipulus (Abbot)
on Jan 08, 2021 at 16:09 UTC ( #11126610=note: print w/replies, xml ) Need Help??


in reply to looking for feedback on my first script

Hello thirtySeven,

at first glance it seems ok. About arguments of the script: no one rembemer the correct order of them after 2 minutes. See The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan! for more info. I always use the following format:

unless ( GetOptions ( "example=s" => \$par_example, # string needed # more options a +nd switches.. "help" => \$par_help, # switch )) { my_show_help(); die "Error in command lin +e arguments: $!"} if (defined $par_help){my_show_help();exit;}

Then you can use File::Spec to a more robust path creation and look for a date module to see if it helps managing date formats.

Always check the return value of open and opendir like in: .. or die "Unable to open directory [$dir]"

You can use eval inside a block to mask the scope of $@ and check $^E (last operating system error) too.

When shelling out with system or whatever you can check it better with Capture::Tiny

my ($stdout, $stderr, $exit) = capture { system( $cmd, @cmdargs ); };

L*

PS my last suggestion is to follow haukex's sugestions :)

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-08-05 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (44 votes). Check out past polls.

    Notices?