[15507] in Perl-Users-Digest
Perl-Users Digest, Issue: 2917 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 1 18:10:27 2000
Date: Mon, 1 May 2000 15:10:18 -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: <957219018-v9-i2917@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 1 May 2000 Volume: 9 Number: 2917
Today's topics:
RE: is there sendmail on Win32 platform <danevans@wanadoo.es>
Re: is there sendmail on Win32 platform <you.will.always.find.him.in.the.kitchen@parties>
RE: is there sendmail on Win32 platform <danevans@wanadoo.es>
Javascript call Perl CGI schnurmann@my-deja.com
Re: looking for Parse::Yapp simple example (Teodor Zlatanov)
mailer problem on WNT <hillr@ugsolutions.com>
more troubleshooting <bh_ent@my-deja.com>
Re: more troubleshooting <tony_curtis32@yahoo.com>
Re: more troubleshooting <bmb@ginger.libs.uga.edu>
Re: Order of evaluation (Was: Re: regex) <iltzu@sci.invalid>
Re: Order of evaluation (Was: Re: regex) <lr@hpl.hp.com>
Re: Please Explain ... print "Location: http:etc."; <jeff@vpservices.com>
Re: Random number (Andrea LN Spinelli)
Re: Reformatting a File (Variable to Fixed) <rootbeer@redcat.com>
Re: Regular Expression and HTML tags <lr@hpl.hp.com>
Re: Regular Expression and HTML tags <rootbeer@redcat.com>
Re: Regular Expression and HTML tags <rudie@wpi.edu>
Re: Regular Expression and HTML tags <lr@hpl.hp.com>
Re: Regular Expression and HTML tags (Ilya Zakharevich)
Re: Regular Expression and HTML tags <rootbeer@redcat.com>
setting an array in a Struct? <crypto_boy@my-deja.com>
Re: subroutines in perl4 <rootbeer@redcat.com>
toggling read-only flag for files in win32 <oliver.rutherfurd@onesoft.com>
VMS Perl system() truncating lines ewilts@my-deja.com
Re: Win98 Pipe problem bennyboy00@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 01 May 2000 18:14:21 GMT
From: "Dan Evans" <danevans@wanadoo.es>
Subject: RE: is there sendmail on Win32 platform
Message-Id: <1QjP4.2265$jv3.206470@m2newsread.uni2.es>
Philip Monitor <brilliance201@hotmail.com> escribió en el mensaje de
noticias 4hbggsga6d050pl72kf5u936979v14t039@4ax.com...
> On Thu, 27 Apr 2000 20:07:05 +0800, "netnews"
> <ya_hsiung@ms2.url.com.tw> wrote:
>
> >as title. so that I use it to send mail and receive mail in my perl
script
> >running on win98.
> >
>
> I'd check out Blat by Tim Charon. I use it and it seems to work
> great.
>
> http://www.interlog.com/~tcharron/
Philip, (or anyone else that knows the answer)
I have been pulling my hair out for over 24 hours with Blat now. I have a
page in a site that needs to be working yesterday, how did you get it to
work? I know the answer is probably staring me in the face, butI can't see
it.
Its an NT system, I can get the script to work fine when run from the
command line on my own machine, but it doesn't work through a web page,
either on my local system or the host. The example that the host gives
doesn't work, and I can't find any documentation to show where I am going
wrong (at least nothing that doesn't give a 404)
Any tips? The recipient is always the same, as is the message (in this case)
so that can be hard coded. As soon as things calm down here I can get onto
it full time and learn all the ins and outs, but at the moment I have a
million and one things to do.
TIA
------------------------------
Date: Tue, 2 May 2000 07:57:01 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: is there sendmail on Win32 platform
Message-Id: <957210958.859171@shelley.paradise.net.nz>
"Dan Evans" <danevans@wanadoo.es> wrote in message
news:1QjP4.2265$jv3.206470@m2newsread.uni2.es...
>
> Philip Monitor <brilliance201@hotmail.com> escribió en el mensaje de
> noticias 4hbggsga6d050pl72kf5u936979v14t039@4ax.com...
> > On Thu, 27 Apr 2000 20:07:05 +0800, "netnews"
> > <ya_hsiung@ms2.url.com.tw> wrote:
> >
> > >as title. so that I use it to send mail and receive mail in my perl
> script
> > >running on win98.
> > >
> >
> > I'd check out Blat by Tim Charon. I use it and it seems to work
> > great.
> >
> > http://www.interlog.com/~tcharron/
>
> Philip, (or anyone else that knows the answer)
>
> I have been pulling my hair out for over 24 hours with Blat now. I have a
> page in a site that needs to be working yesterday, how did you get it to
> work? I know the answer is probably staring me in the face, butI can't see
> it.
>
> Its an NT system, I can get the script to work fine when run from the
> command line on my own machine, but it doesn't work through a web page,
> either on my local system or the host. The example that the host gives
> doesn't work, and I can't find any documentation to show where I am going
> wrong (at least nothing that doesn't give a 404)
>
> Any tips? The recipient is always the same, as is the message (in this
case)
> so that can be hard coded. As soon as things calm down here I can get onto
> it full time and learn all the ins and outs, but at the moment I have a
> million and one things to do.
How is your script calling blat? Remember that blat ne sendmail. They have
totally different flags and perform different functions.
------------------------------
Date: Mon, 01 May 2000 20:36:17 GMT
From: "Dan Evans" <danevans@wanadoo.es>
Subject: RE: is there sendmail on Win32 platform
Message-Id: <5VlP4.2343$jv3.216270@m2newsread.uni2.es>
Tintin <you.will.always.find.him.in.the.kitchen@parties> escribió en el
mensaje de noticias 957210958.859171@shelley.paradise.net.nz...
>
> "Dan Evans" <danevans@wanadoo.es> wrote in message
> news:1QjP4.2265$jv3.206470@m2newsread.uni2.es...
> >
> > Philip Monitor <brilliance201@hotmail.com> escribió en el mensaje de
> > noticias 4hbggsga6d050pl72kf5u936979v14t039@4ax.com...
> > > On Thu, 27 Apr 2000 20:07:05 +0800, "netnews"
> > > <ya_hsiung@ms2.url.com.tw> wrote:
> > >
> > > >as title. so that I use it to send mail and receive mail in my perl
> > script
> > > >running on win98.
> > > >
> > >
> > > I'd check out Blat by Tim Charon. I use it and it seems to work
> > > great.
> > >
> > > http://www.interlog.com/~tcharron/
> >
> > Philip, (or anyone else that knows the answer)
> >
> > I have been pulling my hair out for over 24 hours with Blat now. I have
a
> > page in a site that needs to be working yesterday, how did you get it to
> > work? I know the answer is probably staring me in the face, butI can't
see
> > it.
> >
> > Its an NT system, I can get the script to work fine when run from the
> > command line on my own machine, but it doesn't work through a web page,
> > either on my local system or the host. The example that the host gives
> > doesn't work, and I can't find any documentation to show where I am
going
> > wrong (at least nothing that doesn't give a 404)
> >
> > Any tips? The recipient is always the same, as is the message (in this
> case)
> > so that can be hard coded. As soon as things calm down here I can get
onto
> > it full time and learn all the ins and outs, but at the moment I have a
> > million and one things to do.
>
>
> How is your script calling blat? Remember that blat ne sendmail. They
have
> totally different flags and perform different functions.
With:
Response.Redirect("pathto/cgi-bin/mail.cgi")
from an ASP page after it has updated the database. The bit I am trying to
send is just a confirmation e-mail, that notifies the webmaster that a new
user has registered, so its the same message to the same address each time,
I don't need to pass any variables. $DEITY knows why the host haven't
installed CDONTS support, given that its an NT server running IIS.
TIA
Dan
------------------------------
Date: Mon, 01 May 2000 21:02:40 GMT
From: schnurmann@my-deja.com
Subject: Javascript call Perl CGI
Message-Id: <8ekrd4$pq$1@nnrp1.deja.com>
How might a Javascript call a CGI Perl script? I have two buttons that
are not part of a form. if the user clicks on either, a function is
called by the browser to verify the user's intentions, and if ok, will
call a CGI Perl script passing one parameter.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 1 May 2000 15:24:24 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: looking for Parse::Yapp simple example
Message-Id: <390dd9e8$1_1@news.iglou.com>
<8eg8ma$6n2$1@nnrp1.deja.com>:Tim Richardson (ter@my-deja.com):comp.lang.perl.misc:Sun, 30 Apr 2000 03:18:43 GMT:quote:
:
:
: I want to use Parse::Yapp to process a BAI bank statement. The grammar
: is simple, but I've never used Bison or Yapp. Writing the grammar
: doesn't look too hard, but I don't understand how I put everything
: together. For instance, what does a lexer look like? I'm wondering if
: anyone has a simple, complete example of a Perl script that parses
: something simple using Parse::Yapp.
I realize that you are looking for Parse:Yapp examples, but maybe
Parse::RecDescent will do the job for you? Check out this article:
http://www-4.ibm.com/software/developer/library/perl-parsing/
and that plus Damian's tutorial included with the Parse::RecDescent
module will be enough to get you started.
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
------------------------------
Date: Mon, 01 May 2000 13:16:23 -0700
From: Ron Hill <hillr@ugsolutions.com>
Subject: mailer problem on WNT
Message-Id: <390DE616.12BA8F9B@ugsolutions.com>
Hello All,
I am writting a program that extracts information from a database and
e-mail it using the Mail::Mailer module. the program will run however I
receive a Error: Runtime exception when the program gets to the write
command. I can't figure out why. I have changed the select to point to
STDOUT and it works, however if I try to select the $mailer filehandle I
receive the error. If anyone has an idea I would like to know.
Thanks
======================================================================
use DBI;
use Mail::Mailer;
use strict;
use vars qw($mailer $pr_number $desc $user_id $server_id
$family_release);
eval {
$mailer = Mail::Mailer->new("smtp", "cypntx");
$mailer ->open({'From' =>'hillr@ugsolutions.com',
'To' =>'hillr@ugsolutions.com',
'Subject' =>'Open PR listing for Systems group'});
};
if ($@) {
print "Could not connect to mail system\n";
}
my $statement="SELECT
pr_id,short_desc,user_id,reporting_server_id,family_release
FROM ir_table, pr_table, call_master_table
WHERE ir_id = call_master_id and call_master_id = pr_id and group_id =
65301
and pr_table.status in ('DO','EC','I','IC','O','OF','PT','VO','WF')ORDER
by family_release";
my $dbh = DBI->connect('dbi:ODBC:tac', '', '') || die $DBI::errstr;
$dbh->{RaiseError} = 1;
my $sth = $dbh->prepare("$statement");
select($mailer);
$~="MAIL_OUT";
$sth->execute;
my $rv = $sth->bind_columns(\$pr_number, \$desc, \$user_id, \$server_id,
\$family_release);
while ( $sth->fetch ) {
write ($mailer);
}
$mailer->close;
format MAIL_OUT_TOP =
PR Listing for the Systems Group
---------------------------------------------------------------------
.
format MAIL_OUT =
@<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$pr_number, $desc
~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$desc
~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$desc
@<<<<<<< @<<<<<<<< @<<<<<<<
$user_id,$server_id,$family_release
.
------------------------------
Date: Mon, 01 May 2000 19:44:26 GMT
From: bh <bh_ent@my-deja.com>
Subject: more troubleshooting
Message-Id: <8ekmqm$r81$1@nnrp1.deja.com>
ok. I am horrible at substition, but according to my books this should
work (I'm missing something obviously, I just don't know what).
The $umask = "umask 022"
I am trying to trim the variable down to simply the numerical portion.
This is how I am trying to do it.
print "$umask\n";
$umask =~ s/$umask/\d{3}/;
print $umask;
All I get on the output is "d{3}"
I want to get "022"
Help!?!!?
--
bh
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 01 May 2000 14:56:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: more troubleshooting
Message-Id: <87g0s2kpt2.fsf@shleppie.uh.edu>
>> On Mon, 01 May 2000 19:44:26 GMT,
>> bh <bh_ent@my-deja.com> said:
> ok. I am horrible at substition, but according to my
> books this should work (I'm missing something obviously,
> I just don't know what).
> The $umask = "umask 022"
> I am trying to trim the variable down to simply the
> numerical portion. This is how I am trying to do it.
> print "$umask\n"; $umask =~ s/$umask/\d{3}/; print
> $umask;
> All I get on the output is "d{3}" I want to get "022"
Your s/// says "substitute for the value $umask the string
\d{3}. Backslashing d has no effect so that leaves d{3}.
The LHS is the pattern you want to look for (the regex)
and the RHS is what you are replacing with.
s/$umask\s+(\d{3})/$1/;
is presumably what you want. OTOH if you know that it
always begins with "umask " why not just
$umask =~ s/^umask //;
or avoid the overhead of regexes altogether and use
substr(), q.v.
hth
t
------------------------------
Date: Mon, 1 May 2000 16:05:37 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: more troubleshooting
Message-Id: <Pine.A41.4.10.10005011557100.13002-100000@ginger.libs.uga.edu>
On Mon, 1 May 2000, bh wrote:
> ok. I am horrible at substition, but according to my books this should
> work (I'm missing something obviously, I just don't know what).
>
> The $umask = "umask 022"
>
> I am trying to trim the variable down to simply the numerical portion.
> This is how I am trying to do it.
>
> print "$umask\n";
> $umask =~ s/$umask/\d{3}/;
> print $umask;
>
> All I get on the output is "d{3}"
> I want to get "022"
>
> Help!?!!?
> --
>
> bh
You are using matching metacharacters on the "plain string" side of the
substitution, i.e., s/\d/x/ does what you think, but s/x/\d/ doesn't.
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 my $umask = 'umask 022';
5
6 ### if you just want to print it
7 print "$1\n" if $umask =~ /(\d{3})/;
8
9 ### if you want to change it
10 $umask =~ s/.*(\d{3})/$1/;
11 print "$umask\n";
Output:
022
022
--
Brad
------------------------------
Date: 1 May 2000 18:01:29 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Order of evaluation (Was: Re: regex)
Message-Id: <957203226.17898@itz.pp.sci.fi>
In article <v%ZO4.10396$x4.355417@newsread1.prod.itd.earthlink.net>, Peter Scott wrote:
>.. is documented as being left-associative. Are there any cases where
>evaluation happens in a different order from associativity?
?:
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Mon, 1 May 2000 12:39:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Order of evaluation (Was: Re: regex)
Message-Id: <MPG.13777d52735f579198a9c0@nntp.hpl.hp.com>
In article <v%ZO4.10396$x4.355417@newsread1.prod.itd.earthlink.net> on
Sun, 30 Apr 2000 17:24:43 GMT, Peter Scott <peter@jetcafe.org> says...
> In article <MPG.1374a95e311095a998a9b5@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> writes:
...
> |> Perl should document either that the order of evaluation of the operands
> |> of a binary operator is in general unspecified, or it should document
> |> that it is left-to-right. In the absence of either specification,
> |> assertions such as yours are suspect.
>
> .. is documented as being left-associative. Are there any cases where
> evaluation happens in a different order from associativity? It appears
> there is language in perlop implying that associativity => evaluation order.
I couldn't find such a statement. Left-associativity means that given,
say, a . b . c , one can be assured that that is evaluated as
(a . b) . c
Of the six possible evaluation orders, that rules out
a c b
b c a
But the following *might* still be permitted:
a b c (which is what everyone assumes)
b a c
c a b
c b a
You may think I am being perverse or obstinate even to raise these
issues for Perl. But my C indoctrination screams out for clarity.
As an example, someone today posited in Fun With Perl the equivalence of
the following two expressions (except for the side-effect change in the
final value of $_):
$_ & $_ - 1
$_ & --$_
To which I say, how the hell do you know that? Perhaps the decrement
occurs first, so the second expression is equivalent to:
$_ - 1 & $_ - 1
In C, the behavior of an expression with side effects such as that would
be specifically 'unspecified', associativity be damned. The Standard is
explicit about this (Section 2.1.2.3):
<QUOTE>
The grouping of an expression does not completely determine its
evaluation. In the following fragment
#include <stdio.h>
int sum;
char *p;
/*...*/
sum = sum * 10 - '0' + (*p++ = getchar());
the expression statement is grouped as if it were written as
sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));
but the actual increment of p can occur at any time between the previous
sequence point and the next sequence point (the ;), and the call to
getchar can occur at any point prior to the need of its returned value.
</QUOTE>
A lot of thought went into this area, because of the variety of possible
implementations of the language specification. Perl is more firtunate,
because there is only one 'implementation'. Its behavior can (and, I
think, should) be specified explicitly in this and other areas.
(For example, we all now assume correctly -- based on the behavior of
the implementation -- that the value of a Boolean expression in
numerical context is 1 or 0. I defy anyone to show me that in perlop;
all I can find is TRUE or FALSE.)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 12:56:05 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please Explain ... print "Location: http:etc.";
Message-Id: <390DE155.E7DC49BF@vpservices.com>
Drew Simonis wrote:
>
> "Alan J. Flavell" wrote:
>
> > Again to be pedantic, RFC2616 (which obsoleted RFC2068) specifies the
>
> <lots of impressive info snipped>
>
> > all the best
>
> Where do you learn all this??? Im consistently amazed.
Me too. Two things that impress me about Alan -- over *40* years of
experience with computers (and can you imagine, he still puts up with
usenet, after all that!); and he consistently checks the specifications
for anything he answers. Many's the time I have checked some RFC before
replying to a newsgroup because I knew if I didn't, Alan would
rightfully call me to task.
--
Jeff
------------------------------
Date: Mon, 01 May 2000 21:56:37 GMT
From: aspinelli@ismes.it (Andrea LN Spinelli)
Subject: Re: Random number
Message-Id: <390dfe42.29226538@news.iol.it>
On Fri, 28 Apr 2000 12:17:31 GMT, "Chello" <stephane@siw.ch> wrote:
> I have to generate a random number with two limits
>(upper limit and down limit) for example 1 and 4. When I call the script
>this script would have to display "1" or "2" or "3" or "4".
#!perl -w
use strict;
# return an integer in the interval - limits included
sub RandomIntIn
{
my ($min,$max)=@_;
return $min + int( rand( $max - $min + 1 ) );
}
# test - <RET> to see another number, q to stop
my $a = 'x' ;
while( $a =~ /^[^qQ]/ ){
print RandomIntIn( 1, 4 );
$a = <>;
}
# CAVEATS : $min < $max or disaster
# int($min) == $min or disaster
# only integers are returned; this seems to be the intended
# meaning (although it is not the letter of the request)
------------------------------
Date: Mon, 1 May 2000 11:09:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Reformatting a File (Variable to Fixed)
Message-Id: <Pine.GSO.4.10.10005011106350.13677-100000@user2.teleport.com>
On Mon, 1 May 2000 mkrol@my-deja.com wrote:
> Is there a way to convert a file that has variable length records to a
> file with fixed length records using a Perl script?
Sure; it's probably a one-liner, in fact.
I'm interpreting your question to be something like, "Is there a perl
program which will read a file that has variable-length records and output
the same data as a file of fixed-length records." If I've gotten that
wrong, you may wish to ask again.
> I have a file with 25 records that are 238 chars long, but when I Ftp
> the file to an IBM MVS system the file is showing as variable length
> (255 chars long).
That sounds as if you didn't transfer the file correctly. Did you use
binary mode on a text file, or vice versa?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 1 May 2000 11:08:03 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular Expression and HTML tags
Message-Id: <MPG.137767dcd97f1d6f98a9be@nntp.hpl.hp.com>
In article <Pine.OSF.4.21.0005011214500.18494-100000@bert.WPI.EDU> on
Mon, 1 May 2000 12:22:20 -0400, Brian Murphy <rudie@wpi.edu> says...
> Here is a quick lowdown of what I am doing.
Here is a quick sketch of a better way to do it.
> The html:
<reproduced below>
> The text is always surrounded by a <P>\n on both sides.
That is the key to the solution. Use $/, the input record separator.
See perlvar.
This code isolates and prints everything between "<P>\n" separators that
contains at least one non-space character. Adopt and adapt as desired.
#!/usr/bin/perl -w
use strict;
{
local $/ = "<P>\n";
while (<DATA>) {
chomp;
next unless /\S/;
print; # Or whatever you want to do with $_.
}
}
__END__
<P>
MAY 5...AT THE LONG ISLAND ZOO...BANE, SKYCAMEFALLING, FAHRENHEIT 451,
NEWGROUND,AKIN, STRONGPOINT...6PM...$7<A
HREF="mailto:bullprod@earthlink.net">bullprod@earthlink.net</A>
<P>
<P>
May 19 - Swingset LI - glassjaw, shelter, bane, shai hulud,
thisyearsmodel,six pm, $10
<P>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 1 May 2000 11:17:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Regular Expression and HTML tags
Message-Id: <Pine.GSO.4.10.10005011110380.13677-100000@user2.teleport.com>
On Mon, 1 May 2000, Brian Murphy wrote:
> Subject: Regular Expression and HTML tags
It's not possible to parse HTML with simple regular expressions; use
HTML::Parser or another module instead.
> while($content =~ /<P>\n(.*\n?)(.*\n?)($group.*)\n(.*\n)(.*\n)(.*\n)/gmi){
Eek!
What do you think the /m option is doing? It's probably not doing what you
think.
> This works sometimes, but there has to be a better method. I would loive
> to be able to do the following, and still be able to print it out:
>
> while($content =~ /<P>/\n(.*\n?)*(.*$group)(.*/n*)*<P>/igm){
It may become a "neverending" pattern if you include /(.*\n?)*/. See
Jeffrey Friedl's excellent book Mastering Regular Expressions for more
information.
> Can anyone tell me (.*\n?)* translates with $1, $2, $3?
If I understand your question correctly, you're wanting to know what's
left in the corresponding memory variable when the parens were used with a
quantifier. The answer is, "the last thing matched". If you want to get
everything that that sub-expression matched, use parens which include the
quantifier. But you're still in danger of having a "neverending" pattern
that will lock up your program. :-P
HTML::Parser may not be trivial to use, but it may be just what you need.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 1 May 2000 14:53:19 -0400
From: Brian Murphy <rudie@wpi.edu>
Subject: Re: Regular Expression and HTML tags
Message-Id: <Pine.OSF.4.21.0005011450070.32448-100000@bert.WPI.EDU>
>
>#!/usr/bin/perl -w
>use strict;
>
>{
> local $/ = "<P>\n";
> while (<DATA>) {
> chomp;
> next unless /\S/;
> print; # Or whatever you want to do with $_.
> }
>}
This seems wonderful to me. I ran to check out the pod on perlvar, and
feel like I know more, except here is the next problem. What I am
"grepping" through is a huge variable string. Basically, I use LWP to get
the url file, and then search through it for a string.
This means that <DATA> is not what I am using here. Any idea on how to do
the while(<DATA>) except with $content, which is the url file? The rest I
can imagine right now. Real simple. Thanks so far though.
------------------------------
Date: Mon, 1 May 2000 13:30:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular Expression and HTML tags
Message-Id: <MPG.13778952428aee3e98a9c1@nntp.hpl.hp.com>
In article <Pine.OSF.4.21.0005011450070.32448-100000@bert.WPI.EDU> on
Mon, 1 May 2000 14:53:19 -0400, Brian Murphy <rudie@wpi.edu> says...
> >
> >#!/usr/bin/perl -w
> >use strict;
> >
> >{
> > local $/ = "<P>\n";
> > while (<DATA>) {
> > chomp;
> > next unless /\S/;
> > print; # Or whatever you want to do with $_.
> > }
> >}
>
> This seems wonderful to me. I ran to check out the pod on perlvar, and
> feel like I know more, except here is the next problem. What I am
> "grepping" through is a huge variable string. Basically, I use LWP to get
> the url file, and then search through it for a string.
>
> This means that <DATA> is not what I am using here. Any idea on how to do
> the while(<DATA>) except with $content, which is the url file? The rest I
> can imagine right now. Real simple. Thanks so far though.
So assuming the entire file is in the string $content, you could do
something like this:
while ($content =~ m!(.*?)<P>\n!gs) {
next unless (my $entry = $1) =~ /\S/;
print $entry; # Or whatever you want to do with $entry.
}
See perlre for explanation of the regex and its modifiers.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 May 2000 21:13:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regular Expression and HTML tags
Message-Id: <8eks1e$lq5$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Phoenix
<rootbeer@redcat.com>],
who wrote in article <Pine.GSO.4.10.10005011110380.13677-100000@user2.teleport.com>:
> It's not possible to parse HTML with simple regular expressions; use
> HTML::Parser or another module instead.
Depends on how simple is "simple".
Ilya
------------------------------
Date: Mon, 1 May 2000 14:43:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Regular Expression and HTML tags
Message-Id: <Pine.GSO.4.10.10005011442400.13677-100000@user2.teleport.com>
On 1 May 2000, Ilya Zakharevich wrote:
> > It's not possible to parse HTML with simple regular expressions;
> Depends on how simple is "simple".
And how possible is "possible". But nobody wants to hear what my
definition of "is" is.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 01 May 2000 21:24:28 GMT
From: Crypto-Boy <crypto_boy@my-deja.com>
Subject: setting an array in a Struct?
Message-Id: <8eksln$271$1@nnrp1.deja.com>
Two questions:
Given the declaration
struct Family => { members => '@' };
1) Why doesn't this work for setting the array:
$Family->members(\@myArray);
2) This code works, but what the heck does that weird syntax mean?
@{$Family->members} = @myArray;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 1 May 2000 12:17:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: subroutines in perl4
Message-Id: <Pine.GSO.4.10.10005011210280.13677-100000@user2.teleport.com>
On 1 May 2000, Victor Eijkhout wrote:
> Did subroutines exist in perl4? Is there a way of calling them that
> works in 4 and 5?
Yes; see the manpage for your antique - the old ways still work.
> Please don't tell me to update; the machine is not mine,
> and my script will have to run on it....
You don't have to fix the machine, but maybe you should consider fixing
your career: If you are talented enough that you can keep things
backwards-compatible with software from the days when Macaulay Culkin was
still making movies, you can certainly find a job where you won't have to.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 1 May 2000 16:59:56 -0400
From: "Ollie Rutherfurd" <oliver.rutherfurd@onesoft.com>
Subject: toggling read-only flag for files in win32
Message-Id: <8ekqso$9g8$1@bob.news.rcn.net>
Hi,
I've written a little script to replicate a directory tree, but the
File:Copy function 'copy' fails when the destination files already exist and
are read-only. I've got permission to change this flag, but can this be
done programatically using perl (so I can incorporate it into the script)?
BTW, I'm using 5.6 on NT 4.0.
Thanks,
-Ollie
oliver@rutherfurd.net
------------------------------
Date: Mon, 01 May 2000 20:45:28 GMT
From: ewilts@my-deja.com
Subject: VMS Perl system() truncating lines
Message-Id: <8ekqd3$ver$1@nnrp1.deja.com>
One of my developers is reporting that the Perl system() call is
truncating the argument to 256 characters. I'm running Perl 5.005_03.
Is this a known limitation? Can this limit to be expanded to 1K or
more?
Thanks,
.../Ed
Ed Wilts
mailto:ewilts@mediaone.net
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 01 May 2000 18:40:16 GMT
From: bennyboy00@my-deja.com
Subject: Re: Win98 Pipe problem
Message-Id: <8ekj2d$n12$1@nnrp1.deja.com>
> bennyboy00@my-deja.com wrote:
> > Ok, so I ran the following 2 programs on win98.
> >
> > #!/usr/local/bin/perl -w
> > use strict;
> > open(Reader, 'dir|') or die "Cannot open pipe";
> > while(<Reader>) {
> > print $_;
> > }
> >
> > This programs hangs forever on win98 when it gets to the $_.
>
> Very odd. As you have noted, this works perfectly on NT. I don't
have
> access to Win 98 at the moment, so I can't verify your results. Have
> you tried other commands to read from such as 'echo hi|' or the
> incestuous 'perl -e "print qq(hi\n)"|'? This way you can control your
> input.
I changed the test program to try other methods of input such as
open(Reader, 'route|'). It worked perfectly when I used the open
command on the route statement. Also it worked on various other
statements like perl -e... It failed when I tried commands like 'dir'
that are built into command.com. It worked when it came to commands
like 'route' that are external programs. So I guess there is something
with the way that command.com returns it's output on built-in commands
vs external programs that doesn't work with perl pipes.
So, the question is now, how can I do an equivelant of open(Reader,
'dir|') for any command.com built-in command? I have to be able to step
though the output step by step, as our real-world application prohibits
us from doing a print <Reader> and skipping the loop.
~Ben
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 2917
**************************************