[32042] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3306 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 4 00:09:23 2011

Date: Thu, 3 Mar 2011 21:09:07 -0800 (PST)
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, 3 Mar 2011     Volume: 11 Number: 3306

Today's topics:
        LWP::Simple went haywire this morning <jwcarlton@gmail.com>
    Re: LWP::Simple went haywire this morning (Randal L. Schwartz)
    Re: LWP::Simple went haywire this morning <glex_no-spam@qwest-spam-no.invalid>
    Re: LWP::Simple went haywire this morning <jwcarlton@gmail.com>
    Re: LWP::Simple went haywire this morning <jwcarlton@gmail.com>
        Perl sort different from unix sort <jose.luis.fdez.diaz@gmail.com>
    Re: Perl sort different from unix sort <charlie+newsgroups@newint.org>
    Re: Perl sort different from unix sort <jose.luis.fdez.diaz@gmail.com>
    Re: Perl sort different from unix sort (Randal L. Schwartz)
    Re: Perl sort different from unix sort <glex_no-spam@qwest-spam-no.invalid>
    Re: Perl sort different from unix sort <smallpond@juno.com>
        Readline question <dba1@csi.it>
    Re: Readline question <NoSpamPleaseButThisIsValid3@gmx.net>
    Re: Readline question <dba1@csi.it>
    Re: Readline question <smallpond@juno.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 3 Mar 2011 15:22:03 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: LWP::Simple went haywire this morning
Message-Id: <778b6238-771c-41ee-8035-8fc52841f6b5@r17g2000vbc.googlegroups.com>

I don't know if it's a server update or what, but sometime between 4am
and 8:30am, my Perl scripts that load LWP::Simple started having
errors.

The version of LWP::Simple currently running is 5.837.

Here's a complete test script that's giving such an error:

#!/usr/bin/perl

use LWP::Simple qw(!head);
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

$get_file = get("http://www.EXAMPLE.com/test.txt");
  die "Couldn't get it!" unless defined $get_file;

print "Content-type: text/html\n\n";
print $get_file;
exit;


For this purpose, "test.txt" contains "Hello". Yes, I know that the
test could be done using OPEN, but it's just a test; the main scripts
are getting executed PHP files.

I've updated cPanel, reinstalled Perl, with no luck. The server is
semi-managed, and the management company has been working with me for
about 3 hours, but haven't found anything, either.

Any thoughts?


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

Date: Thu, 03 Mar 2011 15:36:27 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: LWP::Simple went haywire this morning
Message-Id: <864o7jojyc.fsf@red.stonehenge.com>

>>>>> "jwcarlton" == jwcarlton  <jwcarlton@gmail.com> writes:

jwcarlton> $get_file = get("http://www.EXAMPLE.com/test.txt");

 ...

jwcarlton> Any thoughts?


Yes.  EXAMPLE.com is a reserved name by the IANA.  That script cannot
possibly work as is.

And most likely, the problem is the remote server you are connecting to,
not this simple Perl script, so without a proper thing for us to run,
it's silly to ask *us* to debug what only *you* can run.

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, 03 Mar 2011 17:46:43 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: LWP::Simple went haywire this morning
Message-Id: <4d702863$0$3032$815e3792@news.qwest.net>

jwcarlton wrote:
> I don't know if it's a server update or what, but sometime between 4am
> and 8:30am, my Perl scripts that load LWP::Simple started having
> errors.
> 
> The version of LWP::Simple currently running is 5.837.
> 
> Here's a complete test script that's giving such an error:

What error?

> 
> #!/usr/bin/perl
> 
> use LWP::Simple qw(!head);
> use CGI qw(:standard);
> use CGI::Carp qw(fatalsToBrowser);
> 
> $get_file = get("http://www.EXAMPLE.com/test.txt");
>   die "Couldn't get it!" unless defined $get_file;
> 
> print "Content-type: text/html\n\n";
> print $get_file;
> exit;

Anything in the Web server error/access logs?
Can you get there via telnet?
Try debug mode or LWP::Debug.
Remove CGI from the equation.

Many, many things to check/try. You're not showing us
any useful information. I'd start with network access
first, then the Web server, then fire up the debugger or
use LWP::Debug.




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

Date: Thu, 3 Mar 2011 17:55:48 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: LWP::Simple went haywire this morning
Message-Id: <5f7fc196-d8bb-4b53-a01e-1868ea2ea3ce@n18g2000vbq.googlegroups.com>

> What error?

There's no error message, it just dies and gives the die message.
Nothing shows in the error log for it.


