[32477] in Perl-Users-Digest
Perl-Users Digest, Issue: 3742 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 24 09:09:18 2012
Date: Tue, 24 Jul 2012 06:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 24 Jul 2012 Volume: 11 Number: 3742
Today's topics:
Pls help old perl-monger with new version syntax? r.mariotti@fdcx.net
Re: Pls help old perl-monger with new version syntax? <rweikusat@mssgmbh.com>
Re: Pls help old perl-monger with new version syntax? <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Jul 2012 08:10:58 -0400
From: r.mariotti@fdcx.net
Subject: Pls help old perl-monger with new version syntax?
Message-Id: <no3t081n5natf0en0lnc63nlhicc82uims@4ax.com>
Been doing perl since mid-90's. Just upgraded to the latest version
5.14.2 and many of my perl scripts are thowing errors like no
tomorrow.
I've spent several days trying to resolve the errors without much
success so I thought I would post here as many must have experienced
the same.
I DID research quite extensively with perldoc and google and tried
literally all the suggestions but here it goes anyway.
It appears that using the pragmas warning and strict the newest
version is requiring predefinition of variables prior to their use.
Here's a snippet of my code:
# Define pragmas
use warnings;
use strict;
# Define ALL needed variables & indecies
my $fn = '' unless defined($fn);
my $ln = '' unless defined($ln);
my $opt = '' unless defined($opt);
my $rr = 0 unless defined($rr);
my $x1 = '' unless defined($x1);
my $x2 = '' unless defined($x2);
my $x3 = '' unless defined($x3);
my $x4 = '' unless defined($x4);
Pls note that the '' chars above are two single quotes indicating a
NULL value just to initialize the variables.
The infamous error is
Global symbol "$fn" requires explicit package name
Oh the joy. Anyone care to contribute as it will be very, very
appreciated.
Thanks all
------------------------------
Date: Tue, 24 Jul 2012 13:34:01 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Pls help old perl-monger with new version syntax?
Message-Id: <87394h49ty.fsf@sapphire.mobileactivedefense.com>
r.mariotti@fdcx.net writes:
[...]
> # Define ALL needed variables & indecies
> my $fn = '' unless defined($fn);
[...]
> Global symbol "$fn" requires explicit package name
This refers to the $fn used as argument for defined. That's the '$fn'
in the symbol table of the current package, not the my-variable.
------------------------------
Date: Tue, 24 Jul 2012 14:52:27 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Pls help old perl-monger with new version syntax?
Message-Id: <slrnk0t6kc.ob2.hjp-usenet2@hrunkner.hjp.at>
On 2012-07-24 12:10, r.mariotti@fdcx.net <r.mariotti@fdcx.net> wrote:
> Been doing perl since mid-90's. Just upgraded to the latest version
> 5.14.2 and many of my perl scripts are thowing errors like no
> tomorrow.
What was the last version of perl you used? Your script doesn't work
with perl 5.8.8 (2006), so it probably doesn't work since at least 5.8.0
(2002).
> I've spent several days trying to resolve the errors without much
> success so I thought I would post here as many must have experienced
> the same.
>
> I DID research quite extensively with perldoc and google and tried
> literally all the suggestions but here it goes anyway.
>
> It appears that using the pragmas warning and strict the newest
> version is requiring predefinition of variables prior to their use.
>
> Here's a snippet of my code:
>
> # Define pragmas
> use warnings;
> use strict;
> # Define ALL needed variables & indecies
> my $fn = '' unless defined($fn);
What are you trying to do here?
defined() doesn't check if a variable exists, it checks whether the
value is (not) undef.
So this means:
if the value of the variable $fn is undef
then
create a new variable $fn in this lexical scope
and assign the empty string to it.
Except that the variable is created at compile time, so it will
always exist in this scope even if there happened to be a variable $fn
with a defined value in an outer scope.
(There is a similar but not quite identical construct for state
variables pre 5.10 - for these, use the new state feature, but I doubt
that this is what you wanted)
I think you just meant
my $fn = '';
hp
--
_ | Peter J. Holzer | Deprecating human carelessness and
|_|_) | Sysadmin WSR | ignorance has no successful track record.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Bill Code on asrg@irtf.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3742
***************************************