[16224] in Perl-Users-Digest
Perl-Users Digest, Issue: 3636 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 11:23:00 2000
Date: Wed, 12 Jul 2000 08:15:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963414923-v9-i3636@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 12 Jul 2000 Volume: 9 Number: 3636
Today's topics:
Re: Reading lines of a file within a loop? <uackermann@orga.com>
Re: Reading lines of a file within a loop? (Bernard El-Hagin)
Re: Reading lines of a file within a loop? (Tad McClellan)
Re: Regex Never satisfied <john@nomailplease>
Re: Regex Never satisfied (Bernard El-Hagin)
Re: running system command as root from perl kmhanser@my-deja.com
Re: Sorting a tab separated table ? <W.Hielscher@mssys.com>
Re: sorting issue <iltzu@sci.invalid>
sub selects brainmuffin@excite.com
Re: sub selects <kjetilskotheim@iname.com>
Re: syntax error in cgi script under IIS causes downloa <flavell@mail.cern.ch>
Re: Unique Items (Tad McClellan)
Re: using @_ with subs (Just a quickie from a Perl Wann <the.pirla@NOSPAM.flashnet.it>
Re: using @_ with subs (Just a quickie from a Perl Wann <care227@attglobal.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Jul 2000 14:33:58 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: Reading lines of a file within a loop?
Message-Id: <396C65B6.7CE744BE@orga.com>
John Casey wrote:
>
> Hi,
>
> I need to write a script to scan a XML file for the lines containing the search
> pattern "GEEQualify" . The line would be typically like this, (with the values
> of the variables being different for different lines):
>
> <GEEQualify Length="9.979" DCode="A6" Speed="970"/>
>
> Then, when this line is found, it has the to check the value of
> the "Speed" variable (eg: Speed="970" here) in the line. If it is above 500,
> the script has to proceed to do the following (otherwise it has to continue
> the search for the remaining of the file ); Scan the next two
> lines which would be as follows:
> ******
> <NUM>86756</NUM>
> <Info Available="Y" Name="Jackie" GEEAvailable="Fri Jun 21, 2000 00:00:00 EDT"
> LateC="128"/>
> ******
> It has to take the numeric value (86756 here) between the <NUM> tags
> and the alphabetic value of the 'Available' variable (Y here)
> and print them out in a new file with the format
> 86756#Y#
>
> ---
> The outline of the script i am trying to work on is
> While (<FILEID>)
> {
my $NUM; # better written in lc
my $AVAILABLE; # better written in lc
> chomp;
> if /GEEQualify/
> {
> $line = $_;
> ????? (How do i pick the "speed=xyz" variable from the $line? ) ??
$line =~ /Speed=\"(\d+)\"/;
my $speed = $1;
> if ($speed >= 500 )
> {
> ???(how do i) read the next two lines within the loop ???
> ?? PatternMatch the two lines to get the required NUM and Available
> values??
<FILEID> =~ /<NUM>(\d+)</;
$NUM = $1;
<FILEID> =~ /Available\"(\w)\"/;
$AVAILABLE = $1;
>
> print OUTPUTFILE, " $NUM#$AVAILABLE# \n"
> }
> }
>
>
> Please suggest on how to read two lines within a loop and
> the regular expression for pattern matching the two lines to get the values.
>
> thanks
> John
Maybe this works?! I didn't test it. And I'm a Perl-Novice, too!
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Wed, 12 Jul 2000 13:33:52 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Reading lines of a file within a loop?
Message-Id: <slrn8mosle.9rf.bernard.el-hagin@gdndev25.lido-tech>
Ulrich Ackermann <uackermann@orga.com> wrote:
>John Casey wrote:
>>
>> Hi,
>>
>> I need to write a script to scan a XML file for the lines containing the search
>> pattern "GEEQualify" . The line would be typically like this, (with the values
>> of the variables being different for different lines):
>>
>> <GEEQualify Length="9.979" DCode="A6" Speed="970"/>
>>
>> Then, when this line is found, it has the to check the value of
>> the "Speed" variable (eg: Speed="970" here) in the line. If it is above 500,
>> the script has to proceed to do the following (otherwise it has to continue
>> the search for the remaining of the file ); Scan the next two
>> lines which would be as follows:
>> ******
>> <NUM>86756</NUM>
>> <Info Available="Y" Name="Jackie" GEEAvailable="Fri Jun 21, 2000 00:00:00 EDT"
>> LateC="128"/>
>> ******
>> It has to take the numeric value (86756 here) between the <NUM> tags
>> and the alphabetic value of the 'Available' variable (Y here)
>> and print them out in a new file with the format
>> 86756#Y#
>>
>> ---
>> The outline of the script i am trying to work on is
>> While (<FILEID>)
while shouldn't be capitalised.
>> {
> my $NUM; # better written in lc
> my $AVAILABLE; # better written in lc
>
>> chomp;
>> if /GEEQualify/
This won't compile, but this...
if (/GEEQualify/)
...will.
>> {
>> $line = $_;
>> ????? (How do i pick the "speed=xyz" variable from the $line? ) ??
> $line =~ /Speed=\"(\d+)\"/;
> my $speed = $1;
There's no need for the $line variable. There's also no need to escape
the "'s in the regex. And this won't compile anyway if you have "use
strict" on (as you should) because you're later using $speed outside
of its scope. If you want $speed to be global you have to declare it
globally.
m/Speed="(\d+)"/;
$speed = $1; #provided $speed has been declared globally
>> if ($speed >= 500 )
^^^^^^
This is where "use strict" will cause the script to die unless you make
$speed global.
>> {
>> ???(how do i) read the next two lines within the loop ???
>> ?? PatternMatch the two lines to get the required NUM and Available
>> values??
> <FILEID> =~ /<NUM>(\d+)</;
> $NUM = $1;
> <FILEID> =~ /Available\"(\w)\"/;
> $AVAILABLE = $1;
This should read:
m#<NUM>(\d+)</NUM>#;
$NUM = $1;
m/Available="([^"]+)"/; #unless the value of available can only be Y or N
#in which case m/Available="(Y|N)"/ will do
$AVAILABLE = $1;
But there's still the fact that if both of these match once then you're ok, but
if, for example, you get a match for both and later in the file you only
get a match for, say, $AVAILABLE, you'll get ouput with the new $AVAILABLE
and the *old* $NUM.
And, as before, you don't need to escape the "'s.
>> print OUTPUTFILE, " $NUM#$AVAILABLE# \n"
"No comma allowed after filehandle". Drat.
>> }
>> }
>>
>>
>> Please suggest on how to read two lines within a loop and
>> the regular expression for pattern matching the two lines to get the values.
>>
>> thanks
>> John
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Wed, 12 Jul 2000 09:35:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading lines of a file within a loop?
Message-Id: <slrn8mot1t.65s.tadmc@magna.metronet.com>
[ Please limit your line lengths to the customary 70-72 characters. ]
On 11 Jul 2000 21:35:51 -0700, John Casey <John_member@newsguy.com> wrote:
>
>I need to write a script to scan a XML file for the lines containing the search
You should be very sure that you really want to do this using
a pattern match.
Parsing XML with a real XML parser is a much safer way to go about it...
>pattern "GEEQualify" . The line would be typically like this, (with the values
>of the variables being different for different lines):
>
><GEEQualify Length="9.979" DCode="A6" Speed="970"/>
>Scan the next two
>lines which would be as follows:
XML lets you put newlines in "funny" places.
There is no guarantee that the elements will be on "lines"
(unless you control all of the XML data yourself).
This is a legal XML tag:
<GEEQualify
Length="9.979"
DCode="A6"
Speed="970"
/>
If you pattern match, that will be a problem.
If you are using an XML parsing module, that will not be a problem...
>Please suggest on how to read two lines within a loop and
while (<FILE>) {
if ( /something/ ) { # read the next two lines
my $line1 = <FILE>;
my $line2 = <FILE>;
}
}
>the regular expression for pattern matching the two lines to get the values.
------------
# this is very fragile code!
if ( /<GEEQualify\s+
Length\s*=\s*"([^"]*)"\s+
DCode\s*=\s*"([^"]*)"\s+
Speed\s*=\s*"([^"]*)"/x ) {
my($length, $dcode, $speed) = ($1, $2, $3);
print "len '$length' code '$dcode' speed '$speed'\n";
}
------------
You can adapt the above for the other tag too.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Jul 2000 14:38:24 +0100
From: "John" <john@nomailplease>
Subject: Re: Regex Never satisfied
Message-Id: <396c759b@news.telinco.net>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn8moi52.9rf.bernard.el-hagin@gdndev25.lido-tech...
> On Wed, 12 Jul 2000 10:40:39 +0100, John <john@nomailplease> wrote:
> >At last I feel the arcane mystery of regex starting to reveal itself to
me !
> >
> >However chuffed I am that my code below works I would appreciate it if
> >someone would show me how it could be done a bit better.
> >I'm sure it could be done in two lines by not destroying the RHS but am
> >stumped.
> >
> >Thanks, JohnShep
> >
> > $alpha = $numeric = $string_in;
> > $alpha =~ s/[\W]|[\d]//g; # remove any non letters
> > $numeric =~ s/[\D]//g; # remove any non digits
>
> If you want these in two different variables (as you seem to ) then the
> only improvements and/or simplifications I can think of are:
>
> $alpha =~ s/[\W\d]//g;
>
> and
>
> $numeric =~ s/\D//g;
>
Yes that's what I need, I was imagining a regex that was something like
$alpha = extract_alpha_from $string_in;
$numeric = extract_numeric_from $string_in;
thanks John
------------------------------
Date: Wed, 12 Jul 2000 14:05:26 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Regex Never satisfied
Message-Id: <slrn8mougg.9rf.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 12 Jul 2000 14:38:24 +0100, John <john@nomailplease> wrote:
>
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
>news:slrn8moi52.9rf.bernard.el-hagin@gdndev25.lido-tech...
>> On Wed, 12 Jul 2000 10:40:39 +0100, John <john@nomailplease> wrote:
>> >At last I feel the arcane mystery of regex starting to reveal itself to
>me !
>> >
>> >However chuffed I am that my code below works I would appreciate it if
>> >someone would show me how it could be done a bit better.
>> >I'm sure it could be done in two lines by not destroying the RHS but am
>> >stumped.
>> >
>> >Thanks, JohnShep
>> >
>> > $alpha = $numeric = $string_in;
>> > $alpha =~ s/[\W]|[\d]//g; # remove any non letters
>> > $numeric =~ s/[\D]//g; # remove any non digits
>>
>> If you want these in two different variables (as you seem to ) then the
>> only improvements and/or simplifications I can think of are:
>>
>> $alpha =~ s/[\W\d]//g;
>>
>> and
>>
>> $numeric =~ s/\D//g;
>>
>Yes that's what I need, I was imagining a regex that was something like
>$alpha = extract_alpha_from $string_in;
>$numeric = extract_numeric_from $string_in;
>thanks John
You mean something like this:
($some_variable) = $string_to_search =~ m/some(.*)regex/;
which would put $1 into $some_variable if there's a match in
$string_to_search.
But I don't know if that's possible in your case since you haven't
provided an input string. If, for example, your input is...
$string_in = "aaa999bbb";
...and you want just the numbers you can use:
($nums) = $string_in =~ m/(d\+)/;
But if...
$string_in = "a8d8w7823y34uwierwe87234";
...and you still want just the numbers, you have to use s/// or some
other way (a map, possibly). Of course there could be a way to use the
($a) = $b =~ /(.*)/ form, but I don't know how. You can be sure,
though, that if it's possible someone here will post it. :-)
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Wed, 12 Jul 2000 13:55:59 GMT
From: kmhanser@my-deja.com
Subject: Re: running system command as root from perl
Message-Id: <8khtd9$h87$1@nnrp1.deja.com>
Okay, well.... I wouldn't consider myself security anal, but I'd like
to keep it as secure as possible. So I'm interested in some way to
keep this user friendly, and still have some measure of security...
So any other ideas are always appreciated. I'm not neccessarily
looking for the easiest way, just the best compromise of security and
user interface....
Thanx
In article <WENa5.11$w53.2537605@news.interact.net.au>,
"Troy Bell" <troyNO@SPAM.troysplace.net> wrote:
> In article <brian-ya02408000R1107001806460001@news.panix.com>,
> brian@smithrenaud.com (brian d foy) wrote:
>
> > i've heard this sentiment a lot lately - being in an internal
network is
> > no protection from malicious intent. it's not good to lower your
guard
> > because you *think* you are safe. it might be true in your
situation,
> > but it's not something that you should recommend to other people.
>
> Thus the comment at the top:
>
> "If you really want to create a security hazard (heh) install suid
perl
> and do the following:"
>
> My suggestion was the Easy Way Out (tm) of how to overcome his prob.
>
> I didn't say, or imply, that it was the most secure way of doing
things,
> because, quite frankly, it's probably the least secure way of doing
it.
>
> ;-)
>
> Depending on his setup, it might be all he needs.
>
> Now, if he had of said in the top of his post:
>
> "I'm extremely security anal and want to find the most secure way to
do
> this, whilst still being (l)user friendly", then I would have tossed
a few
> more ideas around. But, alas, he didn't. :( I'm quite happy to listen
to
> anyone elses comments on making this more secure actually, as I plan
on
> doing something like this myself.
>
> Kind regards,
> Troy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 12 Jul 2000 12:17:35 +0200
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Sorting a tab separated table ?
Message-Id: <396C45BF.E668480B@mssys.com>
dpi27@my-deja.com wrote:
> foreach $element (sort { (split(/\t/,$a))[1] cmp (split(/\t/,$b))[1]) }
> @table)
>
> so for a table like this one :
> @table=("val1.1\tval2.1\tval3.1\tval4.1","val2.1\tval2.2\tval3.2\val4.2"....)
>
> So my though was that with my sort function, table would be sorted using
> the val2.x columns since split return a table and that I take the 2nd
> element of it. But I have an error during compilation.
>
> Anybody got any idea how to make it ?
Sure. Read the error message:
syntax error at x.pl line x, near "]) "
The combination of a closing bracket and parentheses apears only once in
your posted code. Take a close look and try to find the corresponding
opening parentheses and...
BTW: You're not talking about "tables" but "lists".
Cheers
Wolfgang
------------------------------
Date: 12 Jul 2000 11:34:11 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: sorting issue
Message-Id: <963396510.3191@itz.pp.sci.fi>
In article <slrn8mn6ui.4q5.tadmc@magna.metronet.com>, Tad McClellan wrote:
>On 11 Jul 2000 22:10:29 GMT, D.W. <dpalmeNOSPAM@unitedtraffic.com> wrote:
>
>>I need to sort the miles as they are computed so that when the list is
> ^^^^^^^^^^^^^^^^^^^^
>You cannot do this (if I'm reading it correctly).
>You cannot sort a list if the list is not yet complete.
In the trivial sense that you can't sort (or do anything else with)
the entire list until it exists, you're correct. However, keeping the
list sorted as it is generated is quite simple:
sub insert (&\@@) {
my ($cmp, $array) = @_[0,1];
my @new = sort {$cmp->();} @_[2..$#_];
my $i = $#$array;
my $j = $#$array + @new;
while (@new) {
$array->[$j--] = $array->[$i--]
while $i >= 0 and do {
local ($a,$b) = ($array->[$i], $new[-1]);
$cmp->() > 0;
};
$array->[$j--] = pop @new;
}
return scalar @$array;
}
But I still think this wasn't what the OP meant.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 12 Jul 2000 13:12:20 GMT
From: brainmuffin@excite.com
Subject: sub selects
Message-Id: <8khqr8$fil$1@nnrp1.deja.com>
Does anyone know if mySQL supports sub-selects, and if so, what the
syntax is?
thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 12 Jul 2000 15:45:05 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: brainmuffin@excite.com
Subject: Re: sub selects
Message-Id: <396C8471.30782FA7@iname.com>
(Not perl this? ey?)
See http://www.mysql.com/documentation/mysql/full/
search for "missing from MySQL". No. MySQL do not
support sub-selects. Including "exists"-sub-selects.
Theese are serious shortcommings in MySQL in my
opinion. And was the main reason why Oracle was chosen
over MySQL in a project I worked on. (Even if oracle was
a bitch to install on linux, and the cost).
brainmuffin@excite.com wrote:
>
> Does anyone know if mySQL supports sub-selects, and if so, what the
> syntax is?
>
> thanks.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
Kjetil Skotheim
kjetilskotheim@iname.com
------------------------------
Date: Wed, 12 Jul 2000 11:44:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: syntax error in cgi script under IIS causes download prompt
Message-Id: <Pine.GHP.4.21.0007121127170.22850-100000@hpplus03.cern.ch>
On Tue, 11 Jul 2000, Frank Hanny wrote:
> "The Microsoft Internet Information Server requires NPH mode. As of
> version 2.30, CGI.pm will automatically detect when the script is
> running under IIS and put itself into this mode. You do not need to do
> this manually, although it won't hurt anything if you do."
Woops. Well, I often warn against the risks of off-topic questions,
so perhaps I should draw the consequences and try to answer fewer of
them. Sorry, I _was_ trying to be helpful, and the version of the
main documentation which I consulted really _does_ stress the
importance of designating scripts as nph- when using IIS, so I think I
have some excuse for not noticing mention of automatic detection of
IIS in the changes log.
> While your suggestion regarding Apache may be a good one, the choice of
> web server is not entirely under my control.
This situation isn't entirely unusual, but you still get my best
answer. Apache seems to be designed to be compatible with the
published interworking interfaces; even my limited experience with the
"competition" shows that proprietary servers have all kinds of quirks
in this regard (sometimes tuned to quirks in the same vendor's
browser, which is an even less attractive feature in a WWW situation).
Still, sorry if the advice wasn't useful. Thanks for pointing out the
automatic recognition of IIS in CGI.pm. (But this must make CGI.pm's
interactive debugging feature hard to use, since without explicit nph-
option it presumably produces different output interactively than when
it's run under IIS.)
cheer
------------------------------
Date: Wed, 12 Jul 2000 08:42:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Unique Items
Message-Id: <slrn8mopts.65s.tadmc@magna.metronet.com>
On Wed, 12 Jul 2000 08:03:33 GMT, philhibbs@my-deja.com <philhibbs@my-deja.com> wrote:
>In article <slrn8mlsh5.r6h.sholden@pgrad.cs.usyd.edu.au>,
> sholden@cs.usyd.edu.au wrote:
>> From the perlop description of s//
>> ... returns the number of substitutions made
>> So each element of @in will have 'xxx' prepended (since s// will
>> modify the original values). Each substition will return 1 and so
>> $saw{1} will be incremented.
>
>So this is more like what I want:
>@out = grep(!$saw{($tmp=$_)=~s/.*/xxx$1/}++, @in);
That won't do it (because it does not work :-)
You are doing an awful lot while computing the hash key
(it is pretty strange to be doing that much stuff inside
the curlies of a hash index)
If you want a block of code, use a block of code:
my @out = grep {s/^/xxx/; !$saw{$_}++} @in; # changes @in!
If you want @in to remain unaffected, then don't try and
be tricky, just be clear:
my @out = grep !$saw{$_}++, @in;
s/^/xxx/ for @out;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Jul 2000 14:49:10 +0200
From: Pirla <the.pirla@NOSPAM.flashnet.it>
Subject: Re: using @_ with subs (Just a quickie from a Perl Wannabe :)
Message-Id: <17qoms4fpv2obafd8erq4pdf3f2j9ecbq1@4ax.com>
On 2 Jul 2000 14:02:28 +0100, Jonathan Stowe <gellyfish@gellyfish.com>
wrote:
>On Fri, 30 Jun 2000 15:13:32 +1000 Geoff Toogood wrote:
>> Hi All,
>>
>> CURRENT SYSTEM = x86 200mhz / 60mb RAM / Active PERL 5.6 & WIN98
>>
>> I am using the @_ function in my code to pass variables to my subroutine.
>>
>> ########
>> open (FILE, '>>file.txt') || &error("CANT OPEN FILE");
>> sub error {
>> ($string) = @_;
>> print "ERROR: $string";
>> }
>> ########
>>
>> Yet when I use this method for more than one subroutine in the same script,
>> I get a nasty "WINBLOWS ILLEGAL OPERATION ERROR"
>>
I think you have to call your subroutine error in this way:
|| error("CANT OPEN FILE");
and your subroutine must return a value (True or False).
Try and write back.
Ciao
Pirla
Per rispondere in E-mail the (punto) pirla (chiocciola) flashnet.it
*** un bacio ai pupi ***
---> Linux user since yesterday <---
------------------------------
Date: Wed, 12 Jul 2000 10:04:41 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: using @_ with subs (Just a quickie from a Perl Wannabe :)
Message-Id: <396C7AF9.D939B0C4@attglobal.net>
Pirla wrote:
>
> >> open (FILE, '>>file.txt') || &error("CANT OPEN FILE");
> >> sub error {
> >> ($string) = @_;
> >> print "ERROR: $string";
> >> }
> >> ########
> >>
> >> Yet when I use this method for more than one subroutine in the same script,
> >> I get a nasty "WINBLOWS ILLEGAL OPERATION ERROR"
> >>
>
> I think you have to call your subroutine error in this way:
> || error("CANT OPEN FILE");
> and your subroutine must return a value (True or False).
> Try and write back.
&error("CANT OPEN FILE"); # is fine
error("CANT OPEN FILE"); # also fine
error; # generally fine, but no args here
&error; # fine, no args thou.
error(); # same as above
As for returning true or false, "print" returns true if it can print,
generally the case.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3636
**************************************