[7417] in Perl-Users-Digest
Perl-Users Digest, Issue: 1042 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 18 05:17:21 1997
Date: Thu, 18 Sep 97 02:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Sep 1997 Volume: 8 Number: 1042
Today's topics:
Calling another program from Perl for Win '95/NT <peterv@valkieser.nl>
Change /etc/passwd <jcarlosd@ford.com>
Re: DOS version of PERL 5? (Bart Lateur)
Re: Getting a String from the User (Tad McClellan)
Re: Getting a String from the User <maryesme@3-cities.com>
Re: Help me with this pls (Charles DeRykus)
Re: How to setup list as class data member <holmberg@iar.se>
Re: Impossible dbm size (Jason Gloudon)
looping through an sql query using win32::odbc (Bob Maillet)
Re: Max number of options in GetOptions (Johan Vromans)
Re: Multiple download (Jeremy D. Zawodny)
Re: Need bulk Unix <-> PC file conversion (Greg Zevin)
Re: pattern matching <rovf@earthling.net>
Perl 5 bug???? Help. (kostick christopher)
Re: Perl 5 bug???? Help. (Tad McClellan)
Re: Perl 5 bug???? Help. (Jean-Damien Durand)
Re: postmail and perlis <rene.sorger@onlinemedia.de>
Re: Question <seay@absyss.fr>
Reg Exp Question <appcs@iwaynet.net>
Re: Reg Exp Question (Tad McClellan)
reg expression help! (Alex Krohn)
Re: reg expression help! <eike.grote@theo.phy.uni-bayreuth.de>
RegEx Multiple Matches <savoie@ppp.bekkoame.or.jp>
Re: RegEx Multiple Matches (Jason Gloudon)
Re: simple script (Terry Michael Fletcher - PCD ~)
Something of the day script (John Thomas Mosey)
Re: Value within range? (Terry Michael Fletcher - PCD ~)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Sep 1997 10:02:08 +0200
From: Peter de Vroomen <peterv@valkieser.nl>
Subject: Calling another program from Perl for Win '95/NT
Message-Id: <3420E000.AAF68980@valkieser.nl>
Hello people,
I have some difficulties calling another perl program from a perl
program, using Perl for Windows '95/NT (the standard Perl distribution,
not PerlWin32).
At some time my program calls a second Perl program by using the
'system' statement. This is the code:
$PerlExec = "d:/perl/perl5.004/bin/perl.exe";
$CGIBin = "d:/htdocs/pl-bin";
..
@Call = ( $PerlExec . " " . $CGIBin . "/persbericht.pl", $BLParams );
$RetVal = system( @Call );
This call works fine when I run my program from the commandline (under
Windows NT 4.0, haven't tried Windows '95 yet).
The problem is that the first program is a CGI-script, and gets called
as a shellcgi by my webserver (Netscape Enterprise 3.0). The first
program works fine as a CGI-program, but when the system-call is done, I
get a return-value of 65280 (255 if divided by 256), and the script is
not started.
The documentation tells me the following:
'$? ends up with the exitstatus of the subprocess (this is different
from Unix, where the exitstatus is actually given by "$? >> 8").
Failure to spawn() the subprocess is indicated by setting $? to
"255<<8". This is subject to change.'
So, 255<<8 is what I get for a return-value.
Can anyone tell me what I have to do to get my scripts to work under a
web-server? I expect it has something to do with paths?
Peter
--
Peter de Vroomen (e-mail: peterv@valkieser.nl), Software Engineer,
Valkieser Solutions, 's Gravelandseweg 80a, 1217 EW Hilversum,
The Netherlands, +31-(0)35-6714300, fax: +31-(0)35-6714333
------------------------------
Date: Thu, 18 Sep 1997 10:16:53 +0200
From: Juan Carlos del Rio <jcarlosd@ford.com>
Subject: Change /etc/passwd
Message-Id: <3420E375.3F3@ford.com>
Our web server is running on HP-UX 10.2. Some of our users are able to
input files on it, because I have created them as unix users.
My question is the following: is it possible to run a perl program so
they can change the access password (updating /etc/passwd file)?
------------------------------
Date: Thu, 18 Sep 1997 09:35:56 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: DOS version of PERL 5?
Message-Id: <342bf5d1.7508577@news.tornado.be>
Rachel Holmes <rachelh@nortel.ca> wrote:
>Is there a version of perl available for DOS, that is 100% compatible
>with unix perl 5?
Grab the OS/2 port. YOu need EMX and/or RSX too, but these are free too.
HTH,
Bart.
------------------------------
Date: Wed, 17 Sep 1997 22:40:31 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Getting a String from the User
Message-Id: <fr7qv5.dnk.ln@localhost>
Alex McCool (alex@cadscape.com) wrote:
: How can I ask a user for a string value.
: single chars are working fine with getc, but I can't get it to work with
: a string.
: HELP,
How will you know when they are finished typing the string?
I suppose you could have them type a special character to signal
when they are finished.
How about ASCII 10 (decimal)? Then:
print "enter a string. Hit 'Enter' when done: ";
chomp($string = <STDIN>);
;-)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Sep 1997 23:22:35 -0700
From: Mark and Esmeralda Lybrand <maryesme@3-cities.com>
To: Alex McCool <alex@cadscape.com>
Subject: Re: Getting a String from the User
Message-Id: <3420C8AA.F06@3-cities.com>
Alex McCool wrote:
>
> Hi,
>
> How can I ask a user for a string value.
>
> single chars are working fine with getc, but I can't get it to work with
> a string.
>
> HELP,
>
To get input from a user, simply do this:
$input = <STDIN>;
Is this what you wanted??
Mark :)
------------------------------
Date: Wed, 17 Sep 1997 19:35:05 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help me with this pls
Message-Id: <EGo3qJ.Iz3@bcstec.ca.boeing.com>
In article <01bcc0c9$eabc4de0$082ab583@pacific.net.sg.pacific.net.sg>,
Charles Wee Chun Chiang <cc.wee@student.qut.edu.au> wrote:
> Hi all,
>
> $destadd=$in{'to'};
> $fromadd=$in{'from'};
> $Subject=$in{'Subject'};
> $Answer=$in{'Answer'};
>
> unless($destadd && $fromadd && $Subject &&Answer)
> {
> Error messages asking users to retry again
> }
> print "Your email has been sent";
> }
>
> This code that i wrote is able to test for empty destadd, fromadd and
> subject fields but cannot detect an empty Answer field.
>
Could this be a simple syntax error:
unless($destadd && $fromadd && $Subject &&Answer)
&& $Answer
HTH,
--
Charles DeRykus
------------------------------
Date: 17 Sep 1997 12:36:16 +0200
From: Johan Holmberg <holmberg@iar.se>
Subject: Re: How to setup list as class data member
Message-Id: <vy7mcgmdlr.fsf@iar.se>
"Sylvain St.Germain" <sgermain@nortel.ca> writes:
> Hi,
>
> In my constructor I do:
>
> my $self = $class->SUPER::new(@args);
> $self->{ValidActions} =
> ("Print",
> "Add",
> "Remove",
> "Install",
> "Save Information",
> "Delete");
>
> This does not work because of the scalar context of
> $self->{ValidActions} (I think)
>
> My question is: How can I have list
> assigned to a datamember in the above context??
>
Since only scalars can be stored in an associative array, I think
you have to store a *reference* to the list. Using [] instead of
() you would get:
my $self = $class->SUPER::new(@args);
$self->{ValidActions} =
[ "Print",
"Add",
"Remove",
"Install",
"Save Information",
"Delete" ];
> I would like to be able to do:
>
> foreach $thing ($myobj->{ValidActions}) {
> ...
> }
>
and you could write:
foreach $thing (@{$myobj->{ValidActions}}) {
...
}
/johan holmberg
--
Johan Holmberg email: holmberg@iar.se
IAR Systems AB phone: +46 (0) 18 16 78 24
Box 23051, Islandsgatan 2 fax: +46 (0) 18 16 78 38
S-750 23 UPPSALA, SWEDEN
------------------------------
Date: 18 Sep 1997 01:10:45 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: Impossible dbm size
Message-Id: <5vpv2l$a9a$1@daily.bbnplanet.com>
In article <34202F4C.66B2FDBA@ican.net>,
Charles Jaimet <cjaimet@ican.net> wrote:
>My server says my dbm database file takes up 4,800 GB!
>
Are you sure you posted what you meant ?
It is possible for a file to contain holes, which don't represent actual used
disk blocks. But your GB sounds a bit incredulous.
Jason Gloudon
------------------------------
Date: 18 Sep 1997 02:41:03 GMT
From: bob@cafemedia.com (Bob Maillet)
Subject: looping through an sql query using win32::odbc
Message-Id: <bob-1709972244500001@apt2.tiac.net>
I have been using the win32 odbc module to write the contents on a file
into an access database unfortunately it will only write the first line of
that file...What I am having trouble figuring out is how to construct a
loop which will read the next line of that file and then run the sql to
import it into access. It seems inefficient to do it this way but after
trying to open another $DSN and running into permission errors when
writing that data this seems the logical solution. Below is the script I
have put together. Any suggestions would be appreciated.
Bob
#!/usr/bin/perl
use Win32::ODBC;
$data = "C:/Perl/down.txt";
# open reads and closes files
open (FILE, $data);
@file = (<FILE>);
close(FILE);
# separates each line of the file and breaks each line up into an array
foreach $line (@file){
$_ = $line;
@ok = split(/ /, $line);
}
#open database
$DSN ="Bob";
if (!($db = new Win32::ODBC($DSN))){
print "Error connecting to $DSN\n";
print "Error: " . Win32::ODBC::Error() . "\n";
exit;
}
# execute SQL command
$sql = "INSERT INTO test (1,2,3) VALUES ($ok[0],'$ok[1]','$ok[2]');";
if ($db->Sql($sql)){
print "SQL failed.\n";
print "Error: " . $db->Error() . "\n";
$db->Close();
exit;
}
# close the connection to the database:
$db->Close();
------------------------------
Date: 18 Sep 1997 09:13:25 +0200
From: JVromans@Squirrel.NL (Johan Vromans)
Subject: Re: Max number of options in GetOptions
Message-Id: <wl3yb4vt7qi.fsf@plume.nl.compuware.com>
Gary Croke <croke@nortel.ca> writes:
> I am wondering if there is a maximum number of command-line options that
> GetOptions() will accept when using Getopt::Long;
None, except for internal limits -if any- on perl arrays and hashes.
I guess your shell (that passes the command-line options) will be the
first to complain if you use thousands of options...
-- Johan
------------------------------
Date: Thu, 18 Sep 1997 03:40:44 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Multiple download
Message-Id: <3420b62e.547925344@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On 17 Sep 1997 08:27:17 GMT, "Miran Sepic" <miran.sepic4@mss.tel.hr>
wrote:
>I am trying to solve the following problem:
>
>- make selection of few files (HTML)
>- download them
>
>Is it possible?
Certainly. :-)
Jeremy
--
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"These constraints effectively ruled out the obvious choices of using
plain fingers (yogurt is not a finger food at work), and of constructing
a make-shift spoon from paper clips, scraps of paper, and scotch tape."
-- Justin Dolske (dolske@cis.ohio-state.edu> in alt.hackers
------------------------------
Date: 18 Sep 1997 12:56:21 +1000
From: greg@turing.une.edu.au (Greg Zevin)
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <5vq58l$kk@turing.une.edu.au>
"Aaron" <aaron@soltec.net> writes:
>Hmmmmmmmm
>> I need to convert the PC style (CR LF) files to unix style (LF) files.
>> The text editor I use can do this (UltraEdit32) but it is kinda tedious.
>>
>Let's see
>If I were going to do this (and I have wrestled with the problem in the
>past)
>I would write a perl script that did something like
>s/\r/\n/g *.htm
>I know you can do it from the command line (UNIX) like this
>perl -pi.bak -e 's/\r/\n/g' *.htm
Aaron, do you understand that the result of your commaned would be double
"\n" in the end of each line?
Greg Zevin
------------------------------
Date: 18 Sep 1997 09:29:48 +0200
From: Ronald Fischer <rovf@earthling.net>
To: Joseph June <jjune@midway.uchicago.edu>
Subject: Re: pattern matching
Message-Id: <xz2raant6z7.fsf@uebemc.siemens.de>
>>>>> On Wed, 17 Sep 1997 16:11:02 GMT
>>>>> "JJ" == Joseph June <jjune@midway.uchicago.edu> wrote:
JJ> I have a text file that has the passage
JJ> :icon-name (icon-gateways)
JJ> )
JJ> )
JJ> :time (
JJ> : Any
JJ> )
JJ> )
JJ>
JJ> :rule_adtr (
JJ> :src_adtr (
JJ> : Sever_Name
JJ> )
JJ> :dst_adtr (
JJ> : X-AAAAAAAAA
JJ> )
JJ> :services_adtr (
JJ> : Any
JJ> )
JJ>
JJ>
JJ> )
JJ> ...
JJ>
JJ> I want to be able to replace the entire rule_adtr set with something... so
[snip]
JJ> Obviously I have no problem matching X-AAAAAAAA... but after getting the
JJ> match... i need to move up a few line before start generating the new
JJ> set... or else the old set's beginning will be left and mixed up with the
JJ> new one..
I assume that your rule set containes balance parentheses only, so the
your task is to match a rule starting with ":rule_adtr (", containing
"X-AAAAAAAAA" and ending with the CORRESPONDING closed
parenthese. Right?
Basically, you go thru your file until you find some :rule_adtr. From
here on, push this line and all the following lines up to the
terminating parenthese into an array, instead of writing it to the
output file. Then, if those lines contain X-AAAAAAAA, write your new
rule to the output, otherwise write this array to the output.
What remains to do is how to locate the corresponding closed brace.
Balanced expressions can not be matched by regular expressions at all,
not even with the extension Perl offers, so you have to look for other
ways to do this.
First idea: Can you guarantee that the rules have consistent layout?
In this case you know exactly the position of the closing brace inside
the line and this gets easy.
Otherwise, you will have to count braces.
Hope that helps.
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: 17 Sep 1997 21:58:39 -0400
From: kostick@umbc.edu (kostick christopher)
Subject: Perl 5 bug???? Help.
Message-Id: <5vq1sf$qia@umbc9.umbc.edu>
I can't figure out if this is a bug or it's me. But this program works
under perl4.036 and doesn't under perl5.xxx. I tried this on different
architectures: intel (linux), alpha, sun, and sgi; and they all point
to perl5.003 as the problem (also, noted the same thing on 5.001).
Hell, I even got correct results on a Windows95 machine running 4.019.
Here's the program and a sample run for each version. Can anyone tell
me why perl5 gives, what I think, is a wrong answer. What changed in
5.0 from 4.036 to do this?
#!/usr/local/bin/perl
#
# read in ip address and netmask and bit-wise and the two
# quantities
#
$addr = $ARGV[0];
$mask = $ARGV[1];
$o1 = $o2 = $o3 = $o4 = 0;
$m1 = $m2 = $m3 = $m4 = 0;
($o1, $o2, $o3, $o4) = split(/\./, $addr);
($m1, $m2, $m3, $m4) = split(/\./, $mask);
$n1 = $o1 & $m1;
$n2 = $o2 & $m2;
$n3 = $o3 & $m3;
$n4 = $o4 & $m4;
printf "%d.%d.%d.%d\n", $o1, $o2, $o3, $o4;
printf "%d.%d.%d.%d\n", $m1, $m2, $m3, $m4;
printf "%d.%d.%d.%d\n", $n1, $n2, $n3, $n4;
exit 0;
------------------------------------------------------------
Sample run perl4.036
$ program1.pl 192.168.1.2 255.255.255.0
192.168.1.2
255.255.255.0
192.168.1.0
Sample run perl5.003
$ program1.pl 192.168.1.2 255.255.255.0
192.168.1.2
255.255.255.0
10.40.0.0
When doing a bit-wise I cannot fathom how $n1 = 10 and $n2 = 40.
Help if you can. Thanks.
--
Chris
------------------------------
Date: Wed, 17 Sep 1997 23:26:08 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl 5 bug???? Help.
Message-Id: <0haqv5.60l.ln@localhost>
kostick christopher (kostick@umbc.edu) wrote:
: I can't figure out if this is a bug or it's me. But this program works
: under perl4.036 and doesn't under perl5.xxx. I tried this on different
: architectures: intel (linux), alpha, sun, and sgi; and they all point
: to perl5.003 as the problem (also, noted the same thing on 5.001).
: Hell, I even got correct results on a Windows95 machine running 4.019.
: Here's the program and a sample run for each version. Can anyone tell
: me why perl5 gives, what I think, is a wrong answer. What changed in
: 5.0 from 4.036 to do this?
: #!/usr/local/bin/perl
I'm sure your real code has the -w switch in it.
: #
: # read in ip address and netmask and bit-wise and the two
: # quantities
: #
: $addr = $ARGV[0];
: $mask = $ARGV[1];
: $o1 = $o2 = $o3 = $o4 = 0;
: $m1 = $m2 = $m3 = $m4 = 0;
: ($o1, $o2, $o3, $o4) = split(/\./, $addr);
: ($m1, $m2, $m3, $m4) = split(/\./, $mask);
$o1+=0; # force perl to treat them as numbers, rather than strings
$o2+=0;
$o3+=0;
$o4+=0;
$m1+=0;
$m2+=0;
$m3+=0;
$m4+=0;
: $n1 = $o1 & $m1;
: $n2 = $o2 & $m2;
: $n3 = $o3 & $m3;
: $n4 = $o4 & $m4;
: printf "%d.%d.%d.%d\n", $o1, $o2, $o3, $o4;
: printf "%d.%d.%d.%d\n", $m1, $m2, $m3, $m4;
: printf "%d.%d.%d.%d\n", $n1, $n2, $n3, $n4;
: exit 0;
: ------------------------------------------------------------
: Sample run perl4.036
: $ program1.pl 192.168.1.2 255.255.255.0
: 192.168.1.2
: 255.255.255.0
: 192.168.1.0
: Sample run perl5.003
: $ program1.pl 192.168.1.2 255.255.255.0
: 192.168.1.2
: 255.255.255.0
: 10.40.0.0
: When doing a bit-wise I cannot fathom how $n1 = 10 and $n2 = 40.
It is doing bit-wise on a string, using each character's ASCII value.
For $n1:
hex binary
'192' to ASCII => 31 39 32 => 00110001 00111001 00110010
'255' to ASCII => 32 35 35 => 00110010 00110101 00110101
& -------- --------------------------
30 31 30 00110000 00110001 00110000
30 31 30 in ASCII yields the string '010', and your printf lops
off the leading zero ;-)
: Help if you can. Thanks.
Hope I did.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Sep 1997 07:03:48 GMT
From: ddurand@hpplus01.cern.ch (Jean-Damien Durand)
To: kostick@umbc.edu (kostick christopher)
Subject: Re: Perl 5 bug???? Help.
Message-Id: <EGozMD.LJ4@news.cern.ch>
> $n1 = $o1 & $m1;
> $n2 = $o2 & $m2;
> $n3 = $o3 & $m3;
> $n4 = $o4 & $m4;
$n1 = int ($o1) & int ($m1);
$n2 = int ($o2) & int ($m2);
$n3 = int ($o3) & int ($m3);
$n4 = int ($o4) & int ($m4);
gives me the expected result on perl 5.004 (HPUX 10.20):
[] ~> test.pl 192.168.1.2 255.255.255.0
192.168.1.2
255.255.255.0
192.168.1.0
--
*******************************************************
* Jean-Damien Durand (Jean-Damien.Durand@cern.ch) *
* www : http://wwwinfo.cern.ch/~ddurand/ *
*******************************************************
--
*******************************************************
* Jean-Damien Durand (Jean-Damien.Durand@cern.ch) *
* www : http://wwwinfo.cern.ch/~ddurand/ *
*******************************************************
------------------------------
Date: Thu, 18 Sep 1997 08:51:18 +0200
From: Rene Sorger <rene.sorger@onlinemedia.de>
To: "Jeremy D. Zawodny" <zawodny@hou.moc.com>
Subject: Re: postmail and perlis
Message-Id: <3420CF66.7AE83B3D@onlinemedia.de>
Hi,
Jeremy D. Zawodny wrote:
> On Wed, 17 Sep 1997 09:15:09 +0200, Rene Sorger
> <rene.sorger@onlinemedia.de> wrote:
>
> >Hi,
> >
> >I am using a perl script for feedback delivery on my websites. The
> >program Postmail is called by the script in this way :
> >
> >open (MESSAGE," | postmail -t -H$smtpserver");
> >
...
>
> I believe that IIS has trouble with pipes in spawned processes, like
> perl.exe.
Is there any other way to send email via perl with iis ?
Rene
--
---------------------------------------------------------------------
I Rene Sorger I I
I Online Media Riedlbauer GmbH I Ich hab' Hunger ! I
I Xlink PoP Krefeld I I
---------------------------------------------------------------------
------------------------------
Date: Thu, 18 Sep 1997 09:20:39 +0200
From: Doug Seay <seay@absyss.fr>
To: Jeff Walters <n9707022@scholar.nepean.uws.edu.au>
Subject: Re: Question
Message-Id: <3420D647.27FBB1A5@absyss.fr>
[posted and mailed]
[followups redirected to c.l.p.misc]
Jeff Walters wrote:
>
> I'm a total newbie at creating perl scripts.....and I've just been
> handed the reigns for a Perl script chat site. My question is -
> where's the best site to go to learn how to work Perl? Thanks in
> advance.
I hope that you already know the basics of programming as I don't think
Perl is the best langauge for beginners. Others may disagree. That
asside, the best site for learning about Perl is your own workstation.
It comes with bunches of good documentation that explains lots of
stuff. Assuming everything is well installed, simply entering "perldoc
perl" should give you the high level overview of what there is to see
(basically it is a pointer to other places). Read what it tells you to
read in the order listed and you'll do fine.
If you prefer hardcopy, go to any decent computer bookstore and get what
we call 'the Camel' (aka _Programming Perl_, use "perldoc perlbook" to
get the ISBN).
There is http://www.perl.com/ (TomC's web server) for looking at all the
FAQs and stuff. It has been upgraded recently, so it might be unstable
for a while (dunno, I haven't used it lately). It will redirect you to
a nearby mirror site when possible, so you shouldn't have to use those
trans-pacific links too much.
If you have any questions, just post them to comp.lang.perl.misc (not
modules unless it deals with a module). But please do you homework in
advance. Read the docs, read the faqs (perldoc perlfaq), invest some
brain power. When people have problems, we like to help. When people
are lazy, many of us like to flame.
- doug
------------------------------
Date: Wed, 17 Sep 1997 22:28:36 -0400
From: appcs <appcs@iwaynet.net>
Subject: Reg Exp Question
Message-Id: <342091D4.A11@iwaynet.net>
>From a line such as the one below
<LI><LI><LI><LI>..Pattern..</LI></LI></LI></LI>
is there a way to remove the <LI>..Pattern..</LI> substring if we are
not told how many <LI></LI> pairs surround it?
the .. stands for stuff.
s/<LI>.*?Pattern.*?</LI>// seems to eat up the whole line.
------------------------------
Date: Wed, 17 Sep 1997 23:33:08 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Reg Exp Question
Message-Id: <4uaqv5.m1l.ln@localhost>
appcs (appcs@iwaynet.net) wrote:
: From a line such as the one below
: <LI><LI><LI><LI>..Pattern..</LI></LI></LI></LI>
: is there a way to remove the <LI>..Pattern..</LI> substring if we are
: not told how many <LI></LI> pairs surround it?
Yes.
: the .. stands for stuff.
: s/<LI>.*?Pattern.*?</LI>// seems to eat up the whole line.
s!((?:<LI>)*)<LI>.*?Pattern.*?</LI>!$1!;
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Sep 1997 00:47:06 GMT
From: alex@gossamer-threads.com (Alex Krohn)
Subject: reg expression help!
Message-Id: <3420792c.71273999@news.supernews.com>
I've been struggling with this one for a while:
I have a string that can be of the form
i) "one"
ii) "one/two"
iii) "one/two/three/four"
or some combination of words sepearted by "/". What I want to do is
retrieve in one variable ($base) everything except the trailing word
and in another variable ($name) the trailing word.
I've been trying:
$string = m,^(.*)/(\w+)$,;
($base, $name) = ($1, $2);
but this doesn't work in a lot of cases. Any help would really be
appreciated!
Thanks,
Alex
------------------------------
Date: Thu, 18 Sep 1997 10:16:58 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: reg expression help!
Message-Id: <3420E37A.3F54@theo.phy.uni-bayreuth.de>
Hi,
Alex Krohn wrote:
>
> I've been struggling with this one for a while:
>
> I have a string that can be of the form
>
> i) "one"
> ii) "one/two"
> iii) "one/two/three/four"
>
> or some combination of words sepearted by "/". What I want to do is
> retrieve in one variable ($base) everything except the trailing word
> and in another variable ($name) the trailing word.
>
> I've been trying:
>
> $string = m,^(.*)/(\w+)$,;
^
the operator you want here is =~ (note the '~' !)
You should also insert a check like
if($string =~ m,...,) { ... } else { ..(only one element).. }
to deal with case i) in your list above.
> ($base, $name) = ($1, $2);
>
> but this doesn't work in a lot of cases. Any help would really be
> appreciated!
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: Thu, 18 Sep 1997 10:25:59 +0900
From: Christopher J Savoie <savoie@ppp.bekkoame.or.jp>
Subject: RegEx Multiple Matches
Message-Id: <34208327.41C67EA6@ppp.bekkoame.or.jp>
Dear Perl folks,
I am looking to print out all possible matches in a given sentence
using something simila to :
(/[ABC][DEF][XYZ]/i)
Sorry for my ignorance and poor comprehension of Learnin Perl, but I
seem only to get
ADY
and nothing else, if my search sequence is :
ADYGJJBHUYGYADYhhkhjkjhhjkAEY
where I desire:
ADY, ADY, AEY
as a result.
Here is the portion of my code at question:
while (<DATABASE>){
$rec=$_;
@seq=split /]/, $rec;
$seq[1]=~s/\n//;
$seq[1]=~s/>//;
if ($seq[1]
=~(/[@P[0]][@P[1]][@P[2]][@P[3]][@P[4]][@P[5]][@P[6]][@P[7]][@P[8]]/i)){
print "You have a hit at:\n $seq[0] \] \n\n";
print "The target sequence that matches is:\t $& \n\n";
}
Can anyone tell me the modifications I need in the regex to get all of
the matches in a particular read of $_ .... Also, where are those
results stored, so that I can print all of them out, or throw them to
another routine? Are *all* of the matches stored in something like
@MATCH, or does the loop iterate for each matching instance?
I would greatly appreciate your help.
Thanx
CJS
------------------------------
Date: 18 Sep 1997 01:54:10 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: RegEx Multiple Matches
Message-Id: <5vq1k2$epg$1@daily.bbnplanet.com>
In article <34208327.41C67EA6@ppp.bekkoame.or.jp>,
Christopher J Savoie <savoie@ppp.bekkoame.or.jp> wrote:
>Dear Perl folks,
>
>
>I am looking to print out all possible matches in a given sentence
>using something simila to :
>
> (/[ABC][DEF][XYZ]/i)
>
>
Try reading the perlop manpage particularly of interest is the paragraphs
that start:
The /g modifier specifies global pattern matching--
that is, matching as many times as possible within
the string. How it behaves depends on the context.
In a list context, it returns a list of all the
substrings matched by all the parentheses in the
regular expression. If there are no parentheses, it
returns a list of all the matched strings, as if
there were parentheses around the whole pattern.
In a scalar context, m//g iterates through the
string, returning TRUE each time it matches, and
FALSE when it eventually runs out of matches. (In
The manpage also includes an example.
Jason Gloudon
------------------------------
Date: 18 Sep 1997 00:01:22 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: simple script
Message-Id: <5vpr0i$5b5$1@news.fm.intel.com>
Jiri medlen (jmedlen@lpd.sj.nec.com) so eloquently and verbosely pontificated:
> Hi,
>
> Does anybody know, how make assignmet work??
> $num = system ('grep -c \'GET /HTTP\'
> c:\netscape\server\httpd-80\logs\access');
hmmm. i like the idea behind that.
open(SESAME,'c:/netscape/server/httpd-80/logs/access') || die $!;
$num = grep m|GET /HTTP|, <SESAME>;
close(SESAME);
i know the opening and closing sucks, but you only have to do it once, and
you dont have to worry about NT systems that might not have grep (how dare
they! :-) ).
hope that helps.
--
#!/usr/local/bin/perl -w
print "J" ."u". # -- Terry Fletcher
"s" ."t". " A", "n" # tfletche@pcocd2.intel.com
. "o" ,""."". "the", "r ","P". # Views expressed....not
"e"."rl" ." Ha", "c",'' ."" ."". # INTeL's....yadda yadda
"" , "k". "e" ."r" ;# yadda....
------------------------------
Date: 18 Sep 1997 05:03:03 GMT
From: mosey@alpha3.csd.uwm.edu (John Thomas Mosey)
Subject: Something of the day script
Message-Id: <5vqcm7$rk@uwm.edu>
Does anyone out there know of a daily rotation script program. For
example, quote of the day or picture of the day?
I'm not looking for a random roation, I'd like everyone to see the same
thing for one 24 hour period. I'd just like to program the quotes and
pictures for a month period at a time.
Email me with any information you may have, please.
John Mosey
--
Quantum materiae materietur marmota monax si marmota monax materiam possit
materiari?
-- Latin for: How much wood would a woodchuck chuck if a woodchuck could
chuck wood? (sounds better in Latin, doesn't it?)
------------------------------
Date: 17 Sep 1997 23:20:48 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Value within range?
Message-Id: <5vpokg$4bg$1@news.fm.intel.com>
Terry Michael Fletcher - PCD ~ (tfletche@pcocd2.intel.com) so eloquently and verbosely pontificated:
> Craig M. Votava (craig@lucent.com) so eloquently and verbosely pontificated:
> > ---------------------------------------------------------------------
> > #!perl -w
> >
> > my $range = "1..20";
> > my $number = 35;
> >
> > if($number =~ /[$range]/) {print "yes\n"} else {print "no\n"};
> > ----------------------------------------------------------------------
>
> in that regular expression, you have a character class inside the []
> square brackets. remember that it is a giant single-character OR. your
> code creates [1234567891011121314151617181920] which is effectively the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
whoops!! i looked at $range in an array context. :-(
sorry, your code creates the character class [1..20] which is effectively
the class with the four characters [012.]. my bad.
> my @range = (1..20);
> my $number = 18;
> if (grep /$number/, @range) {print "yes\n"} else {print "no\n"};
this might still work if tom's solution still doesn't fit your needs.
sorry!
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
map{$;.=chr$_}(112,114,105,110,116,32,117,110,112,97,99,107,32,34,117,
34);$_=$;.=q>,':2G5S="!A;F]T:&5R(%!E<FP@:&%C:V5R+`H`'>;y[\034]{}d;eval
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 1042
**************************************