[19399] in Perl-Users-Digest
Perl-Users Digest, Issue: 1594 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 23 03:05:31 2001
Date: Thu, 23 Aug 2001 00:05:09 -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: <998550308-v10-i1594@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 23 Aug 2001 Volume: 10 Number: 1594
Today's topics:
Re: Accessing $a and $b in conjunction with goto &NAME <Tassilo.Parseval@post.rwth-aachen.de>
Re: bizarre! (Sam Holden)
Re: bizarre! <Tassilo.Parseval@post.rwth-aachen.de>
Re: default.ida and your web server <Tassilo.Parseval@post.rwth-aachen.de>
elegant substitutions <justin.devanandan.allegakoen@intel.com>
Re: elegant substitutions <mbudash@sonic.net>
Error in CGI Application: Can't open perl script "d:\my <ash@turnernewmedia.com.au>
Re: Executing DEL and UPDT PL/SQL stored procedures fro <ron@indra.com>
Re: New to group - I'll start with a question (Tad McClellan)
Re: New to group - I'll start with a question <diablo@prometheus.humsoc.utas.edu.au>
Re: Openning a file <Tassilo.Parseval@post.rwth-aachen.de>
Problem: How to deal with list-type return value of pe <enxi.wang@nokia.com>
Re: Re: Search a file (line by line) for String/text <jnurick@zdnetonebox.com>
Re: references and strict <mike_solomon@lineone.net>
Re: Using %{$hashref} or %$hashref to dereference?? <Tassilo.Parseval@post.rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Aug 2001 08:19:42 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Accessing $a and $b in conjunction with goto &NAME
Message-Id: <3B84A07E.70200@post.rwth-aachen.de>
W. James Showalter, Jr. wrote:
[code snipped]
> Rather than come up with a more generic name I wanted it to be
> able to be called by the name 'oidsort'. So I put the following in
> the same package as ipsort.
>
> sub oidsort {
> goto &ipsort;
> }
>
> However, this did not work even though the calling package name
> was correctly determined in the actual sub 'ipsort'. The errors
> indicated that $a and $b were not initialized.
Read 'perldoc -f goto'. It says something about not initializing a
subroutine called with goto &NAME and also something about caller
behaving differently. I did not read it in detail though, but it might
be the answer for this behaviour.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 23 Aug 2001 04:25:36 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: bizarre!
Message-Id: <slrn9o91es.qik.sholden@pgrad.cs.usyd.edu.au>
On Wed, 22 Aug 2001 20:51:42 -0700, ekkis <e@nospam:[arix.com]> wrote:
># perl -v
>This is perl, v5.6.0 built for i386-linux
>
>these are ok:
>
># perl -e '$x{x-this} = 1;'
># perl -e '$x{"no-this"} = 1;'
>
>but this fails:
>
># perl -e '$x{no-this} = 1;'
>syntax error at -e line 1, near "{no"
>Execution of -e aborted due to compilation errors.
no means something to perl...
perldoc -f no
no Module LIST
See the the use entry elsewhere in this document
function, which `no' is the opposite of.
From perldoc -f use:
There's a corresponding `no' command that unim-
ports meanings imported by `use', i.e., it calls
`unimport Module LIST' instead of `import'.
no integer;
no strict 'refs';
no warnings;
--
Sam Holden
------------------------------
Date: Thu, 23 Aug 2001 07:59:38 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: bizarre!
Message-Id: <3B849BCA.9030504@post.rwth-aachen.de>
Sam Holden wrote:
> On Wed, 22 Aug 2001 20:51:42 -0700, ekkis <e@nospam:[arix.com]> wrote:
>
>># perl -v
>>This is perl, v5.6.0 built for i386-linux
>>
>>these are ok:
>>
>># perl -e '$x{x-this} = 1;'
>># perl -e '$x{"no-this"} = 1;'
>>
>>but this fails:
>>
>># perl -e '$x{no-this} = 1;'
>>syntax error at -e line 1, near "{no"
>>Execution of -e aborted due to compilation errors.
>>
>
> no means something to perl...
Yes, this is one thing. But when using strictures, $h{yes-this} would
also trigger a warning. Perl would read the key as two barewords with a
minus-operator in between. While $h{this} would work, a key 'yes-this'
would need to be quotes.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 23 Aug 2001 08:08:49 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: default.ida and your web server
Message-Id: <3B849DF1.602@post.rwth-aachen.de>
Godzilla! wrote:
[snipped sound thoughts on CodeRed]
And, one might want to add, there is an article, recently liked to on
perl.com, that covers CodeRed in conjunction with apache:
http://www.onlamp.com/pub/a/apache/2001/08/16/code_red.html
The article introduces the Apache::CodeRed which tries to send the
originator of the ateempted /default.ida.... break-in a notification
that the server has been infected by CodeRed.
Looking at my logs, I get this attacks each few minutes. I have already
tried to find out notifying the admin of the remote-server by hand
(looking for a website under this IP), but usually these are non
configured servers just showing a default page.
That's particularly lame, I think: Running IIS webserver without any
configuration and probably without even any awareness that it runs.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 23 Aug 2001 13:35:14 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: elegant substitutions
Message-Id: <9m24ml$h34@news.or.intel.com>
Hello all,
I can get the following to work, with some splits and substitutions
but the code runs into several lines . . . this in itself isn't so bad
but there's a better way to do it, and while I have been trying
I'm not getting what I want.
Here's the low down:-
A particular variable could have any of the following combinations
plus others:
61[02,02,04] which needs to be interpreted as 6102, 6103, 6104
7[20,30]6 which needs to be interpreted as 7206, 7306
[EA,BA]T which needs to be interpreted as EAT, BAT
blah blah blah
How can I get a one line substitution to work?
Thanks
------------------------------
Date: Thu, 23 Aug 2001 06:36:39 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: elegant substitutions
Message-Id: <mbudash-E1A5ED.23363822082001@news.sonic.net>
In article <9m24ml$h34@news.or.intel.com>, "Just in"
<justin.devanandan.allegakoen@intel.com> wrote:
> Hello all,
>
> I can get the following to work, with some splits and substitutions
> but the code runs into several lines . . . this in itself isn't so bad
> but there's a better way to do it, and while I have been trying
> I'm not getting what I want.
>
> Here's the low down:-
>
> A particular variable could have any of the following combinations
> plus others:
>
> 61[02,02,04] which needs to be interpreted as 6102, 6103, 6104
> 7[20,30]6 which needs to be interpreted as 7206, 7306
> [EA,BA]T which needs to be interpreted as EAT, BAT
> blah blah blah
>
> How can I get a one line substitution to work?
>
> Thanks
>
>
one way:
s|^(.*?)\[(.+)\](.*?)$|join(",",map{"$1$_$3"}(split(/,/,$2)))|e;
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Thu, 23 Aug 2001 16:00:19 +1000
From: Ash Turner <ash@turnernewmedia.com.au>
Subject: Error in CGI Application: Can't open perl script "d:\myfolder\myfolder\: No such file or directory.
Message-Id: <B7AAD913.CC1%ash@turnernewmedia.com.au>
Hi
Anyone give me some suggestions about this error message I have checked:
Perl Installed
.pl associated with perl.exe
App Mapping the correct path c:\perl\bin\perl.exe %s %s
script and execute permissions set on all directories
I am running:
WinNT4 (SP6)
IIS4
ActivePerl
I believe that it is a directory problem, rather than a Header problem, as I
have created a virtual directory on the IISMC to perl, and when the program
(pl) is placed in there - and run from there it works.?
Ash
------------------------------
Date: Wed, 22 Aug 2001 22:44:02 -0600
From: Ron Reidy <ron@indra.com>
Subject: Re: Executing DEL and UPDT PL/SQL stored procedures from PERL
Message-Id: <3B848A12.DFB85F82@indra.com>
GC wrote:
>
> Hi,
>
> i was wondering whether it is possible (and more importantly how!) to
> execute some PL/SQL stored procedures on Oracle (stprocs) from PERL.
>
> I know using DBI, perl can execute SELECT stprocs but what about
> DELETE and UPDATES? Also can those DELETE and UPDATES stprocs return a
> value to PERL (say number of rows deleted or updated)?
>
> In these codes, im actually calling a stproc found in a Package and it
> simply select date from dual.
>
> use DBI qw(:sql_types);
>
> my $today;
>
> $csr = $dbh->prepare(q{
> BEGIN
> PACK_TEST.TEST_PROC (:today);
> END;
> });
>
> $csr->bind_param_inout(":today", \$today, 20);
> $csr->execute;
> print "Today is $today\n";
>
> $dbh->disconnect;
>
> Is there some equivalent codes for DELETE and UPDATE?
>
> Thanks,
>
> GC.
It depends on how the PL/SQL is written. If you want to return values,
then write the procedure/function so values will be returned. There are
plenty of examples in the DBD::Oracle docs on using PL/SQL from Perl.
If you are up to the challenge, try building and working with
Oracle::OCI. It gic\ves direct access to low level Oracle functions
(just like C/C++ OCI programming) as well as internal function directly
from Perl.
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
------------------------------
Date: Thu, 23 Aug 2001 04:14:37 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: New to group - I'll start with a question
Message-Id: <slrn9o8r88.51f.tadmc@tadmc26.august.net>
Mr Q. Z. Diablo <diablo@prometheus.humsoc.utas.edu.au> wrote:
>In article <slrn9o8f5c.4nd.tadmc@tadmc26.august.net>,
>tadmc@augustmail.com wrote:
>> Mr Q. Z. Diablo <diablo@prometheus.humsoc.utas.edu.au> wrote:
>>
>> >inconsistent with the rest of the way that Perl works (to me, anyway).
>>
>>
>> Well we can't read your mind, so we can address that part.
>>
>> Got an example of what you mean by that?
>
>I suppose what I mean is "why is the array on the left stuffed with $1,
>$2, $3, etc. or is it just an arbitrary piece of functionality included
>because it is useful.
I was questioning your use of "inconsistent" there. To have
an inconsistentency, you need 2 things that are "different"
in some way.
You showed only 1 thing, I was asking for the 2nd thing that
behaved somehow differently. Can you give an example?
>Is 'it is useful' the rationale behind this piece
>of syntax?"
I dunno. Sure seems likely though, with Larry being so smart and all...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 23 Aug 2001 15:05:19 +1000
From: "Mr Q. Z. Diablo" <diablo@prometheus.humsoc.utas.edu.au>
Subject: Re: New to group - I'll start with a question
Message-Id: <diablo-428CD4.15051923082001@newsroom.utas.edu.au>
In article <slrn9o8r88.51f.tadmc@tadmc26.august.net>,
tadmc@augustmail.com wrote:
> Mr Q. Z. Diablo <diablo@prometheus.humsoc.utas.edu.au> wrote:
> >In article <slrn9o8f5c.4nd.tadmc@tadmc26.august.net>,
> >tadmc@augustmail.com wrote:
> >> Mr Q. Z. Diablo <diablo@prometheus.humsoc.utas.edu.au> wrote:
> >>
>
> >> >inconsistent with the rest of the way that Perl works (to me, anyway).
> >>
> >>
> >> Well we can't read your mind, so we can address that part.
> >>
> >> Got an example of what you mean by that?
> >
> >I suppose what I mean is "why is the array on the left stuffed with $1,
> >$2, $3, etc. or is it just an arbitrary piece of functionality included
> >because it is useful.
>
>
> I was questioning your use of "inconsistent" there. To have
> an inconsistentency, you need 2 things that are "different"
> in some way.
>
> You showed only 1 thing, I was asking for the 2nd thing that
> behaved somehow differently. Can you give an example?
I would have expected that sort of thing to set the variables $1, $2,
&c. but do nothing else apart from, perhaps, fill the first scalar. A
matching operator doesn't (intuitively) evaluate as a list and this
seemed odd. That's all.
Mr Q. Z. D.
----
Drinker, systems administrator, wannabe writer, musician and all-round bastard.
"If chance supplied a loaf of white bread,
Two casks of wine and a leg of mutton,
In the corner of a garden with a tulip-cheeked girl
There'd be enjoyment no Sultan could outdo." - Omar Khayyam.
------------------------------
Date: Thu, 23 Aug 2001 08:14:04 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Openning a file
Message-Id: <3B849F2C.3000009@post.rwth-aachen.de>
Tad McClellan wrote:
> No, that is what _arrays_ do in scalar context. There are
> no arrays in the above. This is one of the places where the
> distinction does matter:
>
> Perl FAQ, part 4:
>
> "What is the difference between a list and an array?"
Hehe, it has often been referenced to this FAQ-article. I never really
read it since I thought I knew the difference. But you gave me some
subtle hints as to the fact that I didn't. ;-)
I also read this bit about the comma-operator in scalar context in
perlop. There is, however, something I don't quite understand about it.
It says, the left side of the comma is evaluated and its value thrown
away. After that, the right-side value is returned. In which way does it
make sense to evaluate something and then throw it away?
Does anyone have an example for that?
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 23 Aug 2001 05:37:18 GMT
From: "Wang Enxi" <enxi.wang@nokia.com>
Subject: Problem: How to deal with list-type return value of perl function in C++
Message-Id: <iE0h7.1499$Kl.29629@news2.nokia.com>
Hi!
I am programming embedded perl in C++.and I encountered a headache problem
as following:
how to pass a "complicated list" back to C++. As we know, sometimes we need
to invoke a perl program from a C++ program to get data of list type, whose
item maybe also a list, and so on. Then how can we pass the list to C++
program?
In C++, only serverl API functions: POPi, POPl, POPn, POPp and POPs are
provided. With these functions, the data item in the list has to be poped
one by one from the stack. And it's difficult to combine them again as it's
hard to know where is the border.
For the issue, do u have any good idea? Maybe I have to write the data into
a file in Perl program and get them from C++ program, but this idea isn't
very good. Could u pls give me some info on it or suggestion?
In my cases, Perl will return a great amount of data to C++, but how to pick
them up?
Thank you in advanced.
Wang Enxi
------------------------------
Date: Thu, 23 Aug 2001 06:12:10 +0100
From: John Nurick <jnurick@zdnetonebox.com>
Subject: Re: Re: Search a file (line by line) for String/text
Message-Id: <6v48ot8tann6rnok79thb4r53n7u5cc7vn@4ax.com>
On 22 Aug 2001 08:40:03 GMT, rgarciasuarez@free.fr (Rafael
Garcia-Suarez) wrote:
>Pete Sohi wrote in comp.lang.perl.misc:
>> Calling all Perl Gurus...(Why is it always with religious connotations
>> - why not Perl Studs?!...)
>
>AFAIK, in classical sanskrit, guru only means master or professor.
And in classical menswear, a pearl stud is something that holds your
shirt and collar together.
--
John
Please reply to the newsgroup and not by e-mail.
split $q,q[ acehJklnoPrstu]; $q.=$_[$_] for map hex, unpack
q,a,x29,q;89D010B3170A3B7041263B01D0177;;print qq;...$q.\n;
------------------------------
Date: Wed, 22 Aug 2001 13:41:02 +0100
From: "Mike Solomon" <mike_solomon@lineone.net>
Subject: Re: references and strict
Message-Id: <3b83a88a_3@mk-nntp-1.news.uk.worldonline.com>
Thanks for the help.
I even understood it !
problem solved
Regards
Mike Solomon
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9o6chk.19o.tadmc@tadmc26.august.net...
>
> [ First text moved to second. Second text moved to first.
> Now what came first comes first and what came second
> comes second.
> ]
>
>
> Kevin Bartz <l_pantin@hotmail.com> wrote:
> >In article <3b823c33_1@mk-nntp-1.news.uk.worldonline.com>, "Mike Solomon"
> ><mike_solomon@lineone.net> wrote:
> >
> >> Depending on the value of a variable I want to call different sub
> >> routines.
>
> [snip]
>
> >> Any help would be appreciaceted.
> >>
> >> use strict;
> >>
> >> my $mike = "a2";
> >>
> >> no strict 'refs';
> >> &$mike;
> >>
> >> sub a1 {print "a1\n";}
> >> sub a2 {print "a2 \n";}
> >> sub a3 {print "a3\n";}
>
> >How about an eval?
>
>
> A string eval is the course of last resort, to be used only
> when all else fails. A dispatch table will do nicely here,
> with less danger.
>
>
> my %subs = (
> a1 => \&a1,
> a2 => \&a2,
> a3 => \&a3,
> );
>
> $subs{$mike}->();
>
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Thu, 23 Aug 2001 07:53:10 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Using %{$hashref} or %$hashref to dereference??
Message-Id: <3B849A46.2020303@post.rwth-aachen.de>
Carlos C. Gonzalez wrote:
[%$hashref versus %{$hashref} snipped]
> I am trying to develop a consistent coding style and am inclined to use
> the "{}" for clarity as to what I am doing exactly but then perhaps I
> should just skip them. As long as I am consistent.
>
> Any thoughts on this?
Under some circumstances it is necessary to use the curly brackets.
Imagine you are working with a mail-module and have $msg as object. $msg
has a header method that returns a reference to a hash. Now, if you want
to dereference the object, you cannot write
%$msg->header
Perl will complain that you cannot call this method without a package or
object reference. Instead you have to write
%{$msg->header}
to indicate that you explicitely want to call header on $msg and
dereference the returned value into a hash.
So, if you are heading for consistency which is not a bad habit, then
you should always use curly brackets since they always work.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
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 1594
***************************************