[11309] in Perl-Users-Digest
Perl-Users Digest, Issue: 4909 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 16 17:07:11 1999
Date: Tue, 16 Feb 99 14:00:28 -0800
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, 16 Feb 1999 Volume: 8 Number: 4909
Today's topics:
Re: /i in regexp kills performance. (Larry Rosler)
Re: /i in regexp kills performance. <uri@ibnets.com>
Re: /i in regexp kills performance. (Ilya Zakharevich)
Re: /i in regexp kills performance. (Ilya Zakharevich)
Re: /i in regexp kills performance. <uri@ibnets.com>
[Q] Passing an object to a subroutine, DBI <gary@onegoodidea.com>
[win32] ppm hangs during update of xml-parser package ! (muzo)
Byte Code Compiler <nospam@rayhammer.com>
directorys in PERL <flyboy1111@my-dejanews.com>
Re: directorys in PERL (Larry Rosler)
E-mail CGI script <bootc@worldnet.fr>
Here-docs: indenting closing token <ekkis@arix.com>
Re: I Need Help With a Process Pipe <rbobo@spd.dsccc.com>
Re: ip address search unspam@kj.imediat.com
Re: Is there a perl script for finding out who fingered unspam@kj.imediat.com
LWP for NYTimes access?? newsmf@bigfoot.com
Re: MySQL Perl Interface (Steve Linberg)
OFF TOPIC: My apologies on multiple answers unspam@kj.imediat.com
Re: PFR: UTC_to_Epoch <tam@silk.gsfc.nasa.gov>
pos() and $1, $2, $3... (Peter Palfrader)
Re: pos() and $1, $2, $3... (Ilya Zakharevich)
ReadParse confusion (Curtiss Hammock)
Re: REGEX $1, $2 ... array? (Larry Rosler)
Re: REGEX $1, $2 ... array? <rra@stanford.edu>
removing blank lines in a multiline string? <ekkis@arix.com>
Re: rename files with perl unspam@kj.imediat.com
Re: String Compare unspam@kj.imediat.com
use Module inside a Safe? <matt@weborder.com>
Variable interpolation w/regex <barry@smtek.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Feb 1999 12:30:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: /i in regexp kills performance.
Message-Id: <MPG.1133752bd9b4a58c989a4b@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7acid0$h1h$1@mathserv.mps.ohio-state.edu> on 16 Feb 1999
19:54:08 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler
> <lr@hpl.hp.com>],
> who wrote in article <MPG.113369da3b38750f989a49@nntp.hpl.hp.com>:
> > > It is not mentioned since there is no extra copying associated with //i.
> >
> > Now I have access to the books. You can argue with Jeffrey Friedl
>
> We have nothing to argue about.
>
> > , not
> > me. Here is a quote from 'Mastering Regular Expressions', page 278:
> >
> > The Efficiency Penalty of the /i Modifier
>
> As I explained it many times here, the Perl-specific part of Hip Owl
> has very little to do with the contemporary Perl.
Well, in any case whether or not it is due to extra copying, the
performance penalty persists -- or is this not a 'contemporary Perl'?
This is perl, version 5.005_02 built for MSWin32-x86-object
Copyright 1987-1998, Larry Wall
Binary build 506 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 15:40:37 Oct 27 1998
#!/usr/local/bin/perl -w
use Benchmark;
$x = 'x' x 100;
timethese(1 << (shift || 0), {
No_i => sub { $x =~ /AbCdEfG/ },
With_i => sub { $x =~ /AbCdEfG/i },
});
__END__
Benchmark: timing 262144 iterations of No_i, With_i...
No_i: 3 wallclock secs ( 1.66 usr + 0.00 sys = 1.66 CPU)
With_i: 13 wallclock secs (11.88 usr + 0.00 sys = 11.88 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Feb 1999 15:43:05 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: /i in regexp kills performance.
Message-Id: <39ww1iulk6.fsf@ibnets.com>
>>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
IZ> [A complimentary Cc of this posting was sent to Larry Rosler
IZ> <lr@hpl.hp.com>], who wrote in article
IZ> <MPG.113369da3b38750f989a49@nntp.hpl.hp.com>:
>> > It is not mentioned since there is no extra copying associated
>> with //i.
>>
>> Now I have access to the books. You can argue with Jeffrey Friedl
IZ> We have nothing to argue about.
>> , not me. Here is a quote from 'Mastering Regular Expressions',
>> page 278:
>>
>> The Efficiency Penalty of the /i Modifier
IZ> As I explained it many times here, the Perl-specific part of Hip
IZ> Owl has very little to do with the contemporary Perl.
and as i have rebutted, that may be true for some efficiency issues and
bleeding edge features but overall it is still educational and valuable
(just not to you :-). just look at your recent comment on @+ and @- which
are not in ANY released version of perl, only in maintenance releases of
5.003_*
and if you think the book is so outdated, write a proper errata for it
and publish it. we are all interested in how the well known but maybe
false $& and /i efficiency issues (and others) are handled and with
which real version. we have seen snippets of things in the groups but
nothing comprehensive as MRE has written. you don't even have to rewrite
the chapter (100 pages) just a set of notes with the improvements, which
versions have them, and efficiency issues. then you can stop complaining
about hip owls being out of date.
even better, tell o'reilly you want to edit/write the new edition. i
know they would love to put out one, as they have said so.
and as a final note, there are many 5.004_04's out there which have few
of your new features so MRE is still fairly accurate for that.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: 16 Feb 1999 20:58:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: /i in regexp kills performance.
Message-Id: <7acm6i$j5i$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@ibnets.com>],
who wrote in article <39ww1iulk6.fsf@ibnets.com>:
> IZ> As I explained it many times here, the Perl-specific part of Hip
> IZ> Owl has very little to do with the contemporary Perl.
>
> and as i have rebutted, that may be true for some efficiency issues and
> bleeding edge features but overall it is still educational and valuable
But not Perl-*specific* parts. Perl-related parts: yes.
Perl-specific parts: useless.
> (just not to you :-). just look at your recent comment on @+ and @- which
> are not in ANY released version of perl, only in maintenance releases of
> 5.003_*
There are 6 *released* versions of 5.005_5*. And the released
versions of 5.0050* are much closer to being destructive than
5.005_5[34].
> then you can stop complaining
> about hip owls being out of date.
Why are you putting words in my mouth? I never complained about Hip
Owl. (It is a very good book if you want to discuss 5.002.) All I
did was I commented on this book.
> and as a final note, there are many 5.004_04's out there which have few
> of your new features so MRE is still fairly accurate for that.
Hip Owl documents 5.002. 5.004_04 is *ways* ahead of Hip Owl.
Ilya
------------------------------
Date: 16 Feb 1999 20:51:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: /i in regexp kills performance.
Message-Id: <7aclo9$iss$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.1133752bd9b4a58c989a4b@nntp.hpl.hp.com>:
> > As I explained it many times here, the Perl-specific part of Hip Owl
> > has very little to do with the contemporary Perl.
>
> Well, in any case whether or not it is due to extra copying, the
> performance penalty persists -- or is this not a 'contemporary Perl'?
We were not discussing performance penalty, but string copying.
As to performance penalties, I repeat mine again: everybody is welcome
to update fbm_*() routines so that they work with case-folding (the
API already allows putting flags there). Covering no-locale case is
enough for the time being.
Ilya
------------------------------
Date: 16 Feb 1999 16:12:09 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: /i in regexp kills performance.
Message-Id: <39vhh2uk7q.fsf@ibnets.com>
>>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
>> (just not to you :-). just look at your recent comment on @+ and @-
>> which are not in ANY released version of perl, only in maintenance
>> releases of 5.003_*
IZ> There are 6 *released* versions of 5.005_5*. And the released
IZ> versions of 5.0050* are much closer to being destructive than
IZ> 5.005_5[34].
those are still maintenence versions. not stable released versions. so
my point is valid. anything with a _5* is NOT for mass consumption.
IZ> Why are you putting words in my mouth? I never complained about
IZ> Hip Owl. (It is a very good book if you want to discuss 5.002.)
IZ> All I did was I commented on this book.
>> and as a final note, there are many 5.004_04's out there which have
>> few of your new features so MRE is still fairly accurate for that.
IZ> Hip Owl documents 5.002. 5.004_04 is *ways* ahead of Hip Owl.
as compared perl 5 vs. perl4? you seem to forget that most (and i mean
MOST) perl programs and programmers never use most of the newer features
in regexes that you so love. i have seen countless examples on the net
and in source and they barely exceed perl4 regex stuff. just showing
someone /x blows them away. the fact that MRE covers 5.002 is key since
it is not perl4. that is the great leap in regex stuff. name some
mainstream (and i mean something regular perl hackers or newbies would
use) features of 5.004_04. even then, most regex problems can be solved
with the subset of MRE. and MRE explains how to use per regex better
than any other document. so its value for perl far outweighs any
obsolescence factor. it teaches what you need to knwo to use perl5 regex
well. if you want to know more, read perlre from whatever release you
have. and stay away from 5.003_* features until the subversion is 0*
and ilya, please stop cc'ing me. it isn't stealth but you know i read
the groups and i always read followups to my posts.
uri
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Tue, 16 Feb 1999 21:15:48 -0000
From: "Gary O'Keefe" <gary@onegoodidea.com>
Subject: [Q] Passing an object to a subroutine, DBI
Message-Id: <7acn5j$skb$1@plug.news.pipex.net>
I've been trying to write a script to connect up to an Oracle DB (using DBI)
and extract info. I've subdivided the task into subroutines and I want to
pass the database handle into the subroutines where sets of queries will be
executed but when I try to prepare the query I'm told that I can't execute
prepare on an unblessed reference. I have searced through the manual pages
(both the standard perl ones and the DBI ones) and can't find any recipes or
examples to do this. I can't show exactly what my code looks like (security
and stuff, dontcha know - the number of times I've seen folk post their
passwords in their code examples here...) but the salient points are:
$dbh_dc = connect( [connection stuff] ) ||
die ( "Failed to conect to DB.\n" );
[...]
@dc_supplier_dets = get_dc_supplier_dets ( $dbh_dc, $mpan ); # $mpan is a
ref no for the query
[...]
sub get_dc_supplier_dets {
my ( $dbh_dc );
my ( $mpan );
[misc local variable definitions...]
$dbh_dc = shift;
$mpan = shift;
$c_supplier = [query]
$dbh_dc -> prepare ( $c_supplier ) ||
die ( "Could not prepare query for supplier info.\n" );
[more stuff]
}
And, as I said, the code falls over at $dbh_dc -> prepare. Why do I feel
like I'm making a really basic mistake? I tried blessing the local $dbh_dc
but couldn't work out what I should have blessed it with.
Gary
--
Gary O'Keefe
gary@onegoodidea.com
http://www.onegoodidea.com/
------------------------------
Date: 16 Feb 1999 13:52:36 PST
From: muzok@nospam.pacbell.net (muzo)
Subject: [win32] ppm hangs during update of xml-parser package !!!
Message-Id: <36cde8d8.88595693@news.concentric.net>
hi,
I am running activestate perl 509 on NT 4.0 SP4. I ran ppm and it said that there
was an update to the xml-parser package. When I say install xml-parser, ppm hangs
with perl consuming %100 CPU. Any idea why? I thought about removing xml-parser
but ppm says that PPM package depends on it so it can't be removed. Is it
possible that this dependency is causing the problem ? How does one install a
package without using PPM ?
thanks
muzo
Verilog, ASIC/FPGA and NT Driver Development Consulting (remove nospam from email)
------------------------------
Date: Tue, 16 Feb 1999 15:24:36 -0500
From: "R.J. Russell" <nospam@rayhammer.com>
Subject: Byte Code Compiler
Message-Id: <36C9D404.100BA220@rayhammer.com>
I've heard rumors that it's possible to "compile" a perl text source
script to byte code. How does one do this / where is the documentation?
All I can seem to find is a one-liner in perlsec.
All I'm trying to do is hide the source code from the prying eyes of
non-programmers, not any real attempt at serious security. Any other
suggestions of methods to do this are also appreciated.
TIA
R.J.
------------------------------
Date: Tue, 16 Feb 1999 20:03:57 GMT
From: FlyBoy <flyboy1111@my-dejanews.com>
Subject: directorys in PERL
Message-Id: <7aciv6$a8e$1@nnrp1.dejanews.com>
simple question: whats a good, quick way to assign a numeric variable with
the amount of files in a given directory?
Thanks!
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 12:40:06 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: directorys in PERL
Message-Id: <MPG.1133777d90277a6c989a4c@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7aciv6$a8e$1@nnrp1.dejanews.com> on Tue, 16 Feb 1999
20:03:57 GMT, FlyBoy <flyboy1111@my-dejanews.com> says...
> simple question: whats a good, quick way to assign a numeric variable with
> the amount of files in a given directory?
perldoc -f opendir
perldoc -f readdir
perldoc -f grep
You can use the result of grep (in scalar context) to eliminate entries
you may not consider to be 'files' (such as the pseudo-directories '.'
and '..' or any real directories). If you use any of the file tests
such as '-f', make sure they operate on the name relative to the current
directory, or on an absolute file path.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 16 Feb 1999 22:03:45 +0100
From: "Chris Boot" <bootc@worldnet.fr>
Subject: E-mail CGI script
Message-Id: <7acmfg$9gv$1@news4.isdnet.net>
Hi,
I NEED and easy to use emailer CGI script that is platform independent
(I.E. uses sockets instead of sendmail).
Please reply to email address below.
--
Chris Boot
Vice President of
The Macintosh Discovery Club
mactech.tmdc@worldnet.fr
http://www.tmdc.org/
http://www.tmdc.org/mactech/
PS: Explore your Mac!
------------------------------
Date: Tue, 16 Feb 1999 13:31:37 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: Here-docs: indenting closing token
Message-Id: <Srly2.4466$bP2.39300@typhoon-sf.pbi.net>
In Korn we are used to doing:
echo <<-EOF
text
text
EOF
Korn kindly ignores whitespace before the closing token when you say <<-TOK
which is nice since you can nicely indent all your code. In Perl it seems
that the closing token HAS to be flush to the left, making your code ugly
like this:
print <<EOF;
text
text
EOF
ok, so you can say:
print <<" EOF";
text
text
EOF
...but the tab worries me because you change the level of
indentation of the code or if the source file has it's tabs
converted to spaces (as sometimes happens), the print will break.
is there a nice alternative?
- e
------------------------------
Date: Tue, 16 Feb 1999 13:52:41 -0600
From: Richard Bobo <rbobo@spd.dsccc.com>
Subject: Re: I Need Help With a Process Pipe
Message-Id: <36C9CC89.7801933@spd.dsccc.com>
FYI:
I solved my own problem with another approach. Rather than using
a process pipe, I used the system operator with the UNIX rsh command
and that worked. Happy coding...
Richard Bobo
*** The opinions expressed are not those of Alcatel USA, Inc ***
------------------------------
Date: Tue, 16 Feb 1999 20:50:01 GMT
From: unspam@kj.imediat.com
Subject: Re: ip address search
Message-Id: <7aclll$clp$1@nnrp1.dejanews.com>
In article <36C88710.1E64916E@wou.edu>,
Roger Kaye <kayer@wou.edu> wrote:
> I'm a newbie and trying to write a script on a unix server to poll ip
> address within
> a given range to test if they ping. Then I need to test each connection
> to see if any are set up as Web servers.
>
> Thanks
>
> Roger
First off, you might want to look at the documentation for the Net::Ping
module. Although (correct me if I'm wrong) it implements a TCP ping (rather
than ICMP), it is still effective to figure out if a host is available --
perhaps moreso, as it should work through firewalls where ICMP may not pass.
As far as testing for webservers there are a few ways you could do
that. The first, and perhaps most obvious is to check for a successful
connect to TCP port 80. If a connection is successful (not refused), it is
most likely that a webserver is using the port. You may also want to try
ports 8000 and 8080, which are alternative ports, but used much more rarely.
Another (far less friendly) method would be to do a TCP port scan and
issue a HTTP GET request on each successful connection and monitor the return
(if any) from the listener. This has the benefit of finding *all* webservers
running on a machine, but may also cause problems on the target machine. It
will also seriously anger the system/security admin, so I *DO NOT* recommend
this, unless you happen to be the person in charge of the intended target(s).
I believe there is likely enough sample code for opening TCP
connections, so I won't include any here.
Cheers,
~kj
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 20:34:09 GMT
From: unspam@kj.imediat.com
Subject: Re: Is there a perl script for finding out who fingered me???
Message-Id: <7acko1$buo$1@nnrp1.dejanews.com>
In article <slrn7cgtri.ei.efflandt@efflandt.xnet.com>,
efflandt@xnet.com wrote:
> On Mon, 15 Feb 1999 03:37:51 -0600, seong joon bae
> <seongbae@students.uiuc.edu> wrote:
> >Hello, everyone.
[snip]
> >I have been trying to figure out a perl script that shows me who have
> >fingered me.
> >Is that possible?
> >If so, can someone tell me how...?
> >you can email me at seongbae@uiuc.edu
[snip]
> But as a user I think there is something in 'man perlipc' or one of
I believe this is covered (albeit not in Perl) in either the
comp.unix or comp.unix.shell FAQ. I think it's given in shell script, but
the conversion to Perl is trivial.
Cheers,
~kj
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 20:03:34 GMT
From: newsmf@bigfoot.com
Subject: LWP for NYTimes access??
Message-Id: <7aciue$a81$1@nnrp1.dejanews.com>
I'm posting this again because the subject line didn't give much info in the
original posting. If anyone can help with the problem below that would be
great.
Thx,
Marc
In article <7aavn6$ti5$1@nnrp1.dejanews.com>,
newsmf@bigfoot.com wrote:
> Hi there -
>
> I wrote a little perl program that fetches a NYT page for me (the pages work
> with passwords; accessing them with a browser, they display a "first time
> user" page if no password is supplied of if there's no cookie, I guess).
>
> My problem: sometimes it gets the real page, sometimes it gets the page for
> first time users. I'm really confused because the behavior seems quite random.
>
> Can anyone help?
>
> Thanks for helping and cheers from South Beach,
>
> Marc.
>
> Here's the code:
>
> #!/usr/local/bin/perl
>
> require "httools.pl";
> require "cgi-lib.pl";
> use LWP::Simple;
> use LWP::UserAgent;
> use HTTP::Request;
> use HTTP::Response;
>
> $url= "http://www.nytimes.com/yr/mo/day/news/world/";
>
> $userid ="231q7";
> $password= "032e4";
>
> $ua = new LWP::UserAgent;
>
> $req = new HTTP::Request 'GET',"$url" || die "$!";
> $ua->agent('Mozilla/4.03');
> $req->authorization_basic($userid, $password);
> $res = $ua->request($req) || die "$!";
> &header;
> print $res->content if $res->is_success;
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 20:48:52 GMT
From: slinberg@crocker.com (Steve Linberg)
Subject: Re: MySQL Perl Interface
Message-Id: <slinberg-1602991548530001@cc11620-a.lwmrn1.pa.home.com>
In article <7aaeur$fq1$1@nnrp1.dejanews.com>, Bosco Tsang
<bosco@ipoline.com> wrote:
> /usr/lib/crt1.o: In function `_start':
> /usr/lib/crt1.o(.text+0x57): undefined reference to `main'
>
> Anyone got an idea on how to fix this? Or, know where can I obtain a workable
> copy of Msql-Mysql-modules-1.2017 for RedHat 4.2?
My first suggestion would be to upgrade to 5.2. Failing that, you'll
probably need to update your gcc to 2.7.2.3. There may be other things
wrong, but I'd start there.
MySQL and the DBI stuff is a cinch on RH 5.2; I compiled from source and
everything is going swimmingly.
------------------------------
Date: Tue, 16 Feb 1999 21:01:20 GMT
From: unspam@kj.imediat.com
Subject: OFF TOPIC: My apologies on multiple answers
Message-Id: <7acmaq$dgr$1@nnrp1.dejanews.com>
Hello folks,
My apologies for re-answering questions here. I will arrange to use
a threaded newsreader (as opposed to dejanews) from here on in.
Sorry 'bout that,
~kj
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 14:24:52 -0500
From: Tom McGlynn <tam@silk.gsfc.nasa.gov>
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <36C9C604.96D44FCB@silk.gsfc.nasa.gov>
Shouldn't this code at least mention that it
does not address leap-seconds?
Tom McGlynn
tam@silk.gsfc.nasa.gov
------------------------------
Date: Tue, 16 Feb 1999 20:23:13 GMT
From: palfrader@usa.net (Peter Palfrader)
Subject: pos() and $1, $2, $3...
Message-Id: <36c9d306.6731604@news.uibk.ac.at>
If I do a regexp search in a string ($str =~ m/regex/g), I can
determine where the matched string was with pos($str),
which returns, where the last m//g left off and with $& which is the
matched string, so I have
$startpos = pos($str) - length($&)
If the regex has pairs of parentheses (), I have the matched
substrings in \1, \2, \3... or $1, $2, $3...
Now my questions:
Is there a function similar to pos() to find out, where these
substrings start/end in the "big" string ($src)?
I hope someone can help. TIA
--
Weasel mailto:palfrader@writeme.com
-----------------------------------------------------------------
"With a rubber duck, one's never alone"
-- The Hitchhiker's Guide to the Galaxy
------------------------------
Date: 16 Feb 1999 20:37:53 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: pos() and $1, $2, $3...
Message-Id: <7ackv1$iev$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Peter Palfrader
<palfrader@usa.net>],
who wrote in article <36c9d306.6731604@news.uibk.ac.at>:
> Is there a function similar to pos() to find out, where these
> substrings start/end in the "big" string ($src)?
I answered it just yesterday. Use @+, @-. (And a bleeding-edge perl
- we got a new one today.)
Ilya
------------------------------
Date: Tue, 16 Feb 1999 21:41:56 GMT
From: curtiss@desertisle.com (Curtiss Hammock)
Subject: ReadParse confusion
Message-Id: <36c9e441.10445507@nntp4.mindspring.com>
I admit it, I'm a novice at this. I'm trying to take a Username from
an HTML form and redirect to a specific web page with PERL.
If the user enters "byteme," he should be redirected to a page in the
"byteme" directory.
If I'm understanding the ReadParse thing correctly, the username
should wind up stored as a string in the $val variable. But for
reasons that elude me, I am unable to use that variable to redirect.
The script, as is, gets me the error page.
Any hints would be greatly appreciated.
Here's the form:
<form action="/cgi-bin/user.pl">
<p><input type="Text" name="username" size="20" maxlength="15"></p>
</form>
And here's the script. Included in my script, but not reproduced here,
is the CGI-LIB.PL.
#!/usr/bin/perl
&ReadParse;
if ($val eq "hyperdyne"){
print "Location:
http://www.website.com/usertest/hyperdyne/index.html\n\n";
}
elsif ($val eq "byteme"){
print "Location:
http://www.website.com/usertest/byteme/index.html\n\n";
}
else{
print &PrintHeader;
print<<"print_tag";
<html>
<head>
<title>Sorry, try again</title>
</head>
<body BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800040
ALINK=#800040>
<P><center>Sorry, the user name you entered is not
valid.<P><BR><P><BR>
"$val"
print_tag
exit 0;
}
Thanks a lot,
Curtiss
------------------------------
Date: Tue, 16 Feb 1999 11:54:30 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <MPG.11336cd024e5e6e2989a4a@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <tg3e46duqt.fsf@noise.bsd.uchicago.edu> on Tue, 16 Feb 1999
19:16:42 GMT, Darrin Edwards <d-edwards@nospam.uchicago.edu> says...
> "William H. Asquith" <asquith@macconnect.com> writes:
...
> my @keys;
> $Input_string =~ s/{(\w+)}/push (@keys, $1);
> $Matches{$1}/gex;
>
> So I had a string, and wanted to replace instances of "{KEY}"
> with the corresponding value in a given hash, while remembering
> the keys that had matched. Looks a bit silly perhaps, and probably
> far from being the best way to do this, but it's the first time
> I've ever needed (wanted?) to use the /x switch on the s// operator.
But why did you need (want) to use the /x switch on the s// operator?
It allows white space and comments within the regex, but there are none.
You may have been thinking of the white space in the substitution, but
that is irrelevant, as it is within a Perl expression; in any case, /x
wouldn't affect the substitution part in any way.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Feb 1999 12:05:10 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <ylaeyeazd5.fsf@windlord.stanford.edu>
Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> Russ Allbery <rra@stanford.edu>:
>> I, like thousands of other users of Perl, have no need for h2ph for any
>> of the Perl scripts we run. I don't use Sys::Syslog, or any other
>> module that requires it. And 5.005_02 is running well enough on
>> Solaris to handle posting duties for comp.lang.perl.moderated.
> I'm very glad you enjoy your installation of Perl. ;-)
Me too. :)
> However, this does not fix things which are broken. I got *very* hot
> mail from our system administrator after he spend enormous time trying
> to switch to 5.005_02 (as a result, we are running 5.005_54 - he could
> not go back to 5.004 - per users' requests?).
It's been my experience that upgrading versions of Perl always tends to be
a bit rocky. It's not really because of bugs; it's because of the sheer
quantity of things that depend on Perl, and often depend on more specific
behavior of Perl than people realized when they wrote them originally.
> And after an upgrade my *only* Perl script I use frequently at work (one
> for posting to p5p) broke - per __sparc being undefined. Hmm, probably
> it broke due the switch to Solaris 7, it just happened that the .ph
> files were recompiled only during the upgrade to 5.005*.
That may have been it. In any case, h2ph works well enough for me that
Sys::Syslog works, although I don't use it. h2ph has always been a crap
shoot at best; it's gotten much better in the development versions of
Perl, but even still trying to parse C headers with something other than a
C preprocessor is always going to be tricky.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Tue, 16 Feb 1999 13:38:29 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: removing blank lines in a multiline string?
Message-Id: <iyly2.4467$bP2.38475@typhoon-sf.pbi.net>
I know, this sounds like something well covered in the FAQs but I've read
and struggled with this and can't seem to figure it out. Suppose I have:
$s = <<EOF;
this
and
that
and
these
EOF
and when I "print $s" I want:
"this
and
that
and
these"
...what would be a good regexp to do this? I've tried "s/\n+/\n/g;" but
that still leaves with:
"
this
and
that
and
these
"
and short of converting it to an array and recomposing the string (yuk!) I
think there must be some clever way to do this
thx - e!
------------------------------
Date: Tue, 16 Feb 1999 20:53:42 GMT
From: unspam@kj.imediat.com
Subject: Re: rename files with perl
Message-Id: <7aclsi$d0v$1@nnrp1.dejanews.com>
In article <36C88DF8.2214E797@mercuryfilmworks.com>,
Derrick MacPherson <derrick@mercuryfilmworks.com> wrote:
> I am in need of a huge hand, I was wondering if someone can help me.
> I am needing to rename a list of files. The files are in the format
> ?-*.pnt and ?-*.scan (so m-31.pnt and m-31.scan)
>
> I would like at least to be able to change the first character to a
> different letter.
>
> Bonus points if it can include moving directories, and flexibility..
>
> Thanks.
If you check the perlfunc manpage you will find the function 'rename'. It
doesn't work across filesystem boundaries, but it should do the rest of what
you're looking for.
Cheers,
~kj
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 20:28:54 GMT
From: unspam@kj.imediat.com
Subject: Re: String Compare
Message-Id: <7ackdp$bhh$1@nnrp1.dejanews.com>
In article <36C87877.B0F54B60@btv.ibm.com>,
"Paul J. Sala" <psala@btv.ibm.com> wrote:
> I'm trying to construct a REGX that will determine if
> a string contains a character other than
> these: a-z A-Z 0-9 @ . _ -
>
> I tried:
> if ($MyStr =~
> /[\W\@\._-]+/)
> { dosomething; }
>
else
> { dosomethingelse; }
>
> But it didn't work. Any suggestions.
if ($my_str =~ m/[^a-z0-9-_\.\@]/i) {
# actions of it contains other characters
}
else {
# actions if it only has the okay characters
}
The above should do the trick -- I haven't fully tested it, so beware.
Cheers,
~kj
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 16 Feb 1999 12:32:50 -0800
From: Matt Feiszli <matt@weborder.com>
Subject: use Module inside a Safe?
Message-Id: <36C9D5F2.55EFCF50@weborder.com>
Hi,
Is it possible to reval() code inside a Safe, if the code uses functions
imported from other modules? I'd like to to something like this:
################################################
#!/usr/local/bin/perl -w
use strict;
use Safe;
my $s = new Safe();
$s->deny_only(); # or whatever we disallow, nothing right now
#$s->share('@INC', '%INC'); # doesn't seem to make a difference
# now, both of these statements here set $@ to the same error message
# which is 'Unable to create sub named "*Safe::Root0::vanilla" at...'
# SomeLib is in the same directory and will export the function vanilla,
# which contains one print statement.
$s->reval('
use SomeLib qw(vanilla);
&vanilla;
');
$@ && print "reval(): $@";
# untrusted.pl contains the same two lines we reval() above
$s->rdo('untrusted.pl');
$@ && print "rdo(): $@";
################################################
Can anyone tell me what's going on? I suspect what I'd like to do is
sort of contrary to the whole idea of Safe, which protects namespaces,
but maybe I've just missed something. If I do 'perl untrusted.pl' it
works fine. When I look at the symbol table for Safe::Root0:: it seems
like the "use SomeLib..." does create an entry for the 'vanilla' sub,
but I am not familiar enough with symbol tables to know what's going
on. Any help would be appreciated.
Thanks,
Matt
------------------------------
Date: Tue, 16 Feb 1999 13:38:18 -0800
From: "Barry Brevik" <barry@smtek.com>
Subject: Variable interpolation w/regex
Message-Id: <7aco6u$9sq$1@news-1.news.gte.net>
I'm having a problem with regular expressions and variable interpolation. I
want
to use a file to store regular expression patterns which are then used to
search
other files to determine if that pattern can be matched. Here is a
simplified example
where $inbuf would actually hold the contents of the file under test:
open(FHWL,"wordlist.txt") || die "Could not open wordlist: $!";
chomp (@wl = <FHWL>);
close(FHWL);
$inbuf = "the quick
brown fox jumped over the lazy dog.";
foreach $test (@wl)
{
if ($inbuf =~ /\b($test)\b/i)
{
print "found with $1\n";
last;
}
}
This works fine where $test is a plain text string. BUT, I also want to
include entire regular
expressions in the wordfile, like "/start/ ... /end/" or any other
expression that includes the "/"
chars. IOW, if I try to do-
if ($inbuf =~ $test)
...where $test is "/pattern/g" (for example), it does not work. Is there
any way
to get around this?
-bbb (Barry Brevik - barryb@smtek.com)
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4909
**************************************