[32192] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3457 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 28 16:09:24 2011

Date: Thu, 28 Jul 2011 13:09:06 -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           Thu, 28 Jul 2011     Volume: 11 Number: 3457

Today's topics:
        =?UTF-8?B?UmU6IER5bmFMb2FkZXIucG0gbGluZSAyMzAgbXkgcGVyb <glex_no-spam@qwest-spam-no.invalid>
        =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_is_pe <j.joeyoung@gmail.com>
        =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_is_pe <j.joeyoung@gmail.com>
    Re: Generating an anonymous reference to an OO method (Randal L. Schwartz)
    Re: Generating an anonymous reference to an OO method <rweikusat@mssgmbh.com>
        Getting a usable reference to an OO method <matt.pounsett@gmail.com>
        LWP and Xerox printers <rthreet@gmail.com>
    Re: LWP and Xerox printers <glex_no-spam@qwest-spam-no.invalid>
        Trouble running Perl script from within a Perl script <laredotornado@gmail.com>
    Re: Trouble running Perl script from within a Perl scri <glex_no-spam@qwest-spam-no.invalid>
    Re: Trouble running Perl script from within a Perl scri <RedGrittyBrick@spamweary.invalid>
    Re: Trouble running Perl script from within a Perl scri <rweikusat@mssgmbh.com>
    Re: why won't perl say which value was uninitialized? <uri@StemSystems.com>
    Re: why won't perl say which value was uninitialized? <jidanni@jidanni.org>
    Re: why won't perl say which value was uninitialized? jidanni@jidanni.org
    Re: why won't perl say which value was uninitialized? <hjp-usenet2@hjp.at>
    Re: why won't perl say which value was uninitialized? <hjp-usenet2@hjp.at>
    Re: why won't perl say which value was uninitialized? <kst-u@mib.org>
    Re: why won't perl say which value was uninitialized? <rweikusat@mssgmbh.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 28 Jul 2011 19:13:50 +0000
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: =?UTF-8?B?UmU6IER5bmFMb2FkZXIucG0gbGluZSAyMzAgbXkgcGVybCBtb2R1bGU=?= =?UTF-8?B?IGlzIHBlcm1pc3Npb24gZGVuaWVk4oCP?=
Message-Id: <4e31b4ee$0$9086$815e3792@news.qwest.net>

On 07/28/11 16:13, Joe Young wrote:
> How do DynaLoader.pm line 230 permission errors happen?
[...]

How many times are you going to post this???

This is a permission issue... Nothing special about DynaLoader.