> Anything in the Web server error/access logs?
> Can you get there via telnet?
> Try debug mode or LWP::Debug.
> Remove CGI from the equation.

I removed CGI completely (it wasn't needed for the test), but that had
no impact. I'm not familiar with debug mode, though. I tried adding
LWP::Debug, but there isn't any info for this module on CPAN, and I
don't know how to use it?


> Many, many things to check/try. You're not showing us
> any useful information. I'd start with network access
> first, then the Web server, then fire up the debugger or
> use LWP::Debug.

I did have a lot of "new" errors in the error log. One was related to
"head" being used in LWP::Simple and CGI, so I had to change "use
LWP::Simple" to "use LWP::Simple qw(!head)". Another is a PHP warning:

mysql_num_rows(): supplied argument is not a valid MySQL result
resource

These are both new as of today, even though none of my scripts have
changed.

I also just found a "new" error_log on my site, that's different from
the server's error log. This one just popped up today. It has a ton of
these warnings:

***
[04-Mar-2011 00:14:00] PHP Warning:  session_start() [<a
href='function.session-start'>function.session-start</a>]: Cannot send
session cache limiter - headers already sent (output started at /home/
USERID/public_html/includes/variables.php:14) in /home/USERID/
public_html/includes/variables.php on line 14
[04-Mar-2011 00:14:00] PHP Warning:  chmod() [<a
href='function.chmod'>function.chmod</a>]: Operation not permitted in /
home/USERID/public_html/includes/variables.php on line 18
[04-Mar-2011 00:14:00] PHP Fatal error:  Call to undefined function
apache_request_headers() in /home/USERID/public_html/includes/
members.php on line 43
[04-Mar-2011 00:14:00] PHP Warning:  Unknown: open(/tmp/
sess_3aee31fe86eb1fa10750b7f6361f572e, O_RDWR) failed: Permission
denied (13) in Unknown on line 0
[04-Mar-2011 00:14:00] PHP Warning:  Unknown: Failed to write session
data (files). Please verify that the current setting of
session.save_path is correct (/tmp) in Unknown on line 0
****

By "ton", I mean 1.5MB in the last hour or so.

New oddity discovered. I have a second server with the same versions
of everything on it. I uploaded the test script above to an account on
the second server, getting a file from the first server, and the get
succeeded with no errors. But the same script on the first server,
getting a file from its own domain, has an error. So, I don't think it
can be easily duplicated; it's obviously an error on this server,
specifically.



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

Date: Thu, 3 Mar 2011 19:44:45 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: LWP::Simple went haywire this morning
Message-Id: <823cf408-f379-4c94-856d-f7df15075ace@t16g2000vbi.googlegroups.com>

On Mar 3, 8:55=A0pm, jwcarlton <jwcarl...@gmail.com> wrote:
> > What error?
>
> There's no error message, it just dies and gives the die message.
> Nothing shows in the error log for it.
>
> > Anything in the Web server error/access logs?
> > Can you get there via telnet?
> > Try debug mode or LWP::Debug.
> > Remove CGI from the equation.
>
> I removed CGI completely (it wasn't needed for the test), but that had
> no impact. I'm not familiar with debug mode, though. I tried adding
> LWP::Debug, but there isn't any info for this module on CPAN, and I
> don't know how to use it?
>
> > Many, many things to check/try. You're not showing us
> > any useful information. I'd start with network access
> > first, then the Web server, then fire up the debugger or
> > use LWP::Debug.
>
> I did have a lot of "new" errors in the error log. One was related to
> "head" being used in LWP::Simple and CGI, so I had to change "use
> LWP::Simple" to "use LWP::Simple qw(!head)". Another is a PHP warning:
>
> mysql_num_rows(): supplied argument is not a valid MySQL result
> resource
>
> These are both new as of today, even though none of my scripts have
> changed.
>
> I also just found a "new" error_log on my site, that's different from
> the server's error log. This one just popped up today. It has a ton of
> these warnings:
>
> ***
> [04-Mar-2011 00:14:00] PHP Warning: =A0session_start() [<a
> href=3D'function.session-start'>function.session-start</a>]: Cannot send
> session cache limiter - headers already sent (output started at /home/
> USERID/public_html/includes/variables.php:14) in /home/USERID/
> public_html/includes/variables.php on line 14
> [04-Mar-2011 00:14:00] PHP Warning: =A0chmod() [<a
> href=3D'function.chmod'>function.chmod</a>]: Operation not permitted in /
> home/USERID/public_html/includes/variables.php on line 18
> [04-Mar-2011 00:14:00] PHP Fatal error: =A0Call to undefined function
> apache_request_headers() in /home/USERID/public_html/includes/
> members.php on line 43
> [04-Mar-2011 00:14:00] PHP Warning: =A0Unknown: open(/tmp/
> sess_3aee31fe86eb1fa10750b7f6361f572e, O_RDWR) failed: Permission
> denied (13) in Unknown on line 0
> [04-Mar-2011 00:14:00] PHP Warning: =A0Unknown: Failed to write session
> data (files). Please verify that the current setting of
> session.save_path is correct (/tmp) in Unknown on line 0
> ****
>
> By "ton", I mean 1.5MB in the last hour or so.
>
> New oddity discovered. I have a second server with the same versions
> of everything on it. I uploaded the test script above to an account on
> the second server, getting a file from the first server, and the get
> succeeded with no errors. But the same script on the first server,
> getting a file from its own domain, has an error. So, I don't think it
> can be easily duplicated; it's obviously an error on this server,
> specifically.

I believe (he said with his fingers crossed) that the error is
resolved now. Turns out that it wasn't even on my end; it was the
management company's nameservers.

Thanks for your help, though, guys.


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

Date: Thu, 3 Mar 2011 08:52:36 -0800 (PST)
From: Jose Luis <jose.luis.fdez.diaz@gmail.com>
Subject: Perl sort different from unix sort
Message-Id: <166c1fa2-ee6b-4130-bd46-800ff3bfc925@glegroupsg2000goo.googlegroups.com>

Hi,

How can I get the same sort for "foo.txt" in perl and unix sort?


<<snip>>

indra@bhsciences:/tmp$ cat foo.txt
1 2
10 1
indra@bhsciences:/tmp$ cat sort.pl

open my $fh, shift;

my @s1 = <$fh>;
print sort @s1;

indra@bhsciences:/tmp$ perl sort.pl foo.txt
1 2
10 1
indra@bhsciences:/tmp$ sort foo.txt
10 1
1 2
indra@bhsciences:/tmp$ uname -a
Linux bhsciences 2.6.32 #3 SMP Tue May 11 10:48:46 CEST 2010 x86_64 GNU/Linux


<<snip>>

Thanks in advance,
Jose Luis


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

Date: Thu, 03 Mar 2011 17:58:09 +0000
From: Charlie Harvey <charlie+newsgroups@newint.org>
Subject: Re: Perl sort different from unix sort
Message-Id: <ikokrj$1r4$1@news.eternal-september.org>

On 03/03/11 16:52, Jose Luis wrote:
> Hi,
> 
> How can I get the same sort for "foo.txt" in perl and unix sort?

Sort numerically with -n?

$ sort -n foo.txt
1 2
10 1
-----------------8<---------------
> indra@bhsciences:/tmp$ perl sort.pl foo.txt
> 1 2
> 10 1
> indra@bhsciences:/tmp$ sort foo.txt
> 10 1
> 1 2
-----------------8<---------------


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

Date: Thu, 3 Mar 2011 11:31:13 -0800 (PST)
From: Jose Luis <jose.luis.fdez.diaz@gmail.com>
Subject: Re: Perl sort different from unix sort
Message-Id: <838a1999-2c85-438c-a3d4-f6332c546b40@glegroupsg2000goo.googlegroups.com>


It doesn't run with this file:

1 10 1
1 1 2


Regards,
Jose Luis


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

Date: Thu, 03 Mar 2011 11:52:01 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl sort different from unix sort
Message-Id: <86bp1souce.fsf@red.stonehenge.com>

>>>>> "Jose" == Jose Luis <jose.luis.fdez.diaz@gmail.com> writes:

Jose> indra@bhsciences:/tmp$ perl sort.pl foo.txt
Jose> 1 2
Jose> 10 1
Jose> indra@bhsciences:/tmp$ sort foo.txt
Jose> 10 1
Jose> 1 2
Jose> indra@bhsciences:/tmp$ uname -a
Jose> Linux bhsciences 2.6.32 #3 SMP Tue May 11 10:48:46 CEST 2010
Jose> x86_64 GNU/Linux

Works fine on FreeBSD.  Maybe Linux broke sort.

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, 03 Mar 2011 14:59:13 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Perl sort different from unix sort
Message-Id: <4d700122$0$9087$815e3792@news.qwest.net>

Jose Luis wrote:
> It doesn't run with this file:
> 
> 1 10 1
> 1 1 2

FYI: It doesn't run with any file.

# It /etc/passwd
It: Command not found.




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

Date: Thu, 03 Mar 2011 16:14:37 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Perl sort different from unix sort
Message-Id: <ikp0ce$tg6$1@news.eternal-september.org>

On 03/03/2011 11:52 AM, Jose Luis wrote:
> Hi,
>
> How can I get the same sort for "foo.txt" in perl and unix sort?
>
>
> <<snip>>
>
> indra@bhsciences:/tmp$ cat foo.txt
> 1 2
> 10 1
> indra@bhsciences:/tmp$ cat sort.pl
>
> open my $fh, shift;
>
> my @s1 =<$fh>;
> print sort @s1;
>
> indra@bhsciences:/tmp$ perl sort.pl foo.txt
> 1 2
> 10 1
> indra@bhsciences:/tmp$ sort foo.txt
> 10 1
> 1 2
> indra@bhsciences:/tmp$ uname -a
> Linux bhsciences 2.6.32 #3 SMP Tue May 11 10:48:46 CEST 2010 x86_64 GNU/Linux
>
>
> <<snip>>

UNIX sort:
If no flags are specified, the sort command sorts entire lines of the input file
based upon the collation order of the current locale.

Perl sort:
If SUBNAME or BLOCK is omitted, "sort"s in standard string comparison order.
When "use locale" is in effect, "sort LIST" sorts LIST according to the current
collation locale.  See perl-locale.


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

Date: Thu, 03 Mar 2011 12:23:24 +0100
From: mauro papandrea <dba1@csi.it>
Subject: Readline question
Message-Id: <ikntnd$6v9$1@mophus.csi.it>

 > cat dati
line1
line2
line3
line4

This simple program ( an oversimplified version of my original one for 
sake of simplicity ) works:

#!/bin/perl
open (FILE, "dati");
while ( <FILE> ) {
     $line = readline(FILE);
     print "$. $line";
}
close(FILE);

this is its output:

2 line2
4 line4

However, this oneliner gives a weird error:

 > perl -ne '$line = readline; print "$. $line"; ' dati

Modification of a read-only value attempted at -e line 1.

What am I missing?

Thank you

Regards

Mauro


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

Date: Thu, 03 Mar 2011 16:01:04 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: Readline question
Message-Id: <4d6fad31$0$7658$9b4e6d93@newsspool1.arcor-online.net>

On 03.03.2011 12:23, mauro papandrea wrote:
>  > cat dati
> line1
> line2
> line3
> line4
> 
> However, this oneliner gives a weird error:
> 
>  > perl -ne '$line = readline; print "$. $line"; ' dati
> 
> Modification of a read-only value attempted at -e line 1.
> 
> What am I missing?

Seems to be a bug in older Perl versions. I can reproduce this behaviour
with 5.8.8, however it works without any problem in 5.10.1.

- Wolf


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

Date: Thu, 03 Mar 2011 16:36:30 +0100
From: mauro papandrea <dba1@csi.it>
Subject: Re: Readline question
Message-Id: <ikochv$dls$1@mophus.csi.it>

On 03/03/2011 16.01, Wolf Behrenhoff wrote:
> On 03.03.2011 12:23, mauro papandrea wrote:
>>   >  cat dati
>> line1
>> line2
>> line3
>> line4
>>
>> However, this oneliner gives a weird error:
>>
>>   >  perl -ne '$line = readline; print "$. $line"; ' dati
>>
>> Modification of a read-only value attempted at -e line 1.
>>
>> What am I missing?
>
> Seems to be a bug in older Perl versions. I can reproduce this behaviour
> with 5.8.8, however it works without any problem in 5.10.1.
>
> - Wolf


Thank you very much.
As a matter of fact, I was using 5.8 version ( I apologize for not 
having posted that ).

Have a nice day

Mauro


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

Date: Thu, 03 Mar 2011 10:55:34 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Readline question
Message-Id: <ikodlv$t0d$1@news.eternal-september.org>

On 03/03/2011 10:01 AM, Wolf Behrenhoff wrote:
> On 03.03.2011 12:23, mauro papandrea wrote:
>>   >  cat dati
>> line1
>> line2
>> line3
>> line4
>>
>> However, this oneliner gives a weird error:
>>
>>   >  perl -ne '$line = readline; print "$. $line"; ' dati
>>
>> Modification of a read-only value attempted at -e line 1.
>>
>> What am I missing?
>
> Seems to be a bug in older Perl versions. I can reproduce this behaviour
> with 5.8.8, however it works without any problem in 5.10.1.
>

It's not a bug.  In perl 5.8.8 the parameter to readline had no default to ARGV.
The documentation is clear.




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

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


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