[16062] in Perl-Users-Digest
Perl-Users Digest, Issue: 3474 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 25 06:05:29 2000
Date: Sun, 25 Jun 2000 03:05:12 -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: <961927512-v9-i3474@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 25 Jun 2000 Volume: 9 Number: 3474
Today's topics:
Re: $$variable_name help (Bart Lateur)
Activestate debug mode and PAGER produces Garbage Displ <PostNoEmail <i_am_not@erols.com>>
Can a regex pick out a domain name from a line of text? <robert@chalmers.com.au>
Can I chmod my scripts to an NT server? <mattrlNOmaSPAM@aol.com.invalid>
Re: Can I chmod my scripts to an NT server? <care227@attglobal.net>
Re: cgi/SSI question... (Abigail)
Concatenating with join() <mdemello@pound.ruf.rice.edu>
Re: Concatenating with join() <mdemello@pound.ruf.rice.edu>
Re: Concatenating with join() (Abigail)
Re: Concatenating with join() <mdemello@pound.ruf.rice.edu>
Get cgi url markqian@my-deja.com
Re: Get cgi url <rob13@rock13.com>
Re: Get cgi url (David Efflandt)
Get the matched position in regexp <abuse@localhost>
Re: Get the matched position in regexp (Bart Lateur)
Re: Hard Disk Serial# <andy@u2me3.com>
Re: Hard Disk Serial# (Abigail)
Re: How can I Use a Perl Script to FTP files automatica (Abigail)
How to measure time to milliseconds inside perl script (MrSpoon)
Re: How to measure time to milliseconds inside perl scr <sweeheng@usa.net>
Newbie qn: scope of Dir (file?) handles. <karra@cs.utah.edu>
Re: Newbie qn: scope of Dir (file?) handles. (Maurice E. Jarrell)
Re: oracle DB connection (Abigail)
perl + dll <mathusalem@free.fr>
Re: Perl and Web Security (v)
Re: Quick "Perl Way" solution needed <godzilla@stomp.stomp.tokyo>
Re: Quick "Perl Way" solution needed <you.will.always.find.him.in.the.kitchen@parties>
Re: Quick "Perl Way" solution needed <godzilla@stomp.stomp.tokyo>
Re: Repeated regex matching. <sweeheng@usa.net>
Re: Repeated regex matching. (Abigail)
Re: Repeated regex matching. <sweeheng@usa.net>
Re: Repeated regex matching. <ken@forum.swarthmore.edu>
Re: Repeated regex matching. nobull@mail.com
Re: Testing exit status (Charles DeRykus)
Using HTTP::Request::Form to get SELECT options <netnerds@bellsouth.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Jun 2000 09:36:27 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $$variable_name help
Message-Id: <3955c8ae.727261@news.skynet.be>
Drew Simonis wrote:
>> If I have the following variables:
>> my $aa = 10;
>> my $bb = 'aa';
>> I would expect $$bb to print 10. Instead it appears to be printing
>> nothing.
>
>Why do you expect that to be the case?
Drew, Drew, Drew... Don't tell me you've never heard of "symbolic
references"?
Too true, these shouldn't be used but for pretty advanced application,
such as Exporter, so I think it's a pitty that the syntax is so simple
-- and the same as with proper references, so you can even use it by
accident. True: { use strict 'refs'; } will disallow them, but that's a
little too late for my taste.
I wouldn't mind suymbolic references being banned from the Perl
language.
Since you can access $Foo::Bar::var through
${$::{'Foo::'}{'Bar::'}{'var'}} (you may use a loop to traverse the
stashes)), you don't actually ever need them, except that strict.pm
still doesn't seem to turn off it's alarm for names imported this way.
It should be obvious that you can only access variables in the symbol
tables, i.e. global variables, this way. But that is the case with
symbolic references too.
And that brings us back to the original problem: symbolic references
*only* work with global variables.
--
Bart.
------------------------------
Date: Sat, 24 Jun 2000 23:39:54 -0400
From: "Reinhold J. Gerharz" <PostNoEmail <i_am_not@erols.com>>
Subject: Activestate debug mode and PAGER produces Garbage Display
Message-Id: <slavoa8kjev175@corp.supernews.com>
I created a script, "perlpager.cmd" containing:
@cat >/perltmp.txt 2>&1
@start notepad \perltmp.txt >nul 2>&1
and set PAGER=perlpager.cmd
then run a perl script with the "-d" option. Typing
|V
or
||V
starts notepad as expected, but the Command Prompt window running the
debugger becomes useless! All subsequent lines of display overwrite the
lower-right corner character cell. (You can see it "flicker".) The line
leading up to it has some "garbage" characters.In other words, the console
mode has been screwed up!
Anyone know why? Or how to fix?
NOTES: The "cat" program probably came from one of the NT resource kits; I'm
running on Windows 2000; and I _do_ know better than to use "\" for temp
files. <G>
Thanks!
RG
------------------------------
Date: Sun, 25 Jun 2000 19:03:50 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: Can a regex pick out a domain name from a line of text?
Message-Id: <5Uj55.2$I97.555@nsw.nnrp.telstra.net>
Does anyone have a regex that can pick out a domain name from a line of text
please.
I can't work it out no matter how I try!!!
thanks for any help
Robert
------------------------------
Date: Sat, 24 Jun 2000 20:31:44 -0700
From: Matthew <mattrlNOmaSPAM@aol.com.invalid>
Subject: Can I chmod my scripts to an NT server?
Message-Id: <27d6d928.e5037cb7@usw-ex0108-061.remarq.com>
I am using Win98. I uploaded scripts to my clients ip, which
resides on an NT server. It won't let me use the chmod
command, and gives me an error '500 SITE CHMOD 755
script.cgi: command not understood'. Does NT use the chmod
command? Or do I have to change the permissions som other
way? Thanks
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Sat, 24 Jun 2000 23:38:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Can I chmod my scripts to an NT server?
Message-Id: <39557EB5.6FC1DF3A@attglobal.net>
Matthew wrote:
>
> I am using Win98. I uploaded scripts to my clients ip, which
> resides on an NT server. It won't let me use the chmod
> command, and gives me an error '500 SITE CHMOD 755
> script.cgi: command not understood'. Does NT use the chmod
> command? Or do I have to change the permissions som other
> way? Thanks
Absolutely nothing to do with Perl here, but since I'm using
bandwith to post that bit, I may as well knowck it out...
The chmod command is only implemented under WinNT if the admin has
installed the resource kit. Even if that has been done, its not
likely that they would let others use it, since its not really
necessary. The Windows model does not rely on a file mode to
determine if a file is executable, but rather on the file type
associations. So if you uploaded, say, a .pl file, perl would
be associated with that file type and run it.
Send an email to your admin, they should be able to set you on the
right path.
------------------------------
Date: 24 Jun 2000 22:22:05 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: cgi/SSI question...
Message-Id: <slrn8las8d.k60.abigail@alexandra.delanet.com>
Rich H (richh@panola.com) wrote on MMCDLXXXIX September MCMXCIII in
<URL:news:sl9frbp7e7f49@corp.supernews.com>:
() Alan J. Flavell <flavell@mail.cern.ch> wrote in message
() news:Pine.GHP.4.21.0006241235190.13905-100000@hpplus03.cern.ch...
() >
() > On Fri, 23 Jun 2000, Rich H added another specimen of upside-down
() > posting to the Usenet Hall of Shame with this:
() >
() > > If <!--#include virtual="/cgi-bin/whatever.cgi" --> doesn't work, try
() > > <!--#exec cgi="/cgi-bin/whatever.cgi" -->
() >
() > SSI is not standardised, so don't just "try this" at random - consult
() > the SSI documentation for the http server that you use, and then seek
() > advice on a group where it is on-topic.
() >
() > > > Before you buy.
() >
() > Er, no thanks.
() >
()
()
() Since when did this become comp.lang.perl.strict. What's the use of having
() perl on your site if you can't get it to work. This mans question may have
() been a little off topic but not far enough that it didn't deserve an answer.
Having perl on your site and not getting it to work isn't very useful.
I fail to see what that has to do with the original question. The
original question was totally Perl free; and hence off-topic in this
group. There are other groups better suited to deal with SSI problems.
() Which is worse, the original slightly off-topic post, or you absolutely
() meaningless , bandwidth wasting post which was better suited for
() comp.lang.arrogant.BS (which you should probably get back to moderating)?
The only person being arrogant, meaningless and bandwidth wasting in
this thread is you.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: 25 Jun 2000 02:52:57 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Concatenating with join()
Message-Id: <8j3s69$1s0$1@joe.rice.edu>
Why does the following piece of code suppress $_." "?
#!/usr/bin/perl -w
use strict;
while (<>)
{
chomp;
print $_." ".join('',sort(split //))."\n";
}
Everything from the join onwards gets printed without a problem.
--
Martin "JAPN" DeMello
------------------------------
Date: 25 Jun 2000 03:17:20 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: Concatenating with join()
Message-Id: <8j3tk0$1s0$2@joe.rice.edu>
Martin Julian DeMello <mdemello@pound.ruf.rice.edu> wrote:
> {
> chomp;
> print $_." ".join('',sort(split //))."\n";
> }
>
> Everything from the join onwards gets printed without a problem.
Got it (sort of) - the input file was a dos file; converting it to unix
fixed the problem. Still no idea what difference that made, though.
--
Martin DeMello
------------------------------
Date: 25 Jun 2000 00:52:51 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Concatenating with join()
Message-Id: <slrn8lb532.ka1.abigail@alexandra.delanet.com>
Martin Julian DeMello (mdemello@pound.ruf.rice.edu) wrote on MMCDXC
September MCMXCIII in <URL:news:8j3tk0$1s0$2@joe.rice.edu>:
<> Martin Julian DeMello <mdemello@pound.ruf.rice.edu> wrote:
<> > {
<> > chomp;
<> > print $_." ".join('',sort(split //))."\n";
<> > }
<> >
<> > Everything from the join onwards gets printed without a problem.
<>
<> Got it (sort of) - the input file was a dos file; converting it to unix
<> fixed the problem. Still no idea what difference that made, though.
I bet you printed it to the screen.
Because it was a DOS file, the line ended with a CR LF pair. You chomp()
the LF off, leaving a trailing CR at the end of $_.
So, print() prints $_, ending in a CR. And then your terminal driver does
what it's suppose to do on a CR: it returns the "carriage". But there's
no line feed. Hence, the " " . join ("", sort //) parts overwrites what
was already there.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 25 Jun 2000 05:06:39 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: Concatenating with join()
Message-Id: <8j440v$69g$1@joe.rice.edu>
Abigail <abigail@delanet.com> wrote:
> I bet you printed it to the screen.
> Because it was a DOS file, the line ended with a CR LF pair. You chomp()
> the LF off, leaving a trailing CR at the end of $_.
> So, print() prints $_, ending in a CR. And then your terminal driver does
> what it's suppose to do on a CR: it returns the "carriage". But there's
> no line feed. Hence, the " " . join ("", sort //) parts overwrites what
> was already there.
Ah! Thanks muchly - I've never actually thought about what a 'carriage
return' implied; I always assumed the term was a leftover from the teletype
era.
--
Martin DeMello
------------------------------
Date: Sun, 25 Jun 2000 07:54:53 GMT
From: markqian@my-deja.com
Subject: Get cgi url
Message-Id: <8j4dsa$580$1@nnrp1.deja.com>
How can I get the url of the cgi?
For example, if I run
http://www.my-site.com/cgi-local/my-script.cgi?action=xxx
How can I get
http://www.my-site.com/cgi-local/my-script.cgi
from the cgi?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 04:05:57 -0400
From: "Rob - Rock13.com" <rob13@rock13.com>
Subject: Re: Get cgi url
Message-Id: <3955BD65.DBB94943@rock13.com>
markqian@my-deja.com wrote:
>
> How can I get the url of the cgi?
>
> For example, if I run
>
> http://www.my-site.com/cgi-local/my-script.cgi?action=xxx
>
> How can I get
>
> http://www.my-site.com/cgi-local/my-script.cgi
>
> from the cgi?
Its one of the environment variables, don't recall which one.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: 25 Jun 2000 08:27:02 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Get cgi url
Message-Id: <slrn8lbgi7.m7c.efflandt@efflandt.xnet.com>
On Sun, 25 Jun 2000, markqian@my-deja.com <markqian@my-deja.com> wrote:
>How can I get the url of the cgi?
>
>For example, if I run
>
>http://www.my-site.com/cgi-local/my-script.cgi?action=xxx
>
>How can I get
>
>http://www.my-site.com/cgi-local/my-script.cgi
>
>from the cgi?
On a system with Perl type: perldoc CGI
#!/usr/bin/perl
use CGI qw/:standard/;
print header,start_html('URL Test'),
"The URL of this script is ",url(),
end_html;
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Sun, 25 Jun 2000 16:16:30 +0800
From: "multiplexor" <abuse@localhost>
Subject: Get the matched position in regexp
Message-Id: <8j4emg$jhs3@imsp212.netvigator.com>
Is it possible to get the position of the matched part in a string?
For example:
$_ = 'ABCDE';
if (/C/) {
print "C is at the 3rd character".
}
How do I get the position of C in $_ ?
Thanks
------------------------------
Date: Sun, 25 Jun 2000 09:36:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Get the matched position in regexp
Message-Id: <3956ce65.2190244@news.skynet.be>
multiplexor wrote:
>$_ = 'ABCDE';
>if (/C/) {
> print "C is at the 3rd character".
>}
>
>How do I get the position of C in $_ ?
You can use the pos() function, but it only works if the pattern is
matched with the //g modifier.
$_ = 'ABCDE';
/C/g and print "Match with pos at @{[pos]}\n";
-->
Match with pos at 3
Note that this is the index of the pos pointer in the string AFTER the
matched pattern, so you need the length of the matched text. A decent
way to achiev that, is to put parens around the pattern, and get the
length of $1.
/(C)/g and print <<"#EOT#";
Match with pos at @{[pos]}
length of match = @{[length $1]}
#EOT#
-->
Match with pos at 3
length of match = 1
But do note that //g will influence where the pattern match will start
looking next time.
$_ = 'ABCDECE';
/(C)/g and print <<"#EOT#";
Match with pos at @{[pos]}
length of match = @{[length $1]}
#EOT#
/(C)/g and print <<"#EOT#";
Match with pos at @{[pos]}
length of match = @{[length $1]}
#EOT#
-->
Match with pos at 3
length of match = 1
Match with pos at 6
length of match = 1
Set pos to 0 if you don't want that to happen.
--
Bart.
------------------------------
Date: Sun, 25 Jun 2000 02:06:10 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Hard Disk Serial#
Message-Id: <8j3m0b$4ft$1@neptunium.btinternet.com>
Is there a more portable method available?
Thanks, Andy.
andy@u2me3.com
------------------------------
Date: 24 Jun 2000 23:13:29 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Hard Disk Serial#
Message-Id: <slrn8lav8p.ka1.abigail@alexandra.delanet.com>
Andy Chantrill (andy@u2me3.com) wrote on MMCDXC September MCMXCIII in
<URL:news:8j3m0b$4ft$1@neptunium.btinternet.com>:
,, Is there a more portable method available?
The screwdriver *is* the portable method.
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
------------------------------
Date: 24 Jun 2000 23:16:33 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: How can I Use a Perl Script to FTP files automatically
Message-Id: <slrn8laveg.ka1.abigail@alexandra.delanet.com>
fortbruce (bruceNObrSPAM@mccausland.com.invalid) wrote on MMCDLXXXVIII
September MCMXCIII in <URL:news:0a2211be.596a0f1e@usw-ex0105-034.remarq.com>:
.. I need some assistance setting-up a Perl script that will do the
.. following:
..
.. - Take files that are placed in a directory on a SUN UNIX box
.. (large photos) and FTP them to another UNIX machine in a
.. specific directory.
Net::FTP.
.. - After the file has been FTP'd, the original file can be
.. deleted (removed) from the source directory.
Either unlink(), or Net::FTP, depending on where the program is running.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: Sun, 25 Jun 2000 07:05:30 GMT
From: bretten@fuse.net (MrSpoon)
Subject: How to measure time to milliseconds inside perl script ?
Message-Id: <3956aef4.134106794@news.fuse.net>
Hi, does anyone know a way to measure time inside a script to the
millisecond ?
Thanks
MrSpoon - brettenNO@SPAMfuse.net
------------------------------
Date: Sun, 25 Jun 2000 15:47:03 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: How to measure time to milliseconds inside perl script ?
Message-Id: <8j4d1r$ap1$1@clematis.singnet.com.sg>
MrSpoon <bretten@fuse.net> wrote in message
news:3956aef4.134106794@news.fuse.net...
> Hi, does anyone know a way to measure time inside a script to the
> millisecond ?
You may find the Time::HiRes module at CPAN useful.
Swee Heng
------------------------------
Date: Sat, 24 Jun 2000 20:55:08 -0600
From: Sriram Karra <karra@cs.utah.edu>
Subject: Newbie qn: scope of Dir (file?) handles.
Message-Id: <3955748C.BE39D2D1@cs.utah.edu>
hi,
if I cant my() or local() them, how can I get teh following code to
work: (apart from explicitly maintaining a "stack" of dirhandles
(dirnames)).
sub recurse # lists all files in the dir recursively.
{
my($ar) = $_[0];
my($a);
print $ar, "\n";
if (-d $ar) {
opendir(THISDIR, $ar);
chdir $ar;
while (defined ($a = readdir(THISDIR))) {
if ($a ne "." && $a ne "..") {
recurse($a);
}
}
chdir "../";
}
}
and, why dont we want to allow my() of such?
-sriram.
------------------------------
Date: Sun, 25 Jun 2000 04:31:04 GMT
From: mejarrell@worldnet.att.net (Maurice E. Jarrell)
Subject: Re: Newbie qn: scope of Dir (file?) handles.
Message-Id: <m3k8fe4q9q.fsf@localhost.localdomain>
Sriram Karra <karra@cs.utah.edu> writes:
> sub recurse # lists all files in the dir recursively.
Try the File::Find module ( perldoc File::Find from your command
line. )
HTH,
Maury
> print $ar, "\n";
>
> if (-d $ar) {
> opendir(THISDIR, $ar);
> chdir $ar;
> while (defined ($a = readdir(THISDIR))) {
> if ($a ne "." && $a ne "..") {
> recurse($a);
> }
> }
> chdir "../";
> }
> }
>
> and, why dont we want to allow my() of such?
>
> -sriram.
------------------------------
Date: 24 Jun 2000 23:21:27 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: oracle DB connection
Message-Id: <slrn8lavnn.ka1.abigail@alexandra.delanet.com>
hanbit@tng.co.kr (hanbit@tng.co.kr) wrote on MMCDLXXXIX September
MCMXCIII in <URL:news:8j1a6u$46l$1@newsfeed.unitel.co.kr>:
<> I want a data insert into oracle DB using perl.
<> There was no error message but it couldn't inserted into DB
<> here is source code. I want a reply.
<> Have a nice day
Hmm, it seems you are missing a few lines. I suggest you start with:
#!/opt/perl/bin/perl -w
use strict;
That should give you a start.
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: Sun, 25 Jun 2000 11:04:11 +0200
From: "elixir" <mathusalem@free.fr>
Subject: perl + dll
Message-Id: <8j4hvm$5qb$1@wanadoo.fr>
Hi !
Is there anyone enable to tell me if it's possible to run a dll (visual C)
from a perl script with an exchange of parameters ?
Thanks a lot for an answer !!!
__< (©¿©)>___ felix qui potuit rerum cognoscere causas
------------------------------
Date: Sun, 25 Jun 2000 04:05:21 GMT
From: vig@pop.jaring.my (v)
Subject: Re: Perl and Web Security
Message-Id: <3955843c.11015504@news.jaring.my>
On Tue, 20 Jun 2000 18:13:12 -0700, Tom Phoenix <rootbeer@redcat.com>
wrote:
>If you'd like to hire someone to vet the program, let me know by private
>e-mail and I'll send you some recommendations.
>
Wish I could, but this is a private pet project. I was hoping that an
old, tried and tested script would do the trick. But I guess not.
Thanx anyway :)
v
------------------------------
Date: Sat, 24 Jun 2000 20:04:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Quick "Perl Way" solution needed
Message-Id: <395576AF.EBA18E53@stomp.stomp.tokyo>
Matthew Zimmerman wrote:
> In article <3953C366.EEB592B1@orbital.com>,
> J Church <church.jeff@orbital.com> wrote:
> >From the Block below , I was wondering if anyone wants to take
> >a shot at a quick "Perl Way" solution:
> >I want to print the numbers in the last field in such a way
> >that each sequence of consecutive numbers are considered
> >seperate ranges, and are the only values extracted.
> #!/usr/bin/perl -w
> use strict;
> my($low, $high, $last, $curr);
> $_ = <DATA>;
> ($low) = ($last) = /(\d+)\s*$/;
> while( <DATA> ) {
> ($curr) = /(\d+)\s*$/;
> if( $curr != $last+1 ) {
> $high = $last;
> print "$low .. $high\n";
> $low = $curr;
> }
> $last = $curr;
> }
> print "$low .. $curr\n";
>
> __DATA__
> -W- getl0scene_nav.c: bad navigation at scan 688
> -W- getl0scene_nav.c: bad navigation at scan 689
> -W- getl0scene_nav.c: bad navigation at scan 690
> -W- getl0scene_nav.c: bad navigation at scan 691
> -W- getl0scene_nav.c: bad navigation at scan 692
> -W- getl0scene_nav.c: bad navigation at scan 1039
> -W- getl0scene_nav.c: bad navigation at scan 1040
> -W- getl0scene_nav.c: bad navigation at scan 1041
> -W- getl0scene_nav.c: bad navigation at scan 1042
> -W- getl0scene_nav.c: bad navigation at scan 1635
> -W- getl0scene_nav.c: bad navigation at scan 1636
> -W- getl0scene_nav.c: bad navigation at scan 1637
> -W- getl0scene_nav.c: bad navigation at scan 1638
Not bad! Need to clean up your print and pretty
it up a bit.
Godzilla!
PRINTED RESULTS:
________________
688 .. 692
1039 .. 1042
1635 .. 1638
..
..
------------------------------
Date: Sun, 25 Jun 2000 17:52:46 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: Quick "Perl Way" solution needed
Message-Id: <961912291.523552@shelley.paradise.net.nz>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:395576AF.EBA18E53@stomp.stomp.tokyo...
> Matthew Zimmerman wrote:
>
> > In article <3953C366.EEB592B1@orbital.com>,
> > J Church <church.jeff@orbital.com> wrote:
> > >From the Block below , I was wondering if anyone wants to take
> > >a shot at a quick "Perl Way" solution:
>
> > >I want to print the numbers in the last field in such a way
> > >that each sequence of consecutive numbers are considered
> > >seperate ranges, and are the only values extracted.
>
> > #!/usr/bin/perl -w
> > use strict;
>
> > my($low, $high, $last, $curr);
> > $_ = <DATA>;
> > ($low) = ($last) = /(\d+)\s*$/;
> > while( <DATA> ) {
> > ($curr) = /(\d+)\s*$/;
> > if( $curr != $last+1 ) {
> > $high = $last;
> > print "$low .. $high\n";
> > $low = $curr;
> > }
> > $last = $curr;
> > }
> > print "$low .. $curr\n";
> >
> > __DATA__
> > -W- getl0scene_nav.c: bad navigation at scan 688
> > -W- getl0scene_nav.c: bad navigation at scan 689
> > -W- getl0scene_nav.c: bad navigation at scan 690
> > -W- getl0scene_nav.c: bad navigation at scan 691
> > -W- getl0scene_nav.c: bad navigation at scan 692
> > -W- getl0scene_nav.c: bad navigation at scan 1039
> > -W- getl0scene_nav.c: bad navigation at scan 1040
> > -W- getl0scene_nav.c: bad navigation at scan 1041
> > -W- getl0scene_nav.c: bad navigation at scan 1042
> > -W- getl0scene_nav.c: bad navigation at scan 1635
> > -W- getl0scene_nav.c: bad navigation at scan 1636
> > -W- getl0scene_nav.c: bad navigation at scan 1637
> > -W- getl0scene_nav.c: bad navigation at scan 1638
>
>
>
> Not bad! Need to clean up your print and pretty
> it up a bit.
>
> Godzilla!
Although it does have those horrible Perl 5 isms, like 'my' and 'use
strict'.
------------------------------
Date: Sat, 24 Jun 2000 23:02:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Quick "Perl Way" solution needed
Message-Id: <3955A06D.D3491D68@stomp.stomp.tokyo>
Tintin wrote:
>
> "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
> news:395576AF.EBA18E53@stomp.stomp.tokyo...
> > Matthew Zimmerman wrote:
> > Not bad! Need to clean up your print and pretty
> > it up a bit.
> Although it does have those horrible Perl 5 isms, like 'my' and 'use
> strict'.
Maybe this is why his program doesn't work
quite right? Testing before posting helps.
Good program, no doubt, just not quite right,
yes?
Godzilla!
------------------------------
Date: Sun, 25 Jun 2000 12:50:46 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Repeated regex matching.
Message-Id: <8j42n8$pic$1@mawar.singnet.com.sg>
David Allen <s2mdalle@titan.vcu.edu> wrote in message
news:8j2ulq$ckv$1@bob.news.rcn.net...
> Let's say I have a string:
>
> $foo = "popopop";
>
> and then I have this code:
>
> while(($foo =~ m/pop/gi)){
> print "MATCHED\n";
> }
>
> This prints the word MATCHED two times instead of 3
> times. I.e. the string
> ...
> How do I get the desired behavior out of a regex? I.e. how
> do I get a subsequent regex to return a match that can include
> part of, but not all of, a previous match?
There is the brute force approach:
my $foo = "poPOPopo1234POp";
for (map{ $foo =~ /^.{$_}(pop)/i } 0..length $foo) {
print "MATCHED $_\n";
}
but it sure is ugly. :o)
Swee Heng
------------------------------
Date: 25 Jun 2000 01:50:03 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Repeated regex matching.
Message-Id: <slrn8lb8ea.ka1.abigail@alexandra.delanet.com>
David Allen (s2mdalle@titan.vcu.edu) wrote on MMCDLXXXIX September
MCMXCIII in <URL:news:8j2ulq$ckv$1@bob.news.rcn.net>:
() Let's say I have a string:
()
() $foo = "popopop";
()
() and then I have this code:
()
() while(($foo =~ m/pop/gi)){
() print "MATCHED\n";
() }
()
() This prints the word MATCHED two times instead of 3
() times. I.e. the string
()
() popopop
() | | |
() It should see matches here
If you use a proportional font and do vertical formatting, you're
garanteed that 99% of the people have no clue what you mean.
It should match twice. Once at the first "pop", and once at the
last "pop". The second one overlaps the first, so it will not match.
The regex machine picks up *after* the position it finished.
() but instead it's seeing matches
()
() popopop
() | |
()
() there.
Nah, I don't think so.... The latter | is way after the string... ;-)
() How do I get the desired behavior out of a regex? I.e. how
() do I get a subsequent regex to return a match that can include
() part of, but not all of, a previous match?
Use a look-ahead:
while ($foo =~ /(?=pop)/g) {...}
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Sun, 25 Jun 2000 15:39:30 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Repeated regex matching.
Message-Id: <8j4cjt$9tm$1@clematis.singnet.com.sg>
> > How do I get the desired behavior out of a regex? I.e. how
> > do I get a subsequent regex to return a match that can include
> > part of, but not all of, a previous match?
>
> There is the brute force approach:
>
> my $foo = "poPOPopo1234POp";
> for (map{ $foo =~ /^.{$_}(pop)/i } 0..length $foo) {
> print "MATCHED $_\n";
> }
>
> but it sure is ugly. :o)
Very crude as well. Make sure you don't use it! Read Abigail's suggestion
about using look-aheads instead. I apologise for the hideous monstrosity I
created.
Swee Heng
------------------------------
Date: Sat, 24 Jun 2000 16:45:45 -0500
From: Ken Williams <ken@forum.swarthmore.edu>
Subject: Re: Repeated regex matching.
Message-Id: <240620001645453398%ken@forum.swarthmore.edu>
In article <8j2ulq$ckv$1@bob.news.rcn.net>, David Allen
<s2mdalle@titan.vcu.edu> wrote:
>Let's say I have a string:
>
>$foo = "popopop";
>
>and then I have this code:
>
>while(($foo =~ m/pop/gi)){
> print "MATCHED\n";
>}
>
>This prints the word MATCHED two times instead of 3
>times.
That's because after the first match, the current position on the
string, held in pos($foo), is now 3, and it will start matching at the
4th character.
If you want it to back up a character each time, you could do something
like this:
$foo = "popopop";
while(($foo =~ m/pop/gi)){
print "MATCHED: ", pos($foo), "\n";
pos($foo)--;
}
-Ken
------------------------------
Date: 24 Jun 2000 23:35:47 +0100
From: nobull@mail.com
Subject: Re: Repeated regex matching.
Message-Id: <u9em5mzozg.fsf@wcl-l.bham.ac.uk>
"David Allen" <s2mdalle@titan.vcu.edu> writes:
> Let's say I have a string:
>
> $foo = "popopop";
>
> and then I have this code:
>
> while(($foo =~ m/pop/gi)){
> print "MATCHED\n";
> }
>
> This prints the word MATCHED two times instead of 3
> times. I.e. the string
That's right m//g finds non overlapping occorances.
> How do I get the desired behavior out of a regex? I.e. how
> do I get a subsequent regex to return a match that can include
> part of, but not all of, a previous match?
Lookahead assertion.
while(($foo =~ m/p(?=op)/gi)){
print "MATCHED\n";
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 25 Jun 2000 02:59:31 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Testing exit status
Message-Id: <FwowB7.AEA@news.boeing.com>
In article <39554E8B.9E7CDD22@austin.rr.com>,
David McMullen <davidmac@austin.rr.com> wrote:
>I'm trying to test the exit status of a ping command. what is the best
>way to do see if a host exists on the network through this method?
>
perldoc Net::Ping
--
Charles DeRykus
------------------------------
Date: Sun, 25 Jun 2000 03:57:51 -0400
From: root <netnerds@bellsouth.net>
Subject: Using HTTP::Request::Form to get SELECT options
Message-Id: <3955BB7F.CFB52476@bellsouth.net>
Hello List!
I could really use a pointer or two in figuring out how to get the array
I want out of the field_selection function. All I'm trying to do is
obtain the options of a select box on a remote HTML doc.
Here is the code:
##First I request a web page with various input fields and put the
names into an array, NO PROBLEM :-)
my $f = HTTP::Request::Form->new($forms[0][1], $url);
@names = $f -> fields;
print "These are the field names --->@names";
##Then I try to get the select options of a field named 'desc'.
HERE IS WHERE I AM HOPELESSY STUCK :-(
@categories = $f->field_selection("desc");
print "@categories";
##Here is what is printed out instead of the options: ARRAY(0x849e08)
The author of the library said that function fiel_selection would return
an array. Do I have to something beyond assigning one?
Thanks for your time and patience,
Paul Kunicki
------------------------------
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 3474
**************************************