[22019] in Perl-Users-Digest
Perl-Users Digest, Issue: 4241 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 10 11:11:01 2002
Date: Tue, 10 Dec 2002 08:10:10 -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 Tue, 10 Dec 2002 Volume: 10 Number: 4241
Today's topics:
Re: Problem - Array as Member of Object (Tad McClellan)
Re: Problem with range operator: for ($1 .. $2) <RobTM@fake.addr.ess>
Re: Problem with range operator: for ($1 .. $2) <kurzhalsflasche@netscape.net>
Re: Problem with range operator: for ($1 .. $2) (Peter Scott)
Re: read return value from a sql script using piped ope <sunil_franklin@hotmail.com>
Re: read return value from a sql script using piped ope <rereidy@indra.com>
Re: read return value from a sql script using piped ope <sunil_franklin@hotmail.com>
RegEx question? (Mike)
Re: Regular expression word replacement (Tad McClellan)
Re: The black list: websites banned on Google (Tad McClellan)
unknown import: lib Calc at C:/Perl/lib/Math/BigInt.pm (bsma1)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Dec 2002 08:59:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem - Array as Member of Object
Message-Id: <slrnavc0a5.25h.tadmc@magna.augustmail.com>
Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote:
> Dela Lovecraft wrote (Tuesday 10 December 2002 13:03):
>> #Makes the value of $self->{CELLS} equal to an array of the data we
>> have just got hold of.
>> $self->{CELLS} = @hold;
>
>
> You just stuffed a list in a scalar.
No, he just stuffed an _array_ in a scalar.
> Evaluating a list in a scalar context
A list cannot exist is scalar context.
An array can though.
"there's no such thing as a list in scalar context"
Quoted from this Perl FAQ:
What is the difference between a list and an array?
> yields the number of elements in that list.
s/list/array/;
> Store the ref instead:
>
> $self->{CELLS} = \@hold;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Dec 2002 14:39:38 GMT
From: Robert Szczygiel <RobTM@fake.addr.ess>
Subject: Re: Problem with range operator: for ($1 .. $2)
Message-Id: <slrn.pl.avbv59.21g.RobTM@pcmic25.cern.ch>
Pasi Ryhanen wrote:
> ------------------------------------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
>
> while (<DATA>) {
> if (/^(-?\d+)\s+(-?\d+)$/) {
> print;
> for ($1 .. $2) {
> print "\t$_\n";
> }
> }
> }
> __DATA__
> -2 0
> -2 0
> ------------------------------------------------------------------------
> Could somebody enlighten me on what is happening here?
> (The documentation (perlop) talks about "magical auto-increment
> algorithm", but I don't quite see how it could explain this.)
I will not enlighten you as I do not know why it works like that,
but using:
for ($1 .. $2+0)
seems to help. :-))
Somebody could explain?
RobTM:)
--
** - Why a bike cannot stand up by itself?
** - Because it is two-tyred!
-- http://3226865153/~szczygie --
------------------------------
Date: Tue, 10 Dec 2002 16:16:32 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: Problem with range operator: for ($1 .. $2)
Message-Id: <at50jl$10e2v1$1@fu-berlin.de>
Recently, Pasi Ryhanen told us:
> I'm trying to use the range operator (..) with integers taken from a
> previous regexp match. For some reason, it doesn't work as I expected,
> if the range is from a negative number to zero.
>
> I have the following Perl script:
>
> ------------------------------------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
>
> while (<DATA>) {
> if (/^(-?\d+)\s+(-?\d+)$/) {
> print;
> for ($1 .. $2) {
> print "\t$_\n";
> }
> }
> }
> __DATA__
> -2 0
> -2 0
> ------------------------------------------------------------------------
>
> It gives the following output (when using perl versions 5.6.1 or
> 5.8.0):
> -2 0
> -2
> -1
> 0
> -2 0
>
> I would expect it go give this (which is exactly what perl 5.005_03
> gave):
> -2 0
> -2
> -1
> 0
> -2 0
> -2
> -1
> 0
>
> Could somebody enlighten me on what is happening here?
> (The documentation (perlop) talks about "magical auto-increment
> algorithm", but I don't quite see how it could explain this.)
>
For some reasons (that I do not have the faintest idea of), one of your
zeroes is not treated as a number.
Replacing
for ($1 .. $2)
with
for (int($1) .. int($2))
should help.
HTH anyway,
Dominik
------------------------------
Date: Tue, 10 Dec 2002 15:52:34 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Problem with range operator: for ($1 .. $2)
Message-Id: <65oJ9.195744$ka.4600970@news1.calgary.shaw.ca>
In article <slrn.pl.avbv59.21g.RobTM@pcmic25.cern.ch>,
Robert Szczygiel <RobTM@fake.addr.ess> writes:
>Pasi Ryhanen wrote:
>> __DATA__
>> -2 0
>> -2 0
>> ------------------------------------------------------------------------
>> Could somebody enlighten me on what is happening here?
>
>I will not enlighten you as I do not know why it works like that,
>but using:
>for ($1 .. $2+0)
> seems to help. :-))
>
>Somebody could explain?
This is a bug that was introduced early in perl 5.6.0 and fixed in the current
development perl. It occurs when the right hand operand of .. is the string "0".
See http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-10/msg01179.html.
What I find curious is that after being in existence for nearly three years this
bug was reported to p5p, discovered on the Perl Quiz of the Week, and reported
here, all within the space of two months.
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Tue, 10 Dec 2002 19:44:03 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: read return value from a sql script using piped open
Message-Id: <GHmJ9.1$jV1.133@news.oracle.com>
"Ron Reidy" <rereidy@indra.com> wrote in message
news:3DF5EB0E.68EC226D@indra.com...
> Sunil wrote:
> >
> > All,
> > I need to get the return value from a sql script and redirect the
output
> > to a file. One of the requirements is to avoid showing passwords to 'ps'
and
> > the same code needs to run on win and unix.
> > I am now calling the script using code as below.
> >
> > --------- Start My Code
> > open SQLP, "|sqlplus -s /nolog >> $output_file_name "
> > or die "cannot open sqlplus
$ERRNO
> > \n";
> > # Connect and execute the script. This is done by writing to the stream
we
> > open for sqlplus.
> > SQLP "connect $user_name/$password \n" or die "cannot write in
doScript";
> > print SQLP "\@$script_name; \n" or die "cannot write in doScript";
> > close SQLP or die "cannot close in doScript";
> >
> > print "Status is :" . ($? >> 8);
> > --------- End My Code
> >
> > The sql script I execute is :-
> > ****** Start t.sql
> > select sysdate from dual
> > /
> > exit 77
> > ****** End t.sql
> >
> > This works if the exit value is 0 but anything else fails.
> > ................. Start Error I see
> > Uncaught exception from user code:
> > cannot close in doScript at sqlutils.pm line 160.
> > sqlutils::doSqlScript('t.sql', 'scott', 'tiger@iasdb.local',
> > 'a.log') called at tutils.pl ine 21
> > ................. End Error I see
> >
> > I had tried using the here document operator
> > ######## Start MyCode Using the here doc
> > $ret = system << "EOF";
> > sqlplus -s scott/tiger\@iasdb.local \@t.sql
> > EOF
> > print ($ret >> 8);
> >
> > ######## End MyCode Using the here doc
> >
> > This shows the return value properly but I am not able to redirect
the
> > output of the script to the file.
> >
> > Your suggestions please.
> >
> > Thanks & Regards,
> > Sunil.
> What you should use is a here doc...
>
>
> my $cmd = qq{
> sqlplus -s << EOF
> connect $username/$password
> @script_name
> <quit|exit>
> EOF
> };
>
> my $results = `$cmd`;
> die "some message" if $?;
>
> Voila!
> --
The issue is that the output can be huggeee and I dont want to get it into a
scalar variable or array.
I need to keep writing to a file.
Thanks for your suggestion.
Sunil.
------------------------------
Date: Tue, 10 Dec 2002 07:13:55 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: read return value from a sql script using piped open
Message-Id: <3DF5F6A3.C055AE9A@indra.com>
Sunil wrote:
>
> "Ron Reidy" <rereidy@indra.com> wrote in message
> news:3DF5EB0E.68EC226D@indra.com...
> > Sunil wrote:
> > >
> > > All,
> > > I need to get the return value from a sql script and redirect the
> output
> > > to a file. One of the requirements is to avoid showing passwords to 'ps'
> and
> > > the same code needs to run on win and unix.
> > > I am now calling the script using code as below.
> > >
> > > --------- Start My Code
> > > open SQLP, "|sqlplus -s /nolog >> $output_file_name "
> > > or die "cannot open sqlplus
> $ERRNO
> > > \n";
> > > # Connect and execute the script. This is done by writing to the stream
> we
> > > open for sqlplus.
> > > SQLP "connect $user_name/$password \n" or die "cannot write in
> doScript";
> > > print SQLP "\@$script_name; \n" or die "cannot write in doScript";
> > > close SQLP or die "cannot close in doScript";
> > >
> > > print "Status is :" . ($? >> 8);
> > > --------- End My Code
> > >
> > > The sql script I execute is :-
> > > ****** Start t.sql
> > > select sysdate from dual
> > > /
> > > exit 77
> > > ****** End t.sql
> > >
> > > This works if the exit value is 0 but anything else fails.
> > > ................. Start Error I see
> > > Uncaught exception from user code:
> > > cannot close in doScript at sqlutils.pm line 160.
> > > sqlutils::doSqlScript('t.sql', 'scott', 'tiger@iasdb.local',
> > > 'a.log') called at tutils.pl ine 21
> > > ................. End Error I see
> > >
> > > I had tried using the here document operator
> > > ######## Start MyCode Using the here doc
> > > $ret = system << "EOF";
> > > sqlplus -s scott/tiger\@iasdb.local \@t.sql
> > > EOF
> > > print ($ret >> 8);
> > >
> > > ######## End MyCode Using the here doc
> > >
> > > This shows the return value properly but I am not able to redirect
> the
> > > output of the script to the file.
> > >
> > > Your suggestions please.
> > >
> > > Thanks & Regards,
> > > Sunil.
> > What you should use is a here doc...
> >
> >
> > my $cmd = qq{
> > sqlplus -s << EOF
> > connect $username/$password
> > @script_name
> > <quit|exit>
> > EOF
> > };
> >
> > my $results = `$cmd`;
> > die "some message" if $?;
> >
> > Voila!
> > --
>
> The issue is that the output can be huggeee and I dont want to get it into a
> scalar variable or array.
> I need to keep writing to a file.
>
> Thanks for your suggestion.
>
> Sunil.
The use the SQL*Plus command 'spool' and read the file you spool output
to later.
--
Ron Reidy
Oracle DBA
------------------------------
Date: Tue, 10 Dec 2002 20:15:29 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: read return value from a sql script using piped open
Message-Id: <%8nJ9.2$jV1.76@news.oracle.com>
"Ron Reidy" <rereidy@indra.com> wrote in message
news:3DF5F6A3.C055AE9A@indra.com...
> Sunil wrote:
> >
> > "Ron Reidy" <rereidy@indra.com> wrote in message
> > news:3DF5EB0E.68EC226D@indra.com...
> > > Sunil wrote:
> > > >
> > > > All,
> > > > I need to get the return value from a sql script and redirect
the
> > output
> > > > to a file. One of the requirements is to avoid showing passwords to
'ps'
> > and
> > > > the same code needs to run on win and unix.
> > > > I am now calling the script using code as below.
> > > >
> > > > --------- Start My Code
> > > > open SQLP, "|sqlplus -s /nolog >> $output_file_name "
> > > > or die "cannot open sqlplus
> > $ERRNO
> > > > \n";
> > > > # Connect and execute the script. This is done by writing to the
stream
> > we
> > > > open for sqlplus.
> > > > SQLP "connect $user_name/$password \n" or die "cannot write in
> > doScript";
> > > > print SQLP "\@$script_name; \n" or die "cannot write in doScript";
> > > > close SQLP or die "cannot close in doScript";
> > > >
> > > > print "Status is :" . ($? >> 8);
> > > > --------- End My Code
> > > >
> > > > The sql script I execute is :-
> > > > ****** Start t.sql
> > > > select sysdate from dual
> > > > /
> > > > exit 77
> > > > ****** End t.sql
> > > >
> > > > This works if the exit value is 0 but anything else fails.
> > > > ................. Start Error I see
> > > > Uncaught exception from user code:
> > > > cannot close in doScript at sqlutils.pm line 160.
> > > > sqlutils::doSqlScript('t.sql', 'scott', 'tiger@iasdb.local',
> > > > 'a.log') called at tutils.pl ine 21
> > > > ................. End Error I see
> > > >
> > > > I had tried using the here document operator
> > > > ######## Start MyCode Using the here doc
> > > > $ret = system << "EOF";
> > > > sqlplus -s scott/tiger\@iasdb.local \@t.sql
> > > > EOF
> > > > print ($ret >> 8);
> > > >
> > > > ######## End MyCode Using the here doc
> > > >
> > > > This shows the return value properly but I am not able to
redirect
> > the
> > > > output of the script to the file.
> > > >
> > > > Your suggestions please.
> > > >
> > > > Thanks & Regards,
> > > > Sunil.
> > > What you should use is a here doc...
> > >
> > >
> > > my $cmd = qq{
> > > sqlplus -s << EOF
> > > connect $username/$password
> > > @script_name
> > > <quit|exit>
> > > EOF
> > > };
> > >
> > > my $results = `$cmd`;
> > > die "some message" if $?;
> > >
> > > Voila!
> > > --
> >
> > The issue is that the output can be huggeee and I dont want to get it
into a
> > scalar variable or array.
> > I need to keep writing to a file.
> >
> > Thanks for your suggestion.
> >
> > Sunil.
> The use the SQL*Plus command 'spool' and read the file you spool output
> to later.
> --
> Ron Reidy
> Oracle DBA
I do not want the huge output to be seen on the console, that is why I
am particular about redirection to a file.
Thanks,
Sunil.
------------------------------
Date: 10 Dec 2002 08:04:54 -0800
From: mtg82814@melsud.res.ray.com (Mike)
Subject: RegEx question?
Message-Id: <5bf8838e.0212100804.607c01d1@posting.google.com>
hello,
i am trying to write a regular expression to match this line:
11449971_770_jig
the numbers can be anything.
i have this simple program:
$name = "11449971_770_jig";
if ($name =~ /\d_\d_jig$/) { print "yes"; } else { print "no"; }
but it doesn't seem to match the line, i think the problem has to do
with the underscore before the \d. i can match up to "\d_jig$", but
as soon as i add an underscore before the \d like this: "_\d_jig$" the
regex doesn't match.
any help would be appreciated.
thanks,
-Mike
------------------------------
Date: Tue, 10 Dec 2002 08:43:37 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular expression word replacement
Message-Id: <slrnavbvcp.25h.tadmc@magna.augustmail.com>
CJ <newsgroupcontact@seseaz.org.uk> wrote:
> I want to a script/reg.exp to search out certain words in a string (may be
> multiline) and replace them with an alternative.
How will you determine what to replace it with when the word
has more than one meaning?
Should it be
Jesus rode an donkey on Palm Sunday.
or
Jesus rode an butt on Palm Sunday.
or
Jesus rode an *** on Palm Sunday.
??
> The r.e. must be able to
> handle the disallowed words in forms where the letters of the words are
> separated by any n u m b e r of s p a c e s or by a.n.y other
> n:o:n:a:l:p:h:a:n:u:m:e:r:i:c
> characters or spaced out on
> n
> e
> w
> l
> i
> n
> e
> .>:;s
Now we cannot detect word boundaries.
It will be embarrbutting to replace things in the middle of a word:
John Wilkes Booth was a buttbuttin.
John Wilkes Booth was a donkeydonkeyin.
> as no doubt once the script is in place those who's words are replaced will
> try to get round it.
What you want to do is pretty much hopeless with any degree of accuracy.
Do you expect to be able to detect "phuk ewe" for instance?
Do a Google groups search for "bad words" or "dirty words". This
has been discussed here many times before.
> I reckon I could do the line by line bit easily
You have not thought enough about the problem then.
But I'll try and answer the question anyway. :-)
This will find and display the words in their original form,
so that a human can decide if they should be replaced or not:
----------------------------------
#!/usr/bin/perl
use warnings;
use strict;
{ local $/;
$_ = <DATA>;
}
my @words = qw/number spaces any nonalphanumeric newlines/;
my $re = join '|', map { s//\\W*/g; substr $_, 3, -3 } @words;
print "'$1' is a bad word\n" while /($re)/g;
__DATA__
The r.e. must be able to
handle the disallowed words in forms where the letters of the words are
separated by any n u m b e r of s p a c e s or by a.n.y other
n:o:n:a:l:p:h:a:n:u:m:e:r:i:c
characters or spaced out on
n
e
w
l
i
n
e
.>:;s
as no doubt once the script is in place those who's words are replaced will
try to get round it.
----------------------------------
Or maybe modify it to find ones that have obviously been obfuscated,
by using \W+ instead of \W*.
Another alternative is to just remove all the \W chars before
looking for the bad words. That will work for detecting them,
but not for replacing (only) them.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 10 Dec 2002 09:13:25 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: The black list: websites banned on Google
Message-Id: <slrnavc14l.25h.tadmc@magna.augustmail.com>
Vincent Granville <vincentg@datashaping.com> wrote:
> Please help us build this directory of blacklisted websites by sending
> your contribution.
According to your instructions for identifying blacklisted websites,
this one is blacklisted:
www.imblacklisted.com
> selling Perl scripts.
Self-serving commercial posts are not welcomed in this newsgroup.
Please don't spam us anymore.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Dec 2002 07:31:10 -0800
From: bsma1@hotmail.com (bsma1)
Subject: unknown import: lib Calc at C:/Perl/lib/Math/BigInt.pm
Message-Id: <37959503.0212100731.32c197e4@posting.google.com>
Hello,
I'm a relative newbie to Perl. What I want to do is use large integers
(64 bit) in a script I'm writing. I have downloaded and installed all
the Math::BigInt, Bit::Vector, and anything I thought was/is related.
I have the line "use bigint;", but I still get the error: "unknown
import: lib Calc at C:/Perl/lib/Math/BigInt.pm". Can anyone help me,
or point me in the right direction? Thanks for any and all help
------------------------------
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 4241
***************************************