(formatting fixed so this is more readable)

[EMAIL PROTECTED] wrote:
> Hi,
> 
> I recently upgraded to Mandrake 8.0 (using the perl distrbution which is part
> of Mandrake 8.0) and found a strange problem:

>   perl -e '$x=1; print $x;'

> does NOT print anything. But

>   perl -e '$x=1; print $x,"\n";'

> and  

>   perl -e '$x=1, print $x; print "\n";'

> do work. On any other system I use (including Solaris, HP-UX, WinNT, Win2000)

>   perl -e '$x=1; print $x;'

> works properly. Did anybody else observe the same? Is there a solution
> to this problem?
> 
> Best  regards, Immo-Gert Birn

Hmm.  on a solaris box:

rcarruth@msfree> perl -v
 
This is perl, version 5.005_03 built for sun4-solaris
 
Copyright 1987-1999, Larry Wall
 
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
 
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
 
rcarruth@msfree> perl 
{ my $i = 1; print $i;}
1rcarruth@msfree> 


Note very carefully where the output went - do you see it?  its in my prompt.
'print' does NOT normally append a linefeed/cr pair unless you tell it to.

Now, on a linux Mandrake 7.2 box:

bash-2.04$ perl -v

This is perl, v5.6.0 built for i386-linux

Copyright 1987-2000, Larry Wall

Perl may be copied only...etc...

bash-2.04$  perl 
{ my $i = 1; print $i;}
bash-2.04$ 


Note that nothing printed.  This is incorrect, however I bet I can make it work:
bash-2.04$  perl 
{ $| = 1; my $i = 1; print $i;}
bash-2.04$ 

Hmm.  Looks like perl is closing the output before flushing it.

bash-2.04$  perl 
{ $| = 1; my $i = 1; print $i ,"\n";print $i , "          asdf";}
1
bash-2.04$ 

I'd say its a bug in something somewhere.  However, try this:

bash-2.04$  perl 
{ $| = 1; my $i = 1; print $i ,"\n";print $i , "          asdf";my $foo=<>;}
1
1          asdf ..I type here...
bash-2.04$ 

Yup, its a bug...  ;-)


Rusty Carruth          Email:     [EMAIL PROTECTED] or [EMAIL PROTECTED]
Voice: (480) 345-3621  SnailMail: Schlumberger ATE
FAX:   (480) 345-8793             7855 S. River Parkway, Suite 116
Ham: N7IKQ @ 146.82+,pl 162.2     Tempe, AZ 85284-1825
ICBM: 33 20' 44"N   111 53' 47"W

Reply via email to