[18422] in Perl-Users-Digest
Perl-Users Digest, Issue: 590 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 29 18:21:24 2001
Date: Thu, 29 Mar 2001 15:20:58 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985908058-v10-i590@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 29 Mar 2001 Volume: 10 Number: 590
Today's topics:
perl faq <|hafizur|@options.uk.com>
Re: perl faq (Anno Siegel)
perl script to browse web site strshn99@mail.usa.com
Perl wrapper for Java program <agw@smolyak.cs.columbia.edu>
Re: Perl wrapper for Java program <twhu@lucent.com>
Pointing the browser at a web page <s.warhurst@rl.ac.uk>
Re: Pointing the browser at a web page <mkuin@globalrangers.com>
Re: Pointing the browser at a web page (Stefan Haller)
Problems with shared libraries <jthomae@imn.htwk-leipzig.de>
Re: Provo Perl Mongers Meeting (David H. Adler)
Re: Provo Perl Mongers Meeting <peb@bms.umist.ac.uk>
Purpose of shift in: my $cgi = shift;? <ryanc@nci1.net>
Re: Purpose of shift in: my $cgi = shift;? (Bernard El-Hagin)
Re: Purpose of shift in: my $cgi = shift;? <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Re: Purpose of shift in: my $cgi = shift;? nobull@mail.com
Re: Purpose of shift in: my $cgi = shift;? <bart.lateur@skynet.be>
Re: Question about File::Find module? <shah@typhoon.xnet.com>
Re: Question about File::Find module? <shah@typhoon.xnet.com>
Regex:how do I match this?? <kellyboy@nospanner>
Re: Regex:how do I match this?? <graham.wood@iona.com>
Re: Regex:how do I match this?? (Gary O'Keefe)
Regexp (s//) question <xris@dont.send.spam>
Regular Expression Metacharacter Flashcards <culley@easystreet.com>
Re: score-based search engines? <xris@dont.send.spam>
Re: score-based search engines? (Tony L. Svanstrom)
Re: score-based search engines? (Tony L. Svanstrom)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Mar 2001 10:08:14 +0100
From: "burner" <|hafizur|@options.uk.com>
Subject: perl faq
Message-Id: <985856911.4215.0.nnrp-13.3e31c2b2@news.demon.co.uk>
i am using active perl by activestate software
now going through the faq, i cant help thinking all of it is gobbledegook
anyone got a simplified plain english version
or know where i can get one from
cheers
--
=================================
I have not lost my mind
its backed up on tape somewhere
icq: 30509036
if this message is not for you, why are you reading it.
Email is spam trapped, remove both pipes
------------------------------
Date: 29 Mar 2001 09:24:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl faq
Message-Id: <99uuvr$ev8$2@mamenchi.zrz.TU-Berlin.DE>
According to burner <|hafizur|@options.uk.com>:
> i am using active perl by activestate software
>
> now going through the faq, i cant help thinking all of it is gobbledegook
Why, thank you.
> anyone got a simplified plain english version
>
> or know where i can get one from
The Perl FAQ is about as simple as it gets. If you want to use Perl
for more than the most basic applications, you will have to learn
some of the gobbledygook. It's the way people talk about Perl.
Anno
------------------------------
Date: 29 Mar 2001 19:23:44 GMT
From: strshn99@mail.usa.com
Subject: perl script to browse web site
Message-Id: <9a0240$1tv$1@news.netmar.com>
Hello all,
I am running perl on Linux and NT and wonder if there are any perl scripts
out
there that will allow me to point to a web site. What i need to do is to
fill in a search form on a web site with the words to search and then cause
that form to be submitted to the website along with some cookies value.
So the perl script I am looking for must be able to send form information as
well as cookies information. Does anyone know where I can get a copy of
such
programs? or info on how to write one? Also, I have to run the
same perl scripts on WinNT
Appreciate you help, please also CC me a copy to my email if possible
strshn99@mail.usa.com
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: 29 Mar 2001 09:48:44 -0500
From: Art Werschulz <agw@smolyak.cs.columbia.edu>
Subject: Perl wrapper for Java program
Message-Id: <ylaitkswrzn.fsf@smolyak.cs.columbia.edu>
Hi.
I would like to have a Perl script that's a wrapper for a Java
program. The main reason for this is if the Perl script were
suid and the Java classes were non-world-readable, then I would
essentially have a Java program that could others could run, but
they wouldn't be able to examine the Java classes.
The obvious thing to try is something along the following lines:
#!/usr/bin/perl -T
$ENV{PATH} = "/bin:/usr/bin";
$javaProg = "/usr/bin/java MyProg";
system($javaProg);
But when I run this, it returns immediately, without prompting (or
getting) any input and without producing any output. This happens for
something as simple as a HelloWorld program.
Any idea what's going wrong here? Thanks.
--
Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker
GCS/M (GAT): d? -p+ c++ l u+(-) e--- m* s n+ h f g+ w+ t++ r- y?
Internet: agw@cs.columbia.edu<a href="http://www.cs.columbia.edu/~agw/">WWW</a>
ATTnet: Columbia U. (212) 939-7061, Fordham U. (212) 636-6325
------------------------------
Date: Thu, 29 Mar 2001 10:48:41 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Perl wrapper for Java program
Message-Id: <99vlj9$op3@nntpb.cb.lucent.com>
I use perl wrapper and never have a problem.
However, I never use the -T option.
Will it work without the -T option?
"Art Werschulz" <agw@smolyak.cs.columbia.edu>
> I would like to have a Perl script that's a wrapper for a Java
> program. The main reason for this is if the Perl script were
> suid and the Java classes were non-world-readable, then I would
> essentially have a Java program that could others could run, but
> they wouldn't be able to examine the Java classes.
>
> The obvious thing to try is something along the following lines:
>
> #!/usr/bin/perl -T
>
> $ENV{PATH} = "/bin:/usr/bin";
> $javaProg = "/usr/bin/java MyProg";
> system($javaProg);
>
> But when I run this, it returns immediately, without prompting (or
> getting) any input and without producing any output. This happens for
> something as simple as a HelloWorld program.
------------------------------
Date: Thu, 29 Mar 2001 15:32:53 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Pointing the browser at a web page
Message-Id: <99vh2u$132e@newton.cc.rl.ac.uk>
Hi
In javascript, if you want to tell the browser to go to a specific web page,
you would use the line:
location.href='http://www.somewhere.com';
What is the equivalent command in Perl?
Thanks
Spencer
------------------------------
Date: Thu, 29 Mar 2001 16:47:07 +0200
From: "Mark Kuin" <mkuin@globalrangers.com>
Subject: Re: Pointing the browser at a web page
Message-Id: <99vht9$536$1@news1.xs4all.nl>
use CGI;
my $query = new CGI;
print $query->redirect('http://www.somewhere.com');
exit;
"S Warhurst" <s.warhurst@rl.ac.uk> wrote in message
news:99vh2u$132e@newton.cc.rl.ac.uk...
> Hi
>
> In javascript, if you want to tell the browser to go to a specific web
page,
> you would use the line:
>
> location.href='http://www.somewhere.com';
>
> What is the equivalent command in Perl?
>
> Thanks
> Spencer
>
>
------------------------------
Date: 29 Mar 2001 16:49:12 +0100
From: hals@babylon.icemark.ch (Stefan Haller)
Subject: Re: Pointing the browser at a web page
Message-Id: <slrn9c6hkt.3r2.hals@babylon.icemark.ch>
In article <99vh2u$132e@newton.cc.rl.ac.uk>, S Warhurst wrote:
Hi
>In javascript, if you want to tell the browser to go to a specific web page,
>you would use the line:
>
>location.href='http://www.somewhere.com';
Do a
print "Location: http://www.somewhere.com\n\n"
in the header of your http transmission. (The second \n is to separate the
header from the actual html file.)
With kind regards
Stefan
------------------------------
Date: Thu, 29 Mar 2001 13:31:34 +0200
From: "Jan Thomä" <jthomae@imn.htwk-leipzig.de>
Subject: Problems with shared libraries
Message-Id: <99v5eq$8g6$1@news.uni-leipzig.de>
Hi,
I built up a project, that uses XML. For this, the project needs LibXML and
LibXSLT.
These two modules need several shared libraries (libxml2.so.2, etc.). On my
local computer at home,
this is really no problem, since I have all libraries installed and the
libxml2.so.2 resides in /usr/local/lib,
where the Perl DynaLoader is seeking it.
However, if I try to put the project on a webserver, to which I only have
FTP-access, i cannot copy the
libxml2.so.2 to /usr/local/lib, since i have no access to this directory.
For this reason, Perl failes to find this library at the start, because it
is not located in the
searchpath of DynaLoader. My question is, how to tell DynaLoader, where it
should look for
libxml2.so.2. For perl-modules this is an easy thing
use lib "/path/to/perl-module"
However, this does not work with the shared libraries.
I would be glad if someone can help me with this.
Best regards,
Jan Thomä
------------------------------
Date: 29 Mar 2001 19:18:52 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Provo Perl Mongers Meeting
Message-Id: <slrn9c72ks.3ga.dha@panix2.panix.com>
On Thu, 29 Mar 2001 09:29:21 +0100, Paul Boardman <peb@bms.umist.ac.uk> wrote:
>Alan Young wrote:
>>
>> If this is OT I'm sure y'all'll let me know.
>>
>> We are having a meeting of the Provo Perl Mongers tonight at the Orem
>> Public Library at 7pm for anyone who is interested.
>
>I'd say it was pretty off topic. esp since many readers of this
>newsgroup don't come from the same country as you!
I think it's on topic... you may disagree with the breadth of its
distribution, though... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
It's amazing what giant mutant ants that are the result of Man's
dabbling with the power of atomic energy can accomplish when they set
themselves to the task. - Mark Rogaski
------------------------------
Date: Thu, 29 Mar 2001 09:29:21 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Provo Perl Mongers Meeting
Message-Id: <3AC2F261.CB0697F8@bms.umist.ac.uk>
Alan Young wrote:
>
> If this is OT I'm sure y'all'll let me know.
>
> We are having a meeting of the Provo Perl Mongers tonight at the Orem
> Public Library at 7pm for anyone who is interested.
I'd say it was pretty off topic. esp since many readers of this
newsgroup don't come from the same country as you!
Paul
------------------------------
Date: Thu, 29 Mar 2001 05:55:22 -0500
From: "Ryan Carrier" <ryanc@nci1.net>
Subject: Purpose of shift in: my $cgi = shift;?
Message-Id: <99v4as$77k$1@taliesin.netcom.net.uk>
I know that shift is used to remove and return the first item in an array;
my "CGI Programming with Perl" shows some examples like this:
my $cgi = shift;
Why??
------------------------------
Date: Thu, 29 Mar 2001 12:00:22 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Purpose of shift in: my $cgi = shift;?
Message-Id: <slrn9c68sk.2of.bernard.el-hagin@gdndev32.lido-tech>
On Thu, 29 Mar 2001 05:55:22 -0500, Ryan Carrier <ryanc@nci1.net> wrote:
>I know that shift is used to remove and return the first item in an array;
>my "CGI Programming with Perl" shows some examples like this:
>
>my $cgi = shift;
>
>Why??
Why not? The code you quote puts the value returned by the shift into a
variable for later use. Why is this confusing?
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 29 Mar 2001 12:45:33 +0100
From: "Clyde Ingram" <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Subject: Re: Purpose of shift in: my $cgi = shift;?
Message-Id: <985866300.8564.0.nnrp-13.9e98e5bc@news.demon.co.uk>
Ryan,
> my $cgi = shift;
I believe the implicit array name here is @_
So this code equates to:
my $cgi = shift @_;
perldoc should tell you lots more about this.
Regards,
Clyde
------------------------------
Date: 29 Mar 2001 12:53:59 +0100
From: nobull@mail.com
Subject: Re: Purpose of shift in: my $cgi = shift;?
Message-Id: <u9bsqk4wq0.fsf@wcl-l.bham.ac.uk>
"Ryan Carrier" <ryanc@nci1.net> writes:
> I know that shift is used to remove and return the first item in an array;
> my "CGI Programming with Perl" shows some examples like this:
>
> my $cgi = shift;
>
> Why??
I do not know which of two question you are asking.
If you do not understand the mechanisms at work here then read all
about parameter passing in Perl in:
perldoc -f shift
perldoc perlsub
perldoc perlboot
If you understand all the above and are asking a question about
programming style the answer is that since the first argument to a
subroutine called as a method is special it makes sytlistic sense to
emphasise this by pulling it off @_ first then dealing with the
remainder in a different way.
sub not_a_method_just_a_function {
my ($p1,$p2,$p3) = @_; # The function arguments
# Do whatever
}
sub some_instance_method {
my $self = shift; # current instance
my ($p1,$p2,$p3) = @_; # the method arguments
# Do whatever
}
sub some_class_method {
my $class = shift; # current class
my ($p1,$p2,$p3) = @_; # the method arguments
# Do whatever
}
sub some_other_method {
my ($self,$p1,$p2,$p3) = @_; # Faster but ugly
# Do whatever
}
sub a_method_optomised_for_speed_over_readabilty {
# Do whatever directly with $_[0], $_[1] and so on..
# For example:
$_[0]{attr}{$_[1]} = $_[2];
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 29 Mar 2001 14:26:09 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Purpose of shift in: my $cgi = shift;?
Message-Id: <pch6ctknp18h6dqpu0qaelu9i4p97hau75@4ax.com>
Ryan Carrier wrote:
>I know that shift is used to remove and return the first item in an array;
>my "CGI Programming with Perl" shows some examples like this:
>
>my $cgi = shift;
>
>Why??
In a sub, this shifts from @_.
And why would you want to do that? Because you want to remove the first
item from the arguments list, probably. For example, in subs used as
methods, the first parameter is special, not user supplied: it is the
class name for class methods or the object for object methods. You want
to use that object, but not do any calculations on it. So you separate
the machinery from the user data.
--
Bart.
------------------------------
Date: Thu, 29 Mar 2001 15:27:45 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Question about File::Find module?
Message-Id: <99vk9h$pte$1@flood.xnet.com>
While stranded on information super highway Abigail wrote:
:)Hemant Shah (shah@typhoon.xnet.com) wrote on MMDCCLXVI September MCMXCIII
:)**
:)** To test it try the following commands:
:)**
:)** find / -name core ! -fstype nfs -print
:)**
:)** and now specify all the local file systems and use -xdev option:
:)**
:)** find / /usr /home -name core -xdev -print
:)**
:)** The second command will run much faster as it skips the directories
:)** on other filesystems.
:)
:)True, but you should be able to do something with prune.
:)
:) find / -name core -print \! -fstype nfs -o -prune
Thanks. That did the trick.
:)
:)** :)Of course, if you just want to delete the files, no need for the open.
:)** :)
:)** :) system q {find / -name 'core' \! -fstype nfs -exec rm {} \;};
:)**
:)** Instead of using -exec command try piping into xargs, it will
:)** execute much faster. The -exec will execute rm command for each
:)** file, but when you pipe it into xargs it will execute rm command
:)** for every 1000 files.
:)
:)You have that many core files on your system that it makes a
:)significant difference?
No, I do not have too many core files, but I use it as a standard
programming practice so that if I cut and paste the command to use it for
other files then I do not have to worry about changing the -exec command to
xargs command.
:)
:)
:)
:)Abigail
:)--
:)perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
:) print+Just (), another (), Perl (), Hacker ();'
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: Thu, 29 Mar 2001 15:38:41 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Question about File::Find module?
Message-Id: <99vku1$qm0$1@flood.xnet.com>
While stranded on information super highway Darren Dunham wrote:
:)Hemant Shah <shah@typhoon.xnet.com> wrote:
:)
:)
:)Nonsense. Prune stops traversing the tree and heads back up.
:)
:)> Here is a description of File::Find I found on web:
:)> -----cut-------------cut-------------cut-------------cut------
:)> find() does a recursive subdirectory search of $dir. It calls Wanted()
:)> once for each file and directory in $dir, including $dir itself. You can
:)> actually specify a list of directories, and find() will search all of
:)> them.
:)
:)> Typically, Wanted() begins by deciding whether it wants to operate on
:)> the current file. Regular expression matches on $_ do this concisely.
:)> -----cut-------------cut-------------cut-------------cut------
:)
:)Your quote seems old. Why are you looking on the web? The docs for
:)File::Find should be on your system?
I did look at the document on my system, but it did not clearly mention
how Find::File works so I searched the web.
You are correct that prune stops traversing the tree. I should have tested
it. When I looked at the code that is generated by find2perl, it is looks
like find will call wanted function for each and every file.
Here is the code generated by find2perl:
$ find2perl . -name core -print \! -fstype nfs -o -prune
#! /usr/local/bin/perl -w
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find ();
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '.');
exit;
sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
/^core\z/s &&
print("$name\n") &&
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
! ($dev < 0)
||
($File::Find::prune = 1);
}
When you look at the code, it is not obvious that prune will stop traversing
the tree, and document does not explain it at all.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: Thu, 29 Mar 2001 04:10:23 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Regex:how do I match this??
Message-Id: <tc62b3rj59t6f4@corp.supernews.com>
I thought I was doing well using Regex until I couldnt do this
situation...been at it for couple of hours tonight with no success
Example line to search for match:
Object(blah blah {Translate<12.5, 23.676565, 0>scale<0, 0, 0.234>blah blah
blah
I m trying to build a regular expression where it will match "<xx, xx, xx>"
where $1 has the first 'xx' and $2 has the second 'xx' and $3 has third 'xx'
(xx being diget)
and I want to match for each <xx, xx, xx> not once found first instance of
matching then it move on to next line... I want to match as many as there is
on each line
I tried something like this
############
while (<>) {
$_=~ /<something here>/g #Regex code I couldnt figure out
$first = $1;
$second=$2;
$third=$3;
.
.
<some code here for whatever intended purpose>
.
.
} #it goes on to next match (on same line..if no more match then move on to
next line)
#############
I tried $_=~/<(\d+.\d*), (\d+.\d*), \d+.\d*)>/g (not sure if 'g' helps) but
no success
any ideas?
kellyboy
--
------------------------------
Date: Thu, 29 Mar 2001 12:14:10 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: Regex:how do I match this??
Message-Id: <99v2g1$i7j$1@spider.iona.com>
kellyboy <kellyboy@nospanner> wrote in message
news:tc62b3rj59t6f4@corp.supernews.com...
> Example line to search for match:
> Object(blah blah {Translate<12.5, 23.676565, 0>scale<0, 0, 0.234>blah blah
> blah
<snipped>
> I tried something like this
> ############
> while (<>) {
> $_=~ /<something here>/g #Regex code I couldnt figure out
> $first = $1;
> $second=$2;
> $third=$3;
> .
> .
> <some code here for whatever intended purpose>
You weren't matching the spaces and the "." is optional with the single
digit zeroes.
Escape the "." and follow with ? for (zero or one) -> \.?
Add an optional white space or spaces -> \s*
You do need the /g as well.
$string="Object(blah blah {Translate<12.5, 23.676565, 0>scale<0, 0,
0.234>blah blah blah";
while(($string =~ m/(\d+\.?\d*),\s*(\d+\.?\d*),\s*(\d+\.?\d*)/g)){
print "$1\n";
print "$2\n";
print "$3\n";
print "next one\n";
}
------------------------------
Date: Thu, 29 Mar 2001 11:18:01 GMT
From: gary@onegoodidea.com (Gary O'Keefe)
Subject: Re: Regex:how do I match this??
Message-Id: <3ac312f5.267685401@news.gssec.bt.co.uk>
On Thu, 29 Mar 2001 04:10:23 -0600, "kellyboy" <kellyboy@nospanner>
wrote:
>I thought I was doing well using Regex until I couldnt do this
>situation...been at it for couple of hours tonight with no success
>
>Example line to search for match:
>Object(blah blah {Translate<12.5, 23.676565, 0>scale<0, 0, 0.234>blah blah
>blah
>
>I m trying to build a regular expression where it will match "<xx, xx, xx>"
>where $1 has the first 'xx' and $2 has the second 'xx' and $3 has third 'xx'
>(xx being diget)
>
>and I want to match for each <xx, xx, xx> not once found first instance of
>matching then it move on to next line... I want to match as many as there is
>on each line
[snippage]
>I tried $_=~/<(\d+.\d*), (\d+.\d*), \d+.\d*)>/g (not sure if 'g' helps) but
>no success
The /g modifier for the match certainly helps. Here's a script I
knocked together to try and get what you were looking for:
#!/usr/home/dev_user/perl/bin/perl -w
use strict;
my $first;
my $second;
my $third;
while ( <DATA> ) {
# Match successive co-ordinate sets.
# The coordinates are represented as 3 floating
# point numbers seperated by commas and possible
# whitespace, enclosed in angle brackets. A
# floating point number is represented as a
# sequence of digits, zero or one decimal seperator
# characters, and possibly another sequence of
# digits. The regex to match this pattern is
# \d+\.?\d*
# The /g modifier on the match operator will start
# the matching from the point in the string the
# last match left off. The loop will iterate
# through the string until no more matches can be
# found.
while ( /<(\d+\.?\d*),\s*(\d+\.?\d*),\s*(\d+\.?\d*)>/g ) {
$first = $1;
$second = $2;
$third = $3;
print "first: $first\n";
print "second: $second\n";
print "third: $third\n";
}
}
__DATA__
Object(blah blah {Translate<12.5, 23.676565, 0>scale<0, 0, 0.234>blah
blah blah
The output of the script is:
$ clpm20010329.1.pl
first: 12.5
second: 23.676565
third: 0
first: 0
second: 0
third: 0.234
Hope this is what you were looking for.
Gary
--
Gary O'Keefe
gary@onegoodidea.com
+44 (0) 7976 614 336
------------------------------
Date: Thu, 29 Mar 2001 13:52:06 -0600
From: xris <xris@dont.send.spam>
Subject: Regexp (s//) question
Message-Id: <xris-378AEE.13520629032001@newsrump.sjc.telocity.net>
Hi, I'm trying to parse keywords in a web page that do more or less what
a standard function/subroutine/procedure call does. for example:
$t =~ s/%%keyword\(((?:%%\w+\(.+?\)%%|.)+?)\)%%/&someroutine($1)/sgieo;
would pass the "text" within %%Keyword(text)%% to a routine and get a
response. My first problem is that this keyword is sometimes embedded
in itself. Is there any solution other than doing something like:
1 while (s/%%keyword()%%/&someroutine/sgieo);
to get all occurrences? Sometime like maybe making the position counter
go back to the start of the replacement, rather than to the end of it,
when it's parsing?
My second problem is that sometimes the embedded keywords (different
ones) are sometimes more than 2 layers deep:
%%k1(bla %%k2(bla %%k3(bla)%% bla)%% bla)%%
parsing this currently requires me to expand my regexp pattern manually
for each layer of depth that I want to account for. eg:
%%keyword\(((?:%%\w+\((?:%%\w+\(.+?\)%%|.)+?\)%%|.)+?)\)%%
grabs 2 layers instead of the 1 that the original example used. My
question is whether or not it's possible to make the
((?:%%\w+\(.+?\)%%|.)+?) portion of the regexp point back internally to
the ".+?" inside of itself so that it will automatically skip over as
many layers of parentheses that it needs to to find the closing paren
that belongs to it, rather than to some keyword called within it.
I know that I can do this by writing my own parsing routine (which may
be faster, anyway, as I'm parsing 20-50 keywords like this for every
html pages I'm loading and I could put in some optimizations, but I'm
curious if this can also be done with regexp.
-Chris
------------------------------
Date: Thu, 29 Mar 2001 05:52:44 -0800
From: "Culley Harrelson" <culley@easystreet.com>
Subject: Regular Expression Metacharacter Flashcards
Message-Id: <tc6f602men2a83@corp.supernews.com>
I've put together some regular expression flashcards:
www.flashcardexchange.com
they are in the information technology directory or search for regular
expressions.
------------------------------
Date: Thu, 29 Mar 2001 02:39:05 -0600
From: xris <xris@dont.send.spam>
Subject: Re: score-based search engines?
Message-Id: <xris-3C9D96.02390529032001@newsrump.sjc.telocity.net>
In article <1er0r28.161zusmcrmbk8N%tony@svanstrom.com>,
tony@svanstrom.com (Tony L. Svanstrom) wrote:
> So you think that it's ok to use an e-mailaddress that points to someone
> elses mailserver, so that they have to deal with replies meant for you
> and the spam that you attract using this e-mailaddress?
ok, you're right here.. guess I've just been used to doing the whole
user@host.com thing for anon ftp for the past 8+ years I've been online.
And assumed that the spam bots might be smart enough to ignore this
ultra-genericized address. obviously, as per suggestions, I've changed
the fake address...
But what about some help with the actual question I posted, rather than
criticizing my choice of spam-avoidance technique?
-xris
------------------------------
Date: Thu, 29 Mar 2001 04:54:18 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: score-based search engines?
Message-Id: <1er0r28.161zusmcrmbk8N%tony@svanstrom.com>
xris <user@host.com> wrote:
> p.s. Please reply to the group, this email address is obviously fake (I
> get too much spam as it is to entice more from newsgroup spiders)
So you think that it's ok to use an e-mailaddress that points to someone
elses mailserver, so that they have to deal with replies meant for you
and the spam that you attract using this e-mailaddress?
host.com mail is handled (pri=10) by domres.tierranet.com
Registrant:
Agent Host Co.
1701 E. 8th Street, #259
Tempe, AZ 85281-8106
US
/Tony
--
########################################################################
I'm sorry, I'm sorry; actually, what I said was:
HOW WOULD YOU LIKE TO SUCK MY BALLS?
- South Park -
------------------------------
Date: Thu, 29 Mar 2001 22:01:20 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: score-based search engines?
Message-Id: <1er22nn.1944zu91lijc3uN%tony@svanstrom.com>
xris <xris@dont.send.spam> wrote:
> In article <1er0r28.161zusmcrmbk8N%tony@svanstrom.com>,
> tony@svanstrom.com (Tony L. Svanstrom) wrote:
>
> > So you think that it's ok to use an e-mailaddress that points to someone
> > elses mailserver, so that they have to deal with replies meant for you
> > and the spam that you attract using this e-mailaddress?
>
> ok, you're right here.. guess I've just been used to doing the whole
> user@host.com thing for anon ftp for the past 8+ years I've been online.
> And assumed that the spam bots might be smart enough to ignore this
> ultra-genericized address. obviously, as per suggestions, I've changed
> the fake address...
Well, you're still breaking the "law" (ie, the RFC)... To make it
correct you should use the tld that's set aside for this, use .invalid.
> But what about some help with the actual question I posted, rather than
> criticizing my choice of spam-avoidance technique?
I'm not done with the criticizing yet. =)
/Tony
--
########################################################################
I'm sorry, I'm sorry; actually, what I said was:
HOW WOULD YOU LIKE TO SUCK MY BALLS?
- South Park -
------------------------------
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 V10 Issue 590
**************************************