Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Different behavior when parsing $0 on Solaris and Win32

by liverpole (Monsignor)
on Sep 28, 2011 at 12:55 UTC ( [id://928314]=note: print w/replies, xml ) Need Help??


in reply to Different behavior when parsing $0 on Solaris and Win32

Hi dirac,

When a script doesn't work as expected, you need to debug it. To aid in that venture, be verbose. Don't get fancy and try to do everything in a single line (eg. my $log_file = (split /\./, $0)[0] . '.log';). Rather, do the minimum possible in each step, and display all intermediate results, such as:

#!/usr/local/bin/perl -w # my_script_name.pl use strict; my $arg0 = $0; print "Debug> Before split -- arg0 = '$arg0'\n"; my @words = split /\./, $0; my $count = @words; print "Debug> After split -- $count words: [@words]\n"; my $base = $words[0]; print "Debug> First word (word[0]) = '$base'\n"; my $log_file = $base . '.log'; print "Debug> Full logfile name = '$log_file'\n";

You should never find yourself saying "I know the contents of the variable should be X at this point". Rather, "I think the contents of the variable should be X, so I'll print them out to be sure..."


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found