Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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

by liverpole (Monsignor)
on Sep 28, 2011 at 12:55 UTC ( #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 # 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..."


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928314]
[choroba]: Related to the new release, anyone could explain this or this tester report?
[Discipulus]: hello crew! marto thanks for the message: but I how can I help? i'm testing cpan Padre atm problem with Client::Debug
[choroba]: I don't happen to have 5.10.0 nor 5.8.5 handy...
[Corion]: Hmm - I would say the 5.8.5 is a broken installation / corrupt tarball download, and the 5.10.0 is really weird, and maybe a bug in that version of Perl
[Corion]: I don't see how my $result = eval q{'abc' =~ ?b?}; could create a "Modification of read-only value" error
[marto]: Discipulus the issue that should be adressed is that the page needs to be updated to reflect modern perl on Windows
[Discipulus]: but is really necessary to support these ancient versions? from 5.14 onward is not enough?
[Discipulus]: yes marto I understood
[Corion]: Discipulus: I'm slowly migrating my code to require 5.8.x ;) Most of my code works on 5.6, but Filter::signatures requires 5.10 I think

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2018-06-25 08:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.