quotes difference in Perl5.6 vs 5.8
quotes difference in Perl5.6 vs 5.8
am 12.10.2007 02:48:29 von Petr Vileta
I have script written in Perl 5.6.1 and it wotk fine. But when I run the
same script on hosting server then this fail on trivial operation. On server
Perl 5.8.0 is installed.
The example to ilustrate error is this
#!/usr/bin/perl
use strict;
use warnings;
my $var = "abcd'efg";
open OUT, "> log.txt";
print OUT "$var\n"; # here script fail on server with SIG-PIPE signal
close OUT;
Is something wrong in my script or is some bug in Perl 5.8.0 ?
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: quotes difference in Perl5.6 vs 5.8
am 12.10.2007 04:09:41 von Tad McClellan
Petr Vileta wrote:
> print OUT "$var\n"; # here script fail on server with SIG-PIPE signal
Please do not para-phrase error messages, post the actual
text of the message that you are getting.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Re: quotes difference in Perl5.6 vs 5.8
am 12.10.2007 04:32:54 von Paul Lalli
On Oct 11, 8:48 pm, "Petr Vileta" wrote:
> I have script written in Perl 5.6.1 and it wotk fine. But when I run the
> same script on hosting server then this fail on trivial operation. On server
> Perl 5.8.0 is installed.
> The example to ilustrate error is this
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> my $var = "abcd'efg";
> open OUT, "> log.txt";
You're not checking the return value of open. You have no idea
whether or not this file was actually opened.
open OUT, '>', 'log.txt' or die "Could not open log: $!";
> print OUT "$var\n"; # here script fail on server with SIG-PIPE signal
What does that mean? Please show the actual error message received.
If the open above didn't succeed, then you're printing to an unopened
filehandle, which absolutely *should* cause your program to fail.
Paul Lalli
Re: quotes difference in Perl5.6 vs 5.8
am 12.10.2007 11:01:56 von Abigail
_
Petr Vileta (stoupa@practisoft.cz) wrote on VCLV September MCMXCIII in
:
)) I have script written in Perl 5.6.1 and it wotk fine. But when I run the
)) same script on hosting server then this fail on trivial operation. On server
)) Perl 5.8.0 is installed.
)) The example to ilustrate error is this
))
)) #!/usr/bin/perl
)) use strict;
)) use warnings;
)) my $var = "abcd'efg";
)) open OUT, "> log.txt";
)) print OUT "$var\n"; # here script fail on server with SIG-PIPE signal
)) close OUT;
))
)) Is something wrong in my script or is some bug in Perl 5.8.0 ?
There's something wrong with your script. You're not checking the
return value of 'open', blindly assuming it succeeds.
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
Re: quotes difference in Perl5.6 vs 5.8
am 13.10.2007 07:11:15 von Petr Vileta
Paul Lalli wrote:
> On Oct 11, 8:48 pm, "Petr Vileta" wrote:
>> I have script written in Perl 5.6.1 and it wotk fine. But when I run
>> the same script on hosting server then this fail on trivial
>> operation. On server Perl 5.8.0 is installed.
>> The example to ilustrate error is this
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>> my $var = "abcd'efg";
>> open OUT, "> log.txt";
>
> You're not checking the return value of open. You have no idea
> whether or not this file was actually opened.
>
> open OUT, '>', 'log.txt' or die "Could not open log: $!";
I already do it in the same ways as you and OUT is opened and some is
written in it ;-) This was be a example only.
>
>> print OUT "$var\n"; # here script fail on server with SIG-PIPE signal
>
Real erorr is this:
------CUT--------
SIG-PIPE at /home/leon/priceminer/priceminer.pl line 34
main::__ANON__('PIPE') called at /home/leon/priceminer/priceminer.pl line
1781
eval {...} called at /home/leon/priceminer/priceminer.pl line 1781
main::loging(0, ' IP: SVC-COR-NS5X J-Care Core Support for NS5X
(all') called at /home/leon/priceminer/priceminer.pl line 1087
------CUT--------
I know that string I want to write to OUT pipe is
" IP: SVC-COR-NS5X J-Care Core Support for NS5X (all')"
I store it to variable $var this way
$var = " IP: SVC-COR-NS5X J-Care Core Support for NS5X (all')";
and now I call function
loging(0,$var);
sub loging {
my ($something_not_important, $message) = @_;
print OUT "$message\n";
}
By me the problem is in apostrophe near the string end. On Perl 5.6.1 this
work without problems, but on 5.8.0 this fail. I tried to change print to
pipe to
print OUT $message, "\n";
and now this work on both Perl versions.
Something must be wrong in Perl 5.8.0 I think ;-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: quotes difference in Perl5.6 vs 5.8
am 13.10.2007 07:16:55 von Petr Vileta
Abigail wrote:
> _
> Petr Vileta (stoupa@practisoft.cz) wrote on VCLV September MCMXCIII in
> :
> )) I have script written in Perl 5.6.1 and it wotk fine. But when I
> run the )) same script on hosting server then this fail on trivial
> operation. On server )) Perl 5.8.0 is installed.
> )) The example to ilustrate error is this
> ))
> )) #!/usr/bin/perl
> )) use strict;
> )) use warnings;
> )) my $var = "abcd'efg";
> )) open OUT, "> log.txt";
> )) print OUT "$var\n"; # here script fail on server with SIG-PIPE
> signal )) close OUT;
> ))
> )) Is something wrong in my script or is some bug in Perl 5.8.0 ?
>
>
> There's something wrong with your script. You're not checking the
> return value of 'open', blindly assuming it succeeds.
>
I checking it, of course. This was be example only. When my script fail then
tens or hudreds of lines are written in.
I thing that some difference is between Perl 5.6.1 and 5.8.0 in work with
quoutes.
#!/usr/bin/perl
use strict;
use warnings;
my $var = "abcd'efg";
open OUT, "> log.txt" or die("You stupid!");
print OUT "$var\n";
close OUT;
This work in Perl 5.6.1 but fail in 5.8.0, but if I change this
print OUT "$var\n";
to this
print OUT $var, "\n";
then this work in both Perl versions.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: quotes difference in Perl5.6 vs 5.8
am 13.10.2007 20:01:41 von Ben Morrow
Quoth "Petr Vileta" :
> Abigail wrote:
> > _
> > Petr Vileta (stoupa@practisoft.cz) wrote on VCLV September MCMXCIII in
> > :
> > )) I have script written in Perl 5.6.1 and it wotk fine. But when I
> > run the )) same script on hosting server then this fail on trivial
> > operation. On server )) Perl 5.8.0 is installed.
> > )) The example to ilustrate error is this
> > ))
> > )) #!/usr/bin/perl
> > )) use strict;
> > )) use warnings;
> > )) my $var = "abcd'efg";
> > )) open OUT, "> log.txt";
> > )) print OUT "$var\n"; # here script fail on server with SIG-PIPE
> > signal )) close OUT;
> > ))
> > )) Is something wrong in my script or is some bug in Perl 5.8.0 ?
> >
> >
> > There's something wrong with your script. You're not checking the
> > return value of 'open', blindly assuming it succeeds.
> >
> I checking it, of course. This was be example only. When my script fail then
> tens or hudreds of lines are written in.
> I thing that some difference is between Perl 5.6.1 and 5.8.0 in work with
> quoutes.
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> my $var = "abcd'efg";
> open OUT, "> log.txt" or die("You stupid!");
> print OUT "$var\n";
> close OUT;
>
> This work in Perl 5.6.1 but fail in 5.8.0, but if I change this
Don't use 5.8.0. It is very buggy. You should upgrade to 5.8.1 if at all
possible.
> print OUT "$var\n";
> to this
> print OUT $var, "\n";
> then this work in both Perl versions.
I *seriously* doubt this makes any difference... I think it's more
likely that the error is rather random, and is appearing on the wrong
line because of the 5.8 safe signals code (which causes signals to
appear to be delivered later than they should be). What is STDERR open
to? My suspicion is that it is open to a pipe, and that
1. the open is failing
2. STDERR is a pipe that has been closed
3. die is attempting to write to that pipe, and getting SIGPIPE
4. perl delivers that signal one statement too late, so it appears
to you that it is the print that is signalling.
What happens if you set $SIG{PIPE} to 'IGNORE' and check the return
value of all your print statements? If it is the print that is
signalling, then it should start failing with $! set to EPIPE. If I am
correct then the die error will go nowhere and the print will fail with
EBADF, or EINVAL, or some such (it ought to be EBADF).
What happens if, instead of this, you install your SIGPIPE handler with
POSIX::sigaction, which will bypass safe signals; something like
use POSIX qw/sigaction SIGPIPE/;
use Carp qw/cluck/;
sigaction
SIGPIPE,
POSIX::SigAction->new(
sub { cluck "got SIGPIPE" }
);
What happens if you add a call to Scalar::Util::openhandle, to check
that the filehandle is actually open?
Ben
Re: quotes difference in Perl5.6 vs 5.8
am 14.10.2007 03:32:55 von Petr Vileta
Ben Morrow wrote:
> Quoth "Petr Vileta" :
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>> my $var = "abcd'efg";
>> open OUT, "> log.txt" or die("You stupid!");
>> print OUT "$var\n";
>> close OUT;
>>
>> This work in Perl 5.6.1 but fail in 5.8.0, but if I change this
>
> Don't use 5.8.0. It is very buggy. You should upgrade to 5.8.1 if at
> all possible.
>
Thank you for confirmation of my suspicion :-) I never installed Perl 5.8.0
but admin on some hosting server do it ;-( I wrote scripts for Perl 5.6.1
and these run fine on many hosting servers on different Perl's. I never see
as many troubles as on this hosting.
>> print OUT "$var\n";
>> to this
>> print OUT $var, "\n";
>> then this work in both Perl versions.
>
> I *seriously* doubt this makes any difference... I think it's more
My thinks are the same. This must be the same if Perl is not buggy, or
server not fail randomly.
[...]
> What is STDERR open to?
I don't know ;-) Maybe is redirected somewhere to user error-log file, to
some parser script, really don't know.
I not redirect STDERR anywhere in my script except in SIGPIPE handler.
> What happens if you set $SIG{PIPE} to 'IGNORE' and check the return
> value of all your print statements?
This is impossible. I grab html code from web pages, parse it and store to
database. If I ignore SIGPIPE then I can store wrong data to database. I
must be sure that data are OK or exit from script.
> What happens if, instead of this, you install your SIGPIPE handler
> with POSIX::sigaction, which will bypass safe signals; something like
>
I did not know this, I will take a look to it. I'm trying to not use POSIX,
because many functions are not multiplatform and my scripts are running on
Linux and Windows servers too.
Thanks for your tips.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)