[21866] in Perl-Users-Digest
Perl-Users Digest, Issue: 4070 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 6 03:06:27 2002
Date: Wed, 6 Nov 2002 00:05:11 -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 Wed, 6 Nov 2002 Volume: 10 Number: 4070
Today's topics:
Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: A vision for Parrot <adalke@mindspring.com>
Re: Any Experience with Embedded Perl/HTML? <nuba@turmalina.dcc.ufmg.br>
Re: Any Experience with Embedded Perl/HTML? <fxn@hashref.com>
Re: CGI Upload Problems (ebchang)
Re: CGI Upload Problems <dgardiner@houston.rr.com>
Re: Complex search/replace <goldbb2@earthlink.net>
Do scripts use the CPU while sleeping? (Hobo)
Re: Do scripts use the CPU while sleeping? <nospam@nospam.com>
Re: Do scripts use the CPU while sleeping? <goldbb2@earthlink.net>
Re: grep question <jurgenex@hotmail.com>
Re: Is it wrong to store method definitions in a databa (Bryan Castillo)
Perl as scripting language <sebbean@charter.net>
Re: Perl as scripting language <uri@stemsystems.com>
Re: Perl as scripting language <jurgenex@hotmail.com>
Re: Problem with Opening files and die <craig-and-linda@the-mcniels.com>
Re: Problem with Opening files and die <craig-and-linda@the-mcniels.com>
Re: Problem with Opening files and die <steven.smolinski@sympatico.ca>
Re: split() results limited to 32k length? <fxn@hashref.com>
Re: Telnet to OpenVMS, run cobol program - not working. <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Nov 2002 03:38:06 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aqa2oa$8o1$1@news.ox.ac.uk>
Benjamin Goldberg wrote:
> Frodo Morris wrote:
>
>>Daniel Pfeiffer wrote:
>>
>>>Hi,
>>>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 :-)
>>
>>I would have thought that a more platform-independent version of
>>this would be, say, a parrotd, which sits on top of the kernel,
>>intercepts calls to exec() bytecode and spawns the relevant processes.
>
>
> What advantage would this have over putting a #! line in the bytecode?
>
Faster, better, cheaper.
Imagine if parrot could understand all interpreted code. Why not leave
it running, so that any Perl/Python/Tcl/Ruby/Java/sh/BASIC/whatever code
can get to it immediately? A parrotd exec would consist of: "Run this."
"OK". A #! consists of "Does this file exist?" "Yes." "Does it
work?" "Yes." "OK, run this." "OK". I contend that a properly set up
parrotd *should* be faster than the equivalent "each language set up
separately" environment.
--
FM
------------------------------
Date: Wed, 06 Nov 2002 02:15:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DC8C177.8CC0164E@earthlink.net>
Frodo Morris wrote:
>
> Benjamin Goldberg wrote:
> > Frodo Morris wrote:
> >
> >>Daniel Pfeiffer wrote:
> >>
> >>>Hi,
> >>>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 :-)
> >>
> >>I would have thought that a more platform-independent version of
> >>this would be, say, a parrotd, which sits on top of the kernel,
> >>intercepts calls to exec() bytecode and spawns the relevant
> >>processes.
> >
> >
> > What advantage would this have over putting a #! line in the
> > bytecode?
> >
> Faster, better, cheaper.
> Imagine if parrot could understand all interpreted code.
It can't. Parrot can only understand parrot bytecode.
> Why not leave it running, so that any Perl/Python/Tcl/Ruby/Java/sh/
> BASIC/whatever code can get to it immediately?
Ignoring the problem of compiling those languages down to parrot
bytecode...
How should the kernel detect that a parrot-bytecode file is, in fact,
parrot bytecode?
For normal exe files, there's the execute bit and some standard headers.
For normal scripts, there's the execute bit and the #! line.
> A parrotd exec would consist of: "Run this." "OK".
> A #! consists of "Does this file exist?" "Yes." "Does it
> work?" "Yes." "OK, run this." "OK".
> I contend that a properly set up parrotd *should* be faster than the
> equivalent "each language set up separately" environment.
The speed hit of exec() is *not* the time it takes to check if the file
named on the #! line exists and has the executable bit set.... the speed
it is due to the time it takes to load that program into memory.
With that in mind, if you can special-case the kernel to pass scripts on
to special daemons, rather than loading up an interpreter for each
script, it will almost surely be faster, and not just for perl/parrot.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 06 Nov 2002 01:07:57 -0700
From: Andrew Dalke <adalke@mindspring.com>
Subject: Re: A vision for Parrot
Message-Id: <3DC8CDDD.7050103@mindspring.com>
Frodo Morris wrote:
> Benjamin Goldberg wrote:
...
>> What advantage would this have over putting a #! line in the bytecode?
>>
> Faster, better, cheaper.
> Imagine if parrot could understand all interpreted code. Why not leave
> it running, so that any Perl/Python/Tcl/Ruby/Java/sh/BASIC/whatever code
> can get to it immediately?
Some years back, RMS proposed a standard 'scripting' language called
Guile. See, various languages like Tcl, Perl, Python, etc. were
being developed and none of them were 1) developed under the FSF nor
2) a variation of Scheme. (A simplified and perhaps biased
interpretation of mine.)
A key part of his proposal was that Guile would support translators
from other languages, like Python, C, etc., to Guile.
It didn't happen. Writing those translators are hard because each
of the languages has different object models, which must be implemented
nearly perfectly. Guile is a full-fledge language built on years of
research into Lisp and scheme, so I would be surprised if it was any
easier to implement in Parrot's byte code. It didn't happen with
Guile, it's even less likely to happen with Parrot.
I can "imagine if parrot ..." But it isn't going to happen without
*huge* amounts of work; comparable to writing Jython. (A Python
implementation written on top of Java rather than C.)
On the other hand, consider the gcc suite of tools. These convert C,
C++, Pascal, Fortran, Objective C, ... into a more generic form. So
there is some known success in doing this. But I've looked at gcc
code and it isn't something I want to hack, while I've contributed code
to Python's C implementation.
Andrew
dalke@dalkescientific.com
------------------------------
Date: Wed, 6 Nov 2002 03:19:46 +0000 (UTC)
From: Nuba <nuba@turmalina.dcc.ufmg.br>
Subject: Re: Any Experience with Embedded Perl/HTML?
Message-Id: <aqa1oi$62e$1@dcc.ufmg.br>
darryl <dfdyck@yahoo.com> wrote:
: Template
Hi darryl
Did you mean Template Toolkit ?
Have been using it for months and I'm _very_ satisfied.
Many features. Very configurable. Good documentation there, too.
AFAIK, it's the templating system behind slashcode and many
other large projects.
I don't know about other templating systems, thought...
Let's wait for more followups on this thread :-)
All good things,
Nuba
--
,::::,
:: : Nuba Rodrigues Princigalli _____________
:. O-O: | '\\\\\\
: > Web Design and Development | ' ____|_
____\ - ._. Computational Mathematics | + '||::::::
/' \ -::' .' | '||_____|
/. ,- O < \ www.nuba.tk '________|_____|
(\ <' ' |\ / '-.___ nuba@dcc.ufmg.br ___/____|___\___
_.\__\________\_\___/), |\\____________________| _ ' <<<:|
|_________'___o_o|
------------------------------
Date: Wed, 6 Nov 2002 07:15:04 +0000 (UTC)
From: "F. Xavier Noria" <fxn@hashref.com>
Subject: Re: Any Experience with Embedded Perl/HTML?
Message-Id: <aqafho$ner$2@news.ya.com>
In article <da6cdb12.0211051605.6cb146be@posting.google.com>, darryl wrote:
> I'm currently using HERE documents for dynamic perl web pages and it's
> getting messy. I want to shift over to using an embedded perl solution
> but I can't decide which to use...does anybody have experience
> (positive or neg.) with the following:
>
> HTML::Template
> Template
> HTML::Mason
> HTML::Embperl
> Apache::ASP
Have a look at this comparative:
http://www.perl.com/pub/a/2001/08/21/templating.html
-- fxn
------------------------------
Date: Wed, 06 Nov 2002 02:47:45 GMT
From: echang@netstorm.net (ebchang)
Subject: Re: CGI Upload Problems
Message-Id: <Xns92BDDDCF66575echangnetstormnet@207.106.93.86>
"Josh Stedman" <stedman@siam.org> wrote in <HkTx9.20415$T_.502416
@iad-read.news.verio.net>:
>
>"ebchang" <echang@netstorm.net> wrote in message
>news:Xns92BCF1B602626echangnetstormnet@207.106.93.86...
>>
>> You didn't mention what you have on the client end - does the form
>> use enctype="multipart/form-data"? If you leave the default, the
>> form will submit, but the file will not be attached.
>>
>> EBC
>
>Yeah, I have multipart set on the form. I'm also using POST and not
GET.:
>
><FORM METHOD="POST" ENCTYPE="multipart/formdata">
>...
>......
> <INPUT type="file" name="file1" size="40"><BR>
> <INPUT type="SUBMIT" Value="Submit">
> <INPUT type="RESET" Value="Reset">
></FORM>
Look closely at what you wrote. It is not the enctype that I
indicated, and if used leads to the errors you reported.
--
EBC
------------------------------
Date: Wed, 06 Nov 2002 07:41:22 GMT
From: "Doug" <dgardiner@houston.rr.com>
Subject: Re: CGI Upload Problems
Message-Id: <CI3y9.281655$121.8252034@twister.austin.rr.com>
"ebchang" <echang@netstorm.net> wrote in message
news:Xns92BDDDCF66575echangnetstormnet@207.106.93.86...
> "Josh Stedman" <stedman@siam.org> wrote in <HkTx9.20415$T_.502416
> @iad-read.news.verio.net>:
>
> >
> >"ebchang" <echang@netstorm.net> wrote in message
> >news:Xns92BCF1B602626echangnetstormnet@207.106.93.86...
> >>
> >> You didn't mention what you have on the client end - does the form
> >> use enctype="multipart/form-data"? If you leave the default, the
> >> form will submit, but the file will not be attached.
> >>
> >> EBC
> >
> >Yeah, I have multipart set on the form. I'm also using POST and not
> GET.:
> >
> ><FORM METHOD="POST" ENCTYPE="multipart/formdata">
> >...
> >......
> > <INPUT type="file" name="file1" size="40"><BR>
> > <INPUT type="SUBMIT" Value="Submit">
> > <INPUT type="RESET" Value="Reset">
> ></FORM>
>
> Look closely at what you wrote. It is not the enctype that I
> indicated, and if used leads to the errors you reported.
>
> --
> EBC
Did I miss something, other than the lack of action tag calling the script,
or was it in the OP.
------------------------------
Date: Tue, 05 Nov 2002 22:08:47 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Complex search/replace
Message-Id: <3DC887BF.1AFFA273@earthlink.net>
H.Wiersema wrote:
[snip]
> I want to make a (sed|awk|perl) script that is able to grep (for
> example) the 'DEF' object create clause, then catch the
> 'tablespace'occurence of that clause. Then replace the tablespacename
> after 'tablespace' by another tablespacename.
[snip]
> Does anyone can give me a hint how to programm this in sed|awk|perl ?
How about:
#!/usr/local/bin/perl -i
# print all lines up to, and including the DEF table.
print, /^create table DEF$/ and last while <>;
# print all lines up to, but NOT including the tablespace.
(/^tablespace\s/ and last), print while <>;
# print the new tablespace.
print "tablespace NEWNAME\n";
# print the remaining lines.
print while <>;
__END__
[untested]
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 05 Nov 2002 21:30:58 -0800
From: myusenetclient@requiresthis.com (Hobo)
Subject: Do scripts use the CPU while sleeping?
Message-Id: <myusenetclient-0511022130580001@63-93-75-195.lsan.cwia.com>
I have a script I use to let visitors mail the URL to a friend with a
short message they include. Recently I have been seeing a lot of reports
about spammers hijacking formmail.pl and using it to send their own crap.
I don't want that to happen to me. One idea I have is to set the script
sleep for 60 seconds after each invocation in order to safeguard against
spamjacking. If the script will use up a lot of the cpu during this time
then I don't want to do it. Exactly how much cpu does a script use while
sleeping?
TIA
------------------------------
Date: Tue, 5 Nov 2002 22:13:43 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Do scripts use the CPU while sleeping?
Message-Id: <3dc8b281$1_1@nopics.sjc>
"Hobo" <myusenetclient@requiresthis.com> wrote in message
news:myusenetclient-0511022130580001@63-93-75-195.lsan.cwia.com...
> Exactly how much cpu does a script use while
> sleeping?
0%
------------------------------
Date: Wed, 06 Nov 2002 02:21:02 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Do scripts use the CPU while sleeping?
Message-Id: <3DC8C2DE.3A667C6D@earthlink.net>
Hobo wrote:
>
> I have a script I use to let visitors mail the URL to a friend with a
> short message they include. Recently I have been seeing a lot of
> reports about spammers hijacking formmail.pl and using it to send
> their own crap.
Indeed -- formmail.pl has some major security holes in it.
> I don't want that to happen to me.
Good! So, you're smart enough to switch from formmail.pl to something
safer, more secure?
> One idea I have is to set the script sleep for 60 seconds after each
> invocation in order to safeguard against spamjacking.
Sigh... apparently you are not.
> If the script will use up a lot of the cpu during this time then I
> don't want to do it. Exactly how much cpu does a script use while
> sleeping?
None -- but that doesn't matter, since an attacker can make multiple
connections to your web browser simultaneously, so you've got many
instances of your script running... the 60 second sleep has very little
effect at stopping spammers from taking advantage of it, except that it
will annoy legitimate users of your program, and if your machine is
attacked, it will use more resources on your computer.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 06 Nov 2002 03:36:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: grep question
Message-Id: <o70y9.29125$7W2.7837@nwrddc01.gnilink.net>
KTyson9426 wrote:
> I'm new to Perl, but I'm trying to write a program that will open 2
> different files, then read the invoice number of the first file,
> 'grep' the second file as it reads it and compare the invoice
> numbers. If the 'grep' matches the invoice numbers, then the 'print'
> writes out specific info from the 2 seperate files into 1 file.
>
[...]
> if (grep(/$Invoice/,$Invoice_Number)) {
[...]
Your code is too long and so poorly formatted, that it is too difficult to
really dig through it.
But at least here your grep call doesn't make sense (and according to the
subject this is what you are asking about). grep takes a list as the second
argument. It doesn't make much sense to use a scalar instead.
Nevertheless it will still work, sort of. But then you are throwing away the
result from grep (the list of matched elements) immediately.
Maybe you meant to simply do a compare ("eq", details see "perldoc perlop")
or a regular expression match ("m", details again see perldoc perlop) or a
substring match ("index", details see perldoc -f index)?
I can't tell from your code what you are after, but grep seems to be the
wrong function.
jue
------------------------------
Date: 5 Nov 2002 21:24:16 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Is it wrong to store method definitions in a database?
Message-Id: <1bff1830.0211052124.7c7d0896@posting.google.com>
Phil Brodd wrote:
<snip>
> My project is a system that downloads and parses the contents of
> various web pages, each on its own collection schedule. A Perl cron
> job checks a DB table to see if any pages are to be collected at that
> time, creating a Collector object for each one. For each Collector
> object, methods are invoked to download the page, parse its contents,
> and insert the results in another DB table.
>
> Here's where I'm not sure how to proceed. The Collector objects will
> differ in the URLs they access and the parsing routines they use. I
> can think of two approaches:
>
> 1) Store the URLs and the parsing routines in the database and
> instantiate Collectors from there. I'm not sure how I would go about
> defining a class whose methods are taken from a db, though.
>
> 2) Use inheritance. Create an abstract Collector class, and subclass
> it for each page to be collected. This seems more natural, but if I
> do it this way, how will my script know what kind of object to create?
>
<snip>
[Here is suggestion along the lines of option 2]
Think about the code posted below. I think the framework/style
would work well for your problem. You would use the
Collector::new function to create an object of the class name
you specify as a string. The Collector class will make sure
the module is required (loaded). You overide initialize for
class specific initialization. Any extra arguments to
Collector::new are passed to the initialize method. Now use the
abstract interface to Collector to do all of your work.
Perhaps you would have a table like so:
- From this table you pass the class, the url, then the args
split by ';'
(perhaps your anal though and want to make a table for args.)
CollectorTable -----------< ArgsTable
[ who likes normalization though? ]
+------------------------------------------------------------+
| url | class | args |
+-----------------------+-----------------+------------------+
| http://www.yahoo.com | YahooCollector | follow;1;depth;3 |
+-----------------------+-----------------+------------------+
| http://www.google.com | GoogleCollector | |
+-----------------------+-----------------+------------------+
You were worried about having to load all the modules possible
anytime you run. That will not be true of this design, because
the modules are required through eval.
**Note this smells like a design pattern (factory?) I think
there is request for documentation on perl design patterns
somewhere?
(I thought java invented design patterns or was that al gore?)**
[File: Collector.pm]
package Collector;
use strict;
use warnings;
sub new {
my $class = shift;
eval("require $class"); # force loading of class
die $@ if ($@);
my $self = {};
bless $self, $class;
$self->initialize(@_);
return $self;
}
sub initialize {}
sub parse { die "You need to overide this!\n"; }
return 1;
[File: GoogleCollector.pm]
package GoogleCollector;
use strict;
use warnings;
use Collector;
use vars qw/@ISA/;
@ISA = qw/Collector/;
sub initialize {
my $self = shift;
my %args = @_;
if ($args{follow}) {
print "You want me to follow links?\n";
}
}
sub parse {
my $self = shift;
print "I will parse google!\n";
}
return 1;
[File: YahooCollector.pm]
package YahooCollector;
use strict;
use warnings;
use Collector;
use vars qw/@ISA/;
@ISA = qw/Collector/;
sub initialize {
my $self = shift;
print "In init for yahoo!\n";
}
sub parse {
my $self = shift;
print "I will parse yahoo!\n";
}
return 1;
[File: test.pl]
use Collector;
use strict;
use warnings;
my $collector;
$collector = Collector::new('YahooCollector');
print "\$collector = $collector\n";
$collector->parse;
print "\n";
$collector = Collector::new('GoogleCollector', follow => 1);
print "\$collector = $collector\n";
$collector->parse;
[Output of test]
$ perl test.pl
In init for yahoo!
$collector = YahooCollector=HASH(0x177f130)
I will parse yahoo!
You want me to follow links?
$collector = GoogleCollector=HASH(0x17752c4)
I will parse google!
------------------------------
Date: Wed, 6 Nov 2002 00:18:17 -0600
From: "Seb Bean" <sebbean@charter.net>
Subject: Perl as scripting language
Message-Id: <ushd1nsh8iasa3@corp.supernews.com>
i've never used perl but i'm going to start soon
i was just wondering...does perl have to be compiled or can it run by itself
------------------------------
Date: Wed, 06 Nov 2002 06:27:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl as scripting language
Message-Id: <x71y5zi570.fsf@mail.sysarch.com>
>>>>> "SB" == Seb Bean <sebbean@charter.net> writes:
SB> i've never used perl but i'm going to start soon i was just
SB> wondering...does perl have to be compiled or can it run by itself
yes.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 06 Nov 2002 07:18:19 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl as scripting language
Message-Id: <%m3y9.25071$t1.23647@nwrddc02.gnilink.net>
Seb Bean wrote:
> i was just wondering...does perl have to be compiled or can it run by
> itself
Ahhh, well, let's see:
- perl -in all lower case- refers to the Perl interpreter as such. Yes, you
need to compile the interpreter for your platform or install a pre-compiled
version.
However, something tells me this is not what you meant to ask.
Perl is an interpreted language and the interpreter contains a compilation
phase.
Without knowing more about why you are asking this question I think it's
impossible to give a good answer. What is your real question, i.e what do
you mean by "can it run by itself"?
jue
------------------------------
Date: Tue, 5 Nov 2002 20:10:45 -0600
From: "Craig McNiel" <craig-and-linda@the-mcniels.com>
Subject: Re: Problem with Opening files and die
Message-Id: <aq9tk5$1vt$1@ins22.netins.net>
Thanks all for the rapid response. On my prior versions of perl 5.6.1 and
5.005 it did work as described and now it doesn't. I don't have a problem
fixing this now that I know the old behavior was errant.
Thanks,
Craig
"Andreas Kähäri" <ak@freeshell.org.REMOVE> wrote in message
news:slrnasgtba.ku2.ak@otaku.freeshell.org...
> Submitted by "Craig McNiel" to comp.lang.perl.misc:
> > I have just compiled Perl 5.8 on an AIX 4.3.3 box with gcc 3.02. Now
the
> > following code will no longer die if the file open actually does fail
for
> > some reason.
> >
> > open MYHANDLE, "filethatdoesntexist" || die $! ;
> >
> > however
> >
> > open (MYHANDLE, "filethatdoesntexist") || die $! ;
> >
> > does produce the desired error message and termination of the script. I
> > have a lot of scripts that use the preceding syntax and will no longer
catch
> > a bad file open operation. I don't get any warnings or errors using
either
> > syntax so I'm at a loss as to if this is a bug or how to fix the perl
> > compiler. Any suggestions are welcome.
> >
> > Thanks,
> > Craig
> >
> >
>
> From the perlop manual:
>
> The precedence of "and" and "or" is much lower, however,
> so that you can safely use them after a list operator
> without the need for parentheses:
>
> unlink "alpha", "beta", "gamma" or gripe(), next LINE;
>
> With the C-style operators that would have been written like
> this:
>
> unlink("alpha", "beta", "gamma") || (gripe(), next LINE);
>
> --
> Andreas Kähäri --==::{ Have a Unix: netbsd.org
> --==::{ This post ends with :wq
------------------------------
Date: Tue, 5 Nov 2002 20:14:24 -0600
From: "Craig McNiel" <craig-and-linda@the-mcniels.com>
Subject: Re: Problem with Opening files and die
Message-Id: <aq9tra$sua$1@ins22.netins.net>
Actually I tried it again on the system at work and it never did work on the
opens. I had other statements the did
|| die $!
that worked but, the opens were never tried against bad file names.
Thanks again for the clarification !
- Craig
"Andreas Kähäri" <ak@freeshell.org.REMOVE> wrote in message
news:slrnasgtba.ku2.ak@otaku.freeshell.org...
> Submitted by "Craig McNiel" to comp.lang.perl.misc:
> > I have just compiled Perl 5.8 on an AIX 4.3.3 box with gcc 3.02. Now
the
> > following code will no longer die if the file open actually does fail
for
> > some reason.
> >
> > open MYHANDLE, "filethatdoesntexist" || die $! ;
> >
> > however
> >
> > open (MYHANDLE, "filethatdoesntexist") || die $! ;
> >
> > does produce the desired error message and termination of the script. I
> > have a lot of scripts that use the preceding syntax and will no longer
catch
> > a bad file open operation. I don't get any warnings or errors using
either
> > syntax so I'm at a loss as to if this is a bug or how to fix the perl
> > compiler. Any suggestions are welcome.
> >
> > Thanks,
> > Craig
> >
> >
>
> From the perlop manual:
>
> The precedence of "and" and "or" is much lower, however,
> so that you can safely use them after a list operator
> without the need for parentheses:
>
> unlink "alpha", "beta", "gamma" or gripe(), next LINE;
>
> With the C-style operators that would have been written like
> this:
>
> unlink("alpha", "beta", "gamma") || (gripe(), next LINE);
>
> --
> Andreas Kähäri --==::{ Have a Unix: netbsd.org
> --==::{ This post ends with :wq
------------------------------
Date: Wed, 06 Nov 2002 03:15:12 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: Problem with Opening files and die
Message-Id: <4P%x9.5311$3e2.922302@news20.bellglobal.com>
Craig McNiel <craig-and-linda@the-mcniels.com> wrote:
> Thanks all for the rapid response. On my prior versions of perl 5.6.1
> and 5.005 it did work as described and now it doesn't. I don't have a
> problem fixing this now that I know the old behavior was errant.
That code (i.e., open X, $file || die) didn't work on my 5.6.x
installations or my 5.005 ones. The || operator has had higher
precedence than comma for some time. In fact, the 2nd Camel uses the
'or' operator instead of '||' with opens for the same reason.
I wonder if the || operator *ever* had lower precendence than comma.
Anyone know?
Steve
--
Steven Smolinski => http://arbiter.ca/
GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
=> or email me with 'auto-key' in the subject.
Key Fingerprint => 08C8 6481 3A7B 2A1C 7C26 A5FC 1A1B 66AB F637 495D
------------------------------
Date: Wed, 6 Nov 2002 07:05:53 +0000 (UTC)
From: "F. Xavier Noria" <fxn@hashref.com>
Subject: Re: split() results limited to 32k length?
Message-Id: <aqaf0h$ner$1@news.ya.com>
> - - - - cut here - - -
> $chunk = " " x (37 * 1024);
>
> for (1..37) {
> ~ $data .= $chunk . "x";
> ~ }
>
> print "Data is ", length($data), " bytes long\n";
>
> print "Data has ", scalar split(/x/, $data), " chunks of ",
> length((split(/x/, $data))[0]), " bytes each\n";
> - - - - cut here - - -
That code, once deleted those two "~", gives
Data is 1401893 bytes long
Data has 37 chunks of 37888 bytes each
both with perl 5.6.1 and perl 5.8.0 under GNU/Linux.
-- fxn
------------------------------
Date: Wed, 06 Nov 2002 03:45:30 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Telnet to OpenVMS, run cobol program - not working.
Message-Id: <3DC8903E.1090809@rochester.rr.com>
Joseph Norris wrote:
> 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
...
> $t->waitfor("PRINT ALL CLASSES? (DEFAULT ALL CLASSES)(Y/N)");
Hmmmm...according to the docs, the single-string-argument waitfor is
expecting a "matchop". That includes delimiters. So perhaps:
$t->waitfor('/PRINT ALL CLASSES? (DEFAULT ALL CLASSES)(Y\/N)/');
or maybe
$t->waitfor('|PRINT ALL CLASSES? (DEFAULT ALL CLASSES)(Y/N)|');
might work better? BTW, ' is recommended for quoting strings for
matchops because of the hassles involved with some pattern
metacharacters (like $) when dealing with " quotes. Quoting stuff in
matchops gets a bit tricky. Perhaps you should just go for the string
match, since you don't really need the regex match for what you are doing.
...
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
Cobol, apparently.
...
--
Bob Walton
------------------------------
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 4070
***************************************