[21861] in Perl-Users-Digest
Perl-Users Digest, Issue: 4065 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 4 18:10:48 2002
Date: Mon, 4 Nov 2002 15:05:08 -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 Mon, 4 Nov 2002 Volume: 10 Number: 4065
Today's topics:
Re: "Premature end of script headers" error message <flavell@mail.cern.ch>
A vision for Parrot <occitan@esperanto.org>
Re: A vision for Parrot (Cameron Laird)
Re: A vision for Parrot <simon@simon-cozens.org>
CGI Upload Problems <stedman@siam.org>
Re: Checking AFS tokens <goldbb2@earthlink.net>
Re: Flash sendXML with CGI <nobody@dev.null>
Re: Flash sendXML with CGI <nobody@dev.null>
Re: how can I cause select->can_write to be false ? <goldbb2@earthlink.net>
interacting with processes that diddle with tty <what_do_i_do@nothotmail.org>
Re: Net::Telnet - is there a way to ignore a connection <nospam@nospam.org>
Re: Perl and large text files <nobody@dev.null>
Re: Perl and large text files <goldbb2@earthlink.net>
perl nslookup (filip)
Re: perl nslookup <goldbb2@earthlink.net>
Telnet to OpenVMS, run cobol program - not working. <jozefn@newbolt.sonic.net>
||= |= <cyberjeff@sprintmail.com>
Re: ||= |= <kurzhalsflasche@netscape.net>
Re: ||= |= <tassilo.parseval@post.rwth-aachen.de>
Re: ||= |= <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 4 Nov 2002 20:16:22 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: "Premature end of script headers" error message
Message-Id: <Pine.LNX.4.40.0211041955230.29666-100000@lxplus072.cern.ch>
On Nov 4, Albert inscribed on the eternal scroll:
> I try to start a perl script by executing it via the address bar of
> Internet Explorer. It is located on Apache Server with Linux.
This seems to be what's known around here as a "stealth CGI question".
> By the way, what is the "script header"?
< http://www.perldoc.com/perl5.8.0/pod/perlfaq9.html
#What-is-the-correct-form-of-response-from-a-CGI-script- >
> It would be nice if you could help me.
It's recommended that you familiarise yourself with the FAQs that
relate to your problem. This is considered common courtesy on Usenet
groups. Start with the posting guidelines which appear here
regularly, and follow-up the relevant references from there. There is
a version of the FAQs on every complete Perl installation, although in
respect of FAQ part 9 I would recommend looking at the version in
5.8.0 (see web reference above) if you're stuck with an earlier
version of Perl.
------------------------------
Date: Tue, 5 Nov 2002 22:10:04 +0100
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: A vision for Parrot
Message-Id: <20021105221004.339206f3.occitan@esperanto.org>
Hi,
this morning it struck me that it would be nice to have Parrot not only run Perl 6 and similar byte code, but that any of the common interpreted languages be compiled to this same byte code.
Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe even bash script the same interpreter library would be used. Then likely it would already be in memory speeding up start time.
And this would also ease cross language module/library inclusion. Imagine instantiating some Python class from Perl!
Apache would essentially have a mod_parrot. Maybe, if this can be tested very hard, we'd even have a Parrot kernel module for all Unices supporting that. Then exec() could perform compiled scripts right away, like machine code :-)
coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer
--
-- http://dapfy.bei.t-online.de/make.pl/
--
------------------------------
Date: Mon, 04 Nov 2002 21:35:57 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: A vision for Parrot
Message-Id: <usdq1tapaekk87@corp.supernews.com>
In article <20021105221004.339206f3.occitan@esperanto.org>,
Daniel Pfeiffer <occitan@esperanto.org> wrote:
>Hi,
>
>this morning it struck me that it would be nice to have Parrot not only
>run Perl 6 and similar byte code, but that any of the common interpreted
>languages be compiled to this same byte code.
>
>Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe even
>bash script the same interpreter library would be used. Then likely it
>would already be in memory speeding up start time.
>
>And this would also ease cross language module/library inclusion.
>Imagine instantiating some Python class from Perl!
>
>Apache would essentially have a mod_parrot. Maybe, if this can be
>tested very hard, we'd even have a Parrot kernel module for all Unices
>supporting that. Then exec() could perform compiled scripts right away,
>like machine code :-)
.
.
.
This thought inspired enthusiasm in others long ago--from
before it was named "Parrot", at least.
Availability of all the pieces your vision requires is at
least several years away, barring miracles. I don't par-
ticularly expect it to happen.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
------------------------------
Date: 04 Nov 2002 22:14:54 +0000
From: Simon Cozens <simon@simon-cozens.org>
Subject: Re: A vision for Parrot
Message-Id: <87vg3dt21t.fsf@simoncozens-2.dsl.easynet.co.uk>
claird@lairds.com (Cameron Laird) writes:
> >this morning it struck me that it would be nice to have Parrot not only
> >run Perl 6 and similar byte code, but that any of the common interpreted
> >languages be compiled to this same byte code.
> >
> >Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe even
> >bash script the same interpreter library would be used. Then likely it
> >would already be in memory speeding up start time.
> .
> This thought inspired enthusiasm in others long ago--from
> before it was named "Parrot", at least.
Particularly myself; in fact, it was named Parrot precisely to represent its
language-agnosticism.
The thought is also behind why I wrote the Python::Bytecode module, why I
learnt Ruby, and why I've been asking interesting questions about access to
the Ruby AST.
I don't think the reality is as far away as you imply.
--
The problem with big-fish-little-pond situations is that you
have to put up with all these fscking minnows everywhere.
-- Rich Lafferty
------------------------------
Date: Mon, 4 Nov 2002 17:55:31 -0500
From: "Josh Stedman" <stedman@siam.org>
Subject: CGI Upload Problems
Message-Id: <sPCx9.20391$T_.500864@iad-read.news.verio.net>
I've been really stumped on this for a while now, and have scoured the Google Groups archives, with
no help.
I've got a CGI script that I want to use to (among other things, which already work) upload a few
files. As of now, I'm trying to settle with one file. But I can't get the file to save on the
server or even print out to the screen.
I'm running on a Windows server - think it's .NET, unfortunately, but I don't maintain the
machine -- with IIS 5
My upload subfunction looks like this:
----------------BEGIN CODE----------------
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
------------------------
sub uploadfiles {
my $subpath = param('username')."/".$TimeStamp; # path for files after the main DL path -- uses
the username submitted
$subpath =~ s!\s!\_!g; # takes out any spaces that may have been in the username,
replaces with _ for good measure
my $file = param('file1');
$basename = GetFileName($file);
#my $mime = uploadInfo($file)->{'Content-Type'};
print "<BR><BR>File contents: <BR><BR><TT>";
while (<$file>){
print;
}
print "</TT><BR><BR> End of File <BR><BR>";
open (STORAGE, ">>$UploadPath/$subpath/$basename") or die "Error: File $basename Upload: $!\n";
print STORAGE "This is just a test" or die "Can't write to the file because of $!\n";
# if($mime !~ /text/){
# binmode ($file);
# binmode (STORAGE);
# }
while(read($file, $data, 1024)){
print STORAGE $data or die "Can't write to the file because of $!\n";
}
close STORAGE;
}
----------------END CODE----------------
You may notice the mime data section removed. I was getting an error about using a blank hash
reference, so I'm settling for ASCII data for the moment, but I suspect this has a lot to do with
the same problem.
All I get returned is nothing for the print, and a file created coreectly with only the test text in
it. Most of the code is based from "Writing CGI Applications with Perl" by Kevin Meltzer and Brent
Michalski.
I've printed out the $file variable, and it returns the correct path to the file on my machine
I also tried this with my $file = upload('file1'), to no avail.
Anyone see what my problem(s) is(are) here?
------------------------------
Date: Mon, 04 Nov 2002 16:21:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Checking AFS tokens
Message-Id: <3DC6E4BF.387AAD04@earthlink.net>
Abernathey Family wrote:
>
> I'm looking for a better way to check for afs permission. Currently I
> issue `tokens` and then parse the results for the cells of interest.
> I'm wondering if there is a better way.
use AFS; # from CPAN
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 04 Nov 2002 21:00:54 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Flash sendXML with CGI
Message-Id: <3DC6DFFC.2010305@dev.null>
Robert Robbins wrote:
> Hello Perl Programmers,
>
> I am trying to write a Perl script that reads the XML sent by
> Flash using its XML.send method. The XML.send uses the
> content type text/xml and sends the data using POST. I've
> tried the CGI.pm and cgi-lib.pl. The cgi-lib.pl script won't
> work with this content type and the CGI.pm does not provide
> a method for getting the raw post data. I tried $q->param('raw')
> but this did not work. An ASP script can successfully
> get the XML using:
>
> Response.BinaryWrite Request.BinaryRead(Request.TotalBytes)
>
> And PHP has the $GLOBALS["HTTP_RAW_POST_DATA"]
> global variable. I need to do this in Perl.
>
> Robert Robbins
I have no Flash, so I may be way off base, but a simple script like
#!/usr/bin/perl -w
use strict;
use CGI;
my $message=<STDIN>;
my $q=new CGI;
print $q->header();
print $message;
will parrot back everything you have sent to it via the POST method.
I hope that helps.
------------------------------
Date: Mon, 04 Nov 2002 21:15:20 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Flash sendXML with CGI
Message-Id: <3DC6E35F.6080809@dev.null>
Andras Malatinszky wrote:
>
>
> Robert Robbins wrote:
>
>> Hello Perl Programmers,
>>
>> I am trying to write a Perl script that reads the XML sent by
>> Flash using its XML.send method. The XML.send uses the
>> content type text/xml and sends the data using POST. I've
>> tried the CGI.pm and cgi-lib.pl. The cgi-lib.pl script won't
>> work with this content type and the CGI.pm does not provide
>> a method for getting the raw post data. I tried $q->param('raw')
>> but this did not work. An ASP script can successfully
>> get the XML using:
>>
>> Response.BinaryWrite Request.BinaryRead(Request.TotalBytes)
>>
>> And PHP has the $GLOBALS["HTTP_RAW_POST_DATA"]
>> global variable. I need to do this in Perl.
>>
>> Robert Robbins
>
>
>
> I have no Flash, so I may be way off base, but a simple script like
>
> #!/usr/bin/perl -w
> use strict;
> use CGI;
> my $message=<STDIN>;
> my $q=new CGI;
> print $q->header();
> print $message;
>
> will parrot back everything you have sent to it via the POST method.
>
> I hope that helps.
>
>
>
OK, maybe we should have @message instead of $message in both instances...
Like I said, this is untested.
------------------------------
Date: Mon, 04 Nov 2002 16:16:19 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how can I cause select->can_write to be false ?
Message-Id: <3DC6E3A3.68CC4E45@earthlink.net>
Eran Amzallag wrote:
[snip]
> I would like to be able to control [the client's can_write] result
> from the select command by create a state or set an option telling all
> my clients that it is unable (or able) to send me msgs threw the
> connection.
[snip]
Instead of trying to manipulate the 'writability' state of the client's
tcp socket, simply send to a client a message which tells them to stop
writing.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 04 Nov 2002 15:35:44 -0500
From: Dan Becker <what_do_i_do@nothotmail.org>
Subject: interacting with processes that diddle with tty
Message-Id: <3DC6DA20.4424684C@nothotmail.org>
I'm trying to write a perl script that interfaces with a 3rd party interactive
application on solaris using IPC::Open2, where that application apparently does
things like tcgetattr and tcsetattr. When I execute the application manually
from an xterm, it works the way I expect: I can issue commands to and get
responses from the application on the xterm. when I try to start that same
application from inside perl using open2, I get errors like:
tcgetattr() get options failed: Invalid argument
tcsetattr(TCSANOW) set options failed: Invalid argument
so the application is actually starting, and I'm seeing some data, but it is not
seeing the tty device it is expecting, and failing on tcsetattr. I've been
trying to look at IO::Pty, but cant quite figure if that is a solution, or how
to connect things together. any suggestions?
this is the kind of perl script (simplified) I'm trying. I'm stuck with
perl 5.005_03.
--------------------
#!/usr/bin/perl -w
use strict;
use IPC::Open2;
use Symbol;
my $WTR = gensym();
my $RDR = gensym();
open2($RDR, $WTR, '/omp/itbin/ITcftvtty') or die "could not start appl: $!\n";
while(<$RDR>) {
print;
last if(/IN SERVICE/);
}
print $WTR "do_this_command args\n";
while(<$RDR>) {
print;
last if(/DONE/);
}
print "done\n";
------------------------
the output I'm seeing is:
$ ./t.pl
Warning: tcgetattr() get options failed: Invalid argument
Connection established.
IN SERVICE
improperly terminated input
EOF ENCOUNTERED
Connection closed.
tcsetattr(TCSANOW) set options failed: Invalid argument
done
$
--
Dan Becker
what_do_i_do@nothotmail.org
------------------------------
Date: Mon, 4 Nov 2002 15:23:18 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: Net::Telnet - is there a way to ignore a connection that timed out?
Message-Id: <aq6kvm$r34@nrn2.NRCan.gc.ca>
"Christian Caron" <nospam@nospam.org> wrote in message
news:apuate$mi313@nrn2.NRCan.gc.ca...
>
> But, if the other computer is turned off, then the Telnet connection times
> out and the script ends (my webserver returns a 500 Server Error). My
> question is: is it possible to tell the script to continue _anyway_ and
> print an empty variable instead of stopping?
>
> I tried things like:
>
> if ($t) {
> do;
> }
> else {
> do empty;
> }
for future references, I found out:
my $ok = $t->open( Host => $hostname,
Port => 23);
if ($ok) {
do;
}
else {
do something else;
}
------------------------------
Date: Mon, 04 Nov 2002 20:11:31 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Perl and large text files
Message-Id: <3DC6D46B.1090704@dev.null>
Jürgen Exner wrote:
> JorkkiS wrote:
>
>>I'm supposed to write a sript that searches through a text file for a
>>given string. The script it self will be very simple, but I was
>>wondering will I run into problems, because the size of the text file
>>is around 5 megabytes.
>>
>
> 5 MB is really not that much (unless you are still running on a 486 with 8MB
> of RAM, of course).
>
>
>>I was thinking of reading it into an array and
>>then greping throug it... will there be problems, other than it might
>>take a while.
>>
>
> On a non-antic computer no problem, but see below
>
>
>>Is there a better way to approach this?
>>
>
> Sure. Read the file line by line.
> while (<>) {
> # do whatever you need to with the current line
> }
>
> jue
Here's another potential problem, both with Juergen's and Jarkko's methods;
Suppose you are looking for the string "green eggs and ham" and it
occurs in your file across a line break, like this:
can you, will you eat green
eggs and ham
Maybe the string is guaranteed to occur between two line breaks, but if
not, neither looping through the file line by line nor forcing it into
an array will work in finding it.
------------------------------
Date: Mon, 04 Nov 2002 16:30:25 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl and large text files
Message-Id: <3DC6E6F1.BFBDD78@earthlink.net>
JorkkiS wrote:
>
> Hi!
>
> I'm supposed to write a sript that searches through a text file for a
> given string. The script it self will be very simple, but I was
> wondering will I run into problems, because the size of the text file
> is around 5 megabytes.
> I was thinking of reading it into an array and then greping throug
> it... will there be problems, other than it might take a while.
>
> Is there a better way to approach this?
Read in a little at a time, instead of a lot at a time. Eg:
open( my($fh), "<", $filename )
or die "Couldn't open $filename: $!";
my $b = "";
while( read $fh, $b, 8192, length $b ) {
if( index( $b, $string ) != -1 ) {
print "Found it!\n";
close $fh;
last;
} elsif( length $b >= length $string ) {
$b = substr( $b, 1-length $string );
}
}
print "Didn't find it!\n" if not defined fileno $fh;
[untested]
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 4 Nov 2002 12:11:52 -0800
From: filip.vandenabeele@pandora.be (filip)
Subject: perl nslookup
Message-Id: <6f1e47f8.0211041211.2ee82df7@posting.google.com>
dear all,
I have a problem with my Perl script.
In my script, I use the unix nslookup commando's.
I do a host lookup to a known dns server but the problem is when the
known dns server does not answer. My script just waits and waits.
If I specify a timeout in the nslookup -timeout=10 nothing happens...
I do not know how to solve this problem.
------------------------------
Date: Mon, 04 Nov 2002 15:45:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl nslookup
Message-Id: <3DC6DC75.B88621D5@earthlink.net>
filip wrote:
>
> dear all,
>
> I have a problem with my Perl script.
>
> In my script, I use the unix nslookup commando's.
> I do a host lookup to a known dns server but the problem is when the
> known dns server does not answer. My script just waits and waits.
> If I specify a timeout in the nslookup -timeout=10 nothing happens...
>
> I do not know how to solve this problem.
There are a number of solution.
One is to open a pipe from the nslookup command, and use
select/IO::Select to read data while doing a timeout -- if it does time
out, remember to use kill() on the pid returned by open(), before
closing the filehandle.
Another is to use the bgsend method of Net::DNS::Resolver, do the
timeout using select/IO::Select on the sockethandle it gives you.
Another is to use backticks or qx or readpipe to get the data from
nslookup, and to use alarm() to time it out.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 04 Nov 2002 21:40:07 GMT
From: Joseph Norris <jozefn@newbolt.sonic.net>
Subject: Telnet to OpenVMS, run cobol program - not working.
Message-Id: <Pine.LNX.4.40.0211041332040.14618-100000@newbolt.sonic.net>
Group,
Here is my problem.
I am using Net::Telnet to telnet into a OpenVms box and run a cobol
program. I have set the script up as below:
The problem is that the displays from the cobol program do not show
up and so my waitfor's do not make it and the script dies.
The last entry in the log file just shows the name of the cobol program
Any and all help would be appreciated - need to get this to run.
use Net::Telnet ();
$username = 'dpsub_1';
$passwd = 'some_pass';
$filename = 'telnet.log';
unlink $filename;
$t = new Net::Telnet (Timeout => 60);
$fh = $t->dump_log;
$fh = $t->dump_log($fh);
$fh = $t->dump_log($filename);
print "dump set\n";
$t->open("machine.ip.kept.secret");
print "at open\n";
$t->login(Name=>$username, Password=>$passwd, Prompt=>'/\$/');
print "at dir cmd\n";
$t->print("run cls02l.exe");
$t->waitfor("PRINT ALL CLASSES? (DEFAULT ALL CLASSES)(Y/N)");
$t->print("N");
$t->waitfor("ENTER SECTIONS (MAX. 100)");
$t->print("127");
@lines = $t->getlines;
$t->print("logout");
$t->close;
my $cnt = 0;
for (@lines){
$cnt++;
print "$cnt: $_\n";
}
exit(0);
#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
------------------------------
Date: Mon, 04 Nov 2002 21:57:52 GMT
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: ||= |=
Message-Id: <3DC6EDE2.AE40CFFE@sprintmail.com>
I'd like to replace code like this:
if(!$some_var){$some_var='default value';}
I'm confused about the useage of |= and ||= and perldoc and the camel
book expect me to fall back on my skimpy knowledge of C.
What's the right why to assign defaults?
Jeff
------------------------------
Date: Mon, 04 Nov 2002 23:11:32 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: ||= |=
Message-Id: <3DC6F094.70803@netscape.net>
Jeff Thies announced:
> I'd like to replace code like this:
>
> if(!$some_var){$some_var='default value';}
>
> I'm confused about the useage of |= and ||= and perldoc and the camel
> book expect me to fall back on my skimpy knowledge of C.
>
> What's the right why to assign defaults?
>
> Jeff
Hello Jeff,
want you want is probably
$some_var ||= 'default value';
Anyway,
$some_var = 'default value' unless ($some_var);
is might be easier to understand.
HTH,
Dominik
------------------------------
Date: 4 Nov 2002 22:13:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: ||= |=
Message-Id: <aq6rdq$6ke$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Jeff Thies:
> I'd like to replace code like this:
>
> if(!$some_var){$some_var='default value';}
>
> I'm confused about the useage of |= and ||= and perldoc and the camel
> book expect me to fall back on my skimpy knowledge of C.
One is the logical or (||) while the other one is the bitwise or (|),
just as in C.
> What's the right why to assign defaults?
Use the logical or:
$some_var ||= 'default value';
Note that since Perl also treats the empty string, "0" and 0 as false,
these values will get overridden. If you don't want that, you have to
explicitely test for definedness. There wont be an operator for that
before perl5.9.0:
$some_var = 'default value' if ! defined $some_var;
Btw:
$var |= 1;
is equivalent to
$var = $var | 1;
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Mon, 04 Nov 2002 22:44:54 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: ||= |=
Message-Id: <gstdsuck7vdqj99p5qe9lq4e2frvtr5k3d@4ax.com>
Jeff Thies wrote:
> I'd like to replace code like this:
>
> if(!$some_var){$some_var='default value';}
>
>I'm confused about the useage of |= and ||= and perldoc and the camel
>book expect me to fall back on my skimpy knowledge of C.
The difference between |= and ||= is the same as the difference between
| and ||. | is for bitwise or, || is for logical or.
print 2 | 4;
sets bits 1 and 2 in the result -> 6
print 2 || 4;
Takes the LHS, 2, and only if that is not true, it will continue with
the RHS. It is true, so the result is 2. The RHS is ignored.
print 0 || 4;
Here the LHS is false, so the RHS is evaluated, and its value returned.
So: result is 4.
>What's the right why to assign defaults?
||=
--
Bart.
------------------------------
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:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
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 V10 Issue 4065
***************************************