>
> I've installed DBD::Oracle but can't load it with permission denied.
> I've tried reinstalling it. CPAN doesn't seem that geared up for
> reinstalling things. (It's a bit messy.)

Using 'force' should be more than enough. Not 'messy' at all.

man CPAN

>
> Not surprisingly running perl cpan as root so the file
> /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBD/Oracle/
> Oracle.so is owned root:root

Check the permissions on the file and directory to make sure
everyone can read the file and execute the directories. Possibly
root's umask is more restrictive than you think.

As a user, other than root, cd to that directory.. if that fails,
check permissions on each directory leading to it.


------------------------------

Date: Thu, 28 Jul 2011 05:52:20 -0700 (PDT)
From: Joe Young <j.joeyoung@gmail.com>
Subject: =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_is_permission_?= =?UTF-8?Q?denied=E2=80=8F?=
Message-Id: <d1854192-d66a-491a-89b6-c61e168ff877@m22g2000yqh.googlegroups.com>

How do DynaLoader.pm line 230 permission errors happen?
Below is line 230 from Dynaloader.pm
my $libref = dl_load_file($file, $module->dl_load_flags) or
croak("Can't load '$file' for module $module: ".dl_error());






I've installed DBD::Oracle but can't load it with permission denied.
I've tried reinstalling it. CPAN doesn't seem that geared up for
reinstalling things. (It's a bit messy.)

Not surprisingly running perl cpan as root so the file
/usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBD/Oracle/
Oracle.so is owned root:root
as are all my other cpan modules.



[Thu Jul 21 13:14:45 2011] [error] [client 192.168.1.101]
\tinstall_driver(Oracle) failed: Can't load '/usr/perl5/site_perl/
5.8.4/i86pc-solaris-64int/auto/DBD/Oracle/Oracle.so' for module
DBD::Oracle: ld.so.1: perl: fatal: /export/home/oracle/oracle/product/
10.2.0/db_1/lib/libclntsh.so.10.1: Permission denied at /usr/
perl5/5.8.4/lib/i86pc-solaris-64int/DynaLoader.pm line 230., referer:
http://192.168.1.130/Wood-Recycling/add-new-customer.html

It's not the file itself because I've overwritten it with another file
of the same name and the error is the same. It's not the directory
that it's in because I have another localzone with the same file in it
and the same file and directory permissions and that one works just
fine!



------------------------------

Date: Thu, 28 Jul 2011 09:13:01 -0700 (PDT)
From: Joe Young <j.joeyoung@gmail.com>
Subject: =?UTF-8?Q?DynaLoader=2Epm_line_230_my_perl_module_is_permission_?= =?UTF-8?Q?denied=E2=80=8F?=
Message-Id: <c856a7d8-012e-4cc8-8a34-2318ea22ee33@y13g2000yqy.googlegroups.com>

How do DynaLoader.pm line 230 permission errors happen?
Below is line 230 from Dynaloader.pm
my $libref = dl_load_file($file, $module->dl_load_flags) or
croak("Can't load '$file' for module $module: ".dl_error());






I've installed DBD::Oracle but can't load it with permission denied.
I've tried reinstalling it. CPAN doesn't seem that geared up for
reinstalling things. (It's a bit messy.)

Not surprisingly running perl cpan as root so the file
/usr/perl5/site_perl/5.8.4/i86pc-solaris-64int/auto/DBD/Oracle/
Oracle.so is owned root:root
as are all my other cpan modules.



[Thu Jul 21 13:14:45 2011] [error] [client 192.168.1.101]
\tinstall_driver(Oracle) failed: Can't load '/usr/perl5/site_perl/
5.8.4/i86pc-solaris-64int/auto/DBD/Oracle/Oracle.so' for module
DBD::Oracle: ld.so.1: perl: fatal: /export/home/oracle/oracle/product/
10.2.0/db_1/lib/libclntsh.so.10.1: Permission denied at /usr/
perl5/5.8.4/lib/i86pc-solaris-64int/DynaLoader.pm line 230., referer:
http://192.168.1.130/Wood-Recycling/add-new-customer.html

It's not the file itself because I've overwritten it with another file
of the same name and the error is the same. It's not the directory
that it's in because I have another localzone with the same file in it
and the same file and directory permissions and that one works just
fine!



------------------------------

Date: Wed, 27 Jul 2011 15:12:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Matthew Pounsett <matt.pounsett@gmail.com>
Subject: Re: Generating an anonymous reference to an OO method
Message-Id: <867h73s790.fsf@red.stonehenge.com>

>>>>> "Matthew" == Matthew Pounsett <matt.pounsett@gmail.com> writes:

Matthew> Is there a way to get an anonymous reference to an OO method
Matthew> that can then be executed?

Just create a closure:


    my $maker = do {
       my $class = "Digest::MD5"; # or however you want to determine this
       sub { return $class->new->add(@_) };
    };

    ## later...

    print $maker->("blahblah")->hexdigest;


print "Just another Perl hacker,"; # the original
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


------------------------------

Date: Thu, 28 Jul 2011 18:47:43 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Generating an anonymous reference to an OO method
Message-Id: <87wrf2cn5s.fsf@sapphire.mobileactivedefense.com>

Matthew Pounsett <matt.pounsett@gmail.com> writes:
> Is there a way to get an anonymous reference to an OO method that can then be executed?  I'm trying to create a reference to the new() method in one of the Digest:: modules, depending on which digest type has been selected, so that I don't have to keep having the same big if() block every time I create a new digest.  My first stab at what I'm trying to attempt looked like this:
>
> ----
> use Digest::MD5;
>
> $digest = \&Digest::MD5::new;
> $foo = &$digest();
> $foo->add( "blahblahblah" );
> print $foo->hexdigest;
> ----
>
> This appears to be close, except that I get Digest::MD5->new()'s
> usage error when I try to reference &$digest.

For completeness: You still need to pass the class name as first
argument to the contstructor (or an object as first argument to an
'ordinary' method). Creating a closure which calls the desired
constructor in the proper way is IMO a better idea.



------------------------------

Date: Wed, 27 Jul 2011 15:16:02 -0700 (PDT)
From: Matthew Pounsett <matt.pounsett@gmail.com>
Subject: Getting a usable reference to an OO method
Message-Id: <ca9a8479-f0c5-4191-8b36-28cd6ab62a64@glegroupsg2000goo.googlegroups.com>

Apologies if this turns up as a duplicate post.  I posted earlier, but it h=
asn't shown up ... making a second try.

I'm building some code that makes checksums of several files, using a confi=
gurable digest algo.  In order to avoid having to repeat the same if() bloc=
k all over the place when creating new digest objects, I'd like to do that =
once, and assign a reference to the constructor for the appropriate digest =
module at that point, which I can just re-use.  I seem to be having a hard =
time coming up with the right syntax however.

The closest I've got so far is a proof of concept that looks like this:
----
use Digest::MD5;

$digest =3D \&Digest::MD5::new;
$foo =3D &$digest;
$foo->add( "blahblahblah" );
print $foo->hexdigest;
-----

This throws an error when I try to execute &$digest... I get Digest::MD5::n=
ew's usage help.  It seems it wants me to do "$foo =3D &$digest('Digest::MD=
5')" which doesn't really help with my original problem.  Does anyone have =
a suggestion for how to get what I want out of this?

Thanks!


------------------------------

Date: Thu, 28 Jul 2011 07:13:38 -0700 (PDT)
From: RAT <rthreet@gmail.com>
Subject: LWP and Xerox printers
Message-Id: <e1dd81cb-dad2-4eaf-b42d-098b08ea3961@eb9g2000vbb.googlegroups.com>

I am trying to write an LWP script to automate the retrieval of usage
reports from Xerox printers.  I called Xerox and they say there is no
automated way or alternative to the web gui which requires logging in
and hitting a button to generate new reports.  I can log in and
retrieve the reports but when I run the PHP to generate the new
reports, it says OK and does nothing.

my $ua = LWP::UserAgent->new(cookie_jar => {});
$ua->cookie_jar->set_cookie("PHPSESSID");
my $rsp = $ua->post('http://111.111.111.111/properties/authentication/
login.php?webUsername=mgtuser&webPassword=secret'); # no, not real pw
& IP

# This lines reports OK but does NOT generate a new report
my $newrep = $ua->post('http://111.111.111.111/properties/accounting/
generateReport.php');

I've tried adding more cookies (there were 3 others). I added user
agent and referring URL - no change.

It's a popular printer.  Anyone done this?  Clues?

http://yesistilluseperl.blogspot.com/


------------------------------

Date: Thu, 28 Jul 2011 15:18:25 +0000
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: LWP and Xerox printers
Message-Id: <4e317dc1$0$73606$815e3792@news.qwest.net>

On 07/28/11 14:13, RAT wrote:
> I am trying to write an LWP script to automate the retrieval of usage
> reports from Xerox printers.  I called Xerox and they say there is no
> automated way or alternative to the web gui which requires logging in
> and hitting a button to generate new reports.  I can log in and
> retrieve the reports but when I run the PHP to generate the new
> reports, it says OK and does nothing.
>
> my $ua = LWP::UserAgent->new(cookie_jar =>  {});
> $ua->cookie_jar->set_cookie("PHPSESSID");
> my $rsp = $ua->post('http://111.111.111.111/properties/authentication/
> login.php?webUsername=mgtuser&webPassword=secret'); # no, not real pw
> &  IP
>
> # This lines reports OK but does NOT generate a new report
> my $newrep = $ua->post('http://111.111.111.111/properties/accounting/
> generateReport.php');
>
> I've tried adding more cookies (there were 3 others). I added user
> agent and referring URL - no change.
>
> It's a popular printer.  Anyone done this?  Clues?

I'd suggest using Firebug or the Web Scraping Proxy to see what's sent 
when using the browser.  Possibly there is some JavaScript events 
happening when you are 'hitting a button', which you might have to 
figure out.


------------------------------

Date: Thu, 28 Jul 2011 08:52:01 -0700 (PDT)
From: "laredotornado@zipmail.com" <laredotornado@gmail.com>
Subject: Trouble running Perl script from within a Perl script
Message-Id: <e87cf430-df2d-40a0-8809-85e4052d1fe2@c5g2000yqi.googlegroups.com>

Hi,

I'm using Perl 5.10.1 on Ubuntu Linux 11.04.  I want to run a Perl
script B from within Perl script A.  I can run Perl script B fine from
the bash shell, but when I try and run it within Perl script A, it
fails to execute with a "No such file or directory " error.  I'm
hoping someone might have some advice about what I'm overlooking.

Here's how I create and spawn Perl script B ...


my $cmd = "perl /opt/scripts/selenium/generate_test_suite.pl \"$
{project} USA Tests - ${module}\" \"$destTestDir\" \"$testSuiteFile\"
";
runShellCommand( $cmd );

sub runShellCommand {
    my $cmd = shift;
    print "running command $cmd ...\n";
    open(F, "$cmd") or die "Can't execute command \"$cmd\": $!";
    while (<F>) {
        print;
    }
    close(F);
    print "done.\n\n";
}


Thanks, - Dave


------------------------------

Date: Thu, 28 Jul 2011 16:18:04 +0000
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Trouble running Perl script from within a Perl script
Message-Id: <4e318bbc$0$52252$815e3792@news.qwest.net>

On 07/28/11 15:52, laredotornado@zipmail.com wrote:
> Hi,
>
> I'm using Perl 5.10.1 on Ubuntu Linux 11.04.  I want to run a Perl
> script B from within Perl script A.  I can run Perl script B fine from
> the bash shell, but when I try and run it within Perl script A, it
> fails to execute with a "No such file or directory " error.  I'm
> hoping someone might have some advice about what I'm overlooking.
>
> Here's how I create and spawn Perl script B ...
>
>
> my $cmd = "perl /opt/scripts/selenium/generate_test_suite.pl \"$
> {project} USA Tests - ${module}\" \"$destTestDir\" \"$testSuiteFile\"
> ";

You probably don't need 'perl' there.  If you do, then 
generate_test_suite.pl could be fixed, or you *should* use
the full path to perl.

You could also use qq, to eliminate escaping the double quotes and 
there's no need for the braces either.

my $cmd = qq{ /opt/scripts/selenium/generate_test_suite.pl "$project USA 
Tests - $module" "$destTestDir" "$testSuiteFile" };


> runShellCommand( $cmd );
>
> sub runShellCommand {
>      my $cmd = shift;
>      print "running command $cmd ...\n";
>      open(F, "$cmd") or die "Can't execute command \"$cmd\": $!";

open( f, "$cmd |" ) or die "Can't execute command \"$cmd\": $!";

perldoc -f open
perldoc perlopentut


>      while (<F>) {
>          print;
>      }
>      close(F);
>      print "done.\n\n";
> }

Another option is backticks:

	my $out = `$cmd`;
	print "$out\ndone\n\n";

If you want to do something if generate_test_suite.pl dies or exits with 
an error, see perldoc IPC::Open3.



------------------------------

Date: Thu, 28 Jul 2011 17:19:24 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Trouble running Perl script from within a Perl script
Message-Id: <4e318c0d$0$2936$fa0fcedb@news.zen.co.uk>

On 28/07/2011 16:52, laredotornado@zipmail.com wrote:
> Hi,
>
> I'm using Perl 5.10.1 on Ubuntu Linux 11.04.  I want to run a Perl
> script B from within Perl script A.  I can run Perl script B fine from
> the bash shell, but when I try and run it within Perl script A, it
> fails to execute with a "No such file or directory " error.  I'm
> hoping someone might have some advice about what I'm overlooking.
>
> Here's how I create and spawn Perl script B ...
>
>
> my $cmd = "perl /opt/scripts/selenium/generate_test_suite.pl \"$
> {project} USA Tests - ${module}\" \"$destTestDir\" \"$testSuiteFile\"
> ";
> runShellCommand( $cmd );
>
> sub runShellCommand {
>      my $cmd = shift;
>      print "running command $cmd ...\n";
>      open(F, "$cmd") or die "Can't execute command \"$cmd\": $!";

`open(F, "$cmd")` opens a file with filename equal to the contents of 
the $cmd string. You want a pipe symbol. See `perldoc -f open` (I think).

>      while (<F>) {
>          print;
>      }
>      close(F);
>      print "done.\n\n";
> }
>

P.S. Your Perl looks rather old. Nowadays most people use lexical 
file-handles and three-argument opens.

P.P.S If generate_test_suite (or part of it) can be converted into a 
module, this might be a better approach.

-- 
RGB


------------------------------

Date: Thu, 28 Jul 2011 18:52:33 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Trouble running Perl script from within a Perl script
Message-Id: <87sjpqcmxq.fsf@sapphire.mobileactivedefense.com>

"laredotornado@zipmail.com" <laredotornado@gmail.com> writes:
> Here's how I create and spawn Perl script B ...
>
>
> my $cmd = "perl /opt/scripts/selenium/generate_test_suite.pl \"$
> {project} USA Tests - ${module}\" \"$destTestDir\" \"$testSuiteFile\"
> ";
> runShellCommand( $cmd );
>
> sub runShellCommand {
>     my $cmd = shift;
>     print "running command $cmd ...\n";
>     open(F, "$cmd") or die "Can't execute command \"$cmd\": $!";
>     while (<F>) {
>         print;
>     }
>     close(F);
>     print "done.\n\n";
> }

Provided that's really all what you want, you can just use

	system($cmd);

instead of the runShellCommand subroutine. Since the script you are
starting will use the same standard output channel as its parent
process, its output will automatically appear where it should and the
'wait until done' is already done by system (and in perl, this even
doesn't spawn an intermediate shell except if shell features are
actually used by the command).



------------------------------

Date: Thu, 28 Jul 2011 01:12:57 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <878vrjugx2.fsf@quad.sysarch.com>

>>>>> "W" == Willem  <willem@toad.stack.nl> writes:

  W> ) Not a witch hunt... just a fairly straightforward interpretation of your
  W> ) first statement.  Please read it as we obviously did, and you'll see why
  W> ) we started looking for instances of warnings during autoviv.

  W> Sorry, but I don't see how I could, when you're blatantly
  W> ignoring half of what I wrote.

and you haven't posted code that has warnings during actual
autovivification. it doesn't happen. you have 3 perl expert here (tad,
randal and myself) with about 50+ years of perl experience saying it
doesn't happen. you need to post code that exactly does what you
claimed, warnings issued during autoviv. not warning issued when near
code that does autoviv. 

uri

-- 
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com --
------------  Perl Developer Recruiting and Placement Services  -------------
-----  Perl Code Review, Architecture, Development, Training, Support -------


------------------------------

Date: Wed, 27 Jul 2011 22:14:14 -0700 (PDT)
From: jidanni <jidanni@jidanni.org>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <4ce2b740-ccbe-4b04-aa03-772465f475b9@glegroupsg2000goo.googlegroups.com>

I'm the Original Poster. Why doesn't somebody show some respect and at least acknowledge they saw this followup I posted 28 hours ago?:
On Wednesday, July 27, 2011 8:58:26 AM UTC+8, jidanni wrote:
> Well there is no denying that perl could mention that it was $_ that was bothering it in
> $ perl -we 'print $_ for undef'
> Use of uninitialized value in print at -e line 1.
> 
> You could imagine the wild goose chase that could result if there were several other variables on that line.
> 
> Do submit a bug for me. I'm locked out for life from @perl.org mailing lists.



------------------------------

Date: Thu, 28 Jul 2011 05:30:28 +0000 (UTC)
From: jidanni@jidanni.org
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <j0qs5j$ses$1@news.datemas.de>

Well there is no denying that perl could mention that it was $_ that was bothering it in
$ perl -we 'print $_ for undef'
Use of uninitialized value in print at -e line 1.
And here too!:
$ perl -we 'print for undef'
Use of uninitialized value in print at -e line 1.

You could imagine the wild goose chase that could result if there were several other variables on that line.

Do submit a bug for me. I'm locked out for life from @perl.org mailing lists.

(P.S., I posted the above in
Message-ID: <87fd2cdd-75e4-46fe-b8ba-b8b7cde93026@glegroupsg2000goo.googlegroups.com>
but you didn't see it because Google Groups is ****ed.)


------------------------------

Date: Thu, 28 Jul 2011 12:51:02 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <slrnj32fom.143.hjp-usenet2@hrunkner.hjp.at>

On 2011-07-28 05:12, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "W" == Willem  <willem@toad.stack.nl> writes:
>
>  W> ) Not a witch hunt... just a fairly straightforward interpretation of your
>  W> ) first statement.  Please read it as we obviously did, and you'll see why
>  W> ) we started looking for instances of warnings during autoviv.
>
>  W> Sorry, but I don't see how I could, when you're blatantly
>  W> ignoring half of what I wrote.
>
> and you haven't posted code that has warnings during actual
> autovivification. it doesn't happen. you have 3 perl expert here (tad,
> randal and myself) with about 50+ years of perl experience saying it
> doesn't happen. you need to post code that exactly does what you
> claimed, warnings issued during autoviv.

No, he doesn't have to do this because he never meant to claim that
warnings are issued during autovivification. He posted an ambiguous
statement that several people misunderstood (myself included). He has
since clarified this (at least three times, if I counted correctly). Why
do you insist that he should prove your wrong interpretation of his
original ambiguous statement?

	hp



------------------------------

Date: Thu, 28 Jul 2011 13:00:28 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <slrnj32gae.143.hjp-usenet2@hrunkner.hjp.at>

On 2011-07-28 05:30, jidanni@jidanni.org <jidanni@jidanni.org> wrote:
> Well there is no denying that perl could mention that it was $_ that was bothering it in
> $ perl -we 'print $_ for undef'
> Use of uninitialized value in print at -e line 1.

Interesting:

% perl -we '$_ = undef; print $_'
Use of uninitialized value $_ in print at -e line 1.

or even:

% perl -we 'print $_' 

Looks like the for loop somehow interferes with the warning.


> Do submit a bug for me. I'm locked out for life from @perl.org mailing lists.

I just tested this with 5.10.1. Is the bug still present in 5.14?

	hp



------------------------------

Date: Thu, 28 Jul 2011 07:58:45 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <lntya6fo4a.fsf@nuthaus.mib.org>

"Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
> On 2011-07-28 05:30, jidanni@jidanni.org <jidanni@jidanni.org> wrote:
>> Well there is no denying that perl could mention that it was $_ that
>> was bothering it in
>> $ perl -we 'print $_ for undef'
>> Use of uninitialized value in print at -e line 1.
>
> Interesting:
>
> % perl -we '$_ = undef; print $_'
> Use of uninitialized value $_ in print at -e line 1.
>
> or even:
>
> % perl -we 'print $_' 
>
> Looks like the for loop somehow interferes with the warning.
>
>
>> Do submit a bug for me. I'm locked out for life from @perl.org
>> mailing lists.
>
> I just tested this with 5.10.1. Is the bug still present in 5.14?

Yes.

% /usr/local/apps/perl-5.14.0/bin/perl -we 'print $_'
Use of uninitialized value $_ in print at -e line 1.
% /usr/local/apps/perl-5.14.0/bin/perl -we 'print $_ for undef' 
Use of uninitialized value in print at -e line 1.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


------------------------------

Date: Thu, 28 Jul 2011 19:33:03 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: why won't perl say which value was uninitialized?
Message-Id: <87mxfycl28.fsf@sapphire.mobileactivedefense.com>

"Uri Guttman" <uri@StemSystems.com> writes:
>>>>>> "W" == Willem  <willem@toad.stack.nl> writes:
>
>   W> ) Not a witch hunt... just a fairly straightforward interpretation of your
>   W> ) first statement.  Please read it as we obviously did, and you'll see why
>   W> ) we started looking for instances of warnings during autoviv.
>
>   W> Sorry, but I don't see how I could, when you're blatantly
>   W> ignoring half of what I wrote.
>
> and you haven't posted code that has warnings during actual
> autovivification.

Since there was no 'autovivification' in the posted code, that's
hardly surprising. Applying a mutating operator to a scalar which
happens to be undefined causes the scalar to have the (expected)
defined value that was created by performing the requested operation with
the (suitably converted) value of the scalar  and whatever other
operand(s) (if any) were given. No Perl object which didn't exist so
far is being created.

The Perl reference manual defines autovivification (one of those
'great new features') as 'references being created on demand when
something is dereferenced in an lvalue context', eg, assuming the
following code:

	my $a;

        $a->[0]->{sargnagel} = 3;

an array reference will be 'autovivified' and assigned to $a and a
hash reference will be autovivified and assigned to $a->[0] and the
key sargnagel will be added to the corresponding hash with a value of
3.

In constrast to this, this is the code from sv_inc that will get
executed when a scalar for which defined would return false is
incremented:

  if (!(flags & SVp_POK) || !*SvPVX_const(sv)) {
        if ((flags & SVTYPEMASK) < SVt_PVIV)
            sv_upgrade(sv, ((flags & SVTYPEMASK) > SVt_IV ? SVt_PVIV : SVt_IV));
        (void)SvIOK_only(sv);
        SvIV_set(sv, 1);
        return;
    }

The so-called 'body' of the correspoding SV is upgraded (replaced
with) an IV body or a PVIV body (the latter happens if the undefined
value was ever stringified), the SV flags are set to 'this is an
integer and nothing but an integer' and the integer value is set to
one. As a live demonstration:

---------------------
[rw@error]~ $perl -de 0

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   0
  DB<1> use Devel::Peek

  DB<2> my $x; # create a SV

  DB<3> Dump($x)
SV = NULL(0x0) at 0x83aa8d8
  REFCNT = 1
  FLAGS = ()

  DB<4> ++$x

  DB<5> Dump($x)
SV = IV(0x83aa8d4) at 0x83aa8d8
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 1

  DB<6> my $y; # create another SV

  DB<7> Dump($y)
SV = NULL(0x0) at 0x839c8c0
  REFCNT = 1
  FLAGS = ()

  DB<8> "$y" # stringify it

  DB<9> Dump($y)
SV = PV(0x832a790) at 0x839c8c0
  REFCNT = 1
  FLAGS = ()
  PV = 0

  DB<10> p defined($y)

  DB<11> ++$y

  DB<12> Dump($y)
SV = PVIV(0x817e76c) at 0x839c8c0
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 1
  PV = 0

-----------------

Three people whose added Perl experience is 50 years means 16.6666...
years per person. Personally, I can claim something like 15 years, but
spent with writing code and not with trying to confuse people in order
to make them buy into my political agendas ...


------------------------------

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 3457
***************************************


home help back first fref pref prev next nref lref last post