[22744] in Perl-Users-Digest
Perl-Users Digest, Issue: 4965 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 14:11:23 2003
Date: Fri, 9 May 2003 11:10:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 9 May 2003 Volume: 10 Number: 4965
Today's topics:
pattern match A or B with Y or Z <user@someserver123abc.com>
Re: pattern match A or B with Y or Z <noreply@gunnar.cc>
Re: pattern match A or B with Y or Z <user@someserver123abc.com>
Re: pattern match A or B with Y or Z <usenet@dwall.fastmail.fm>
Re: pattern match A or B with Y or Z <user@someserver123abc.com>
Re: regex to extract number <barryk2@SPAM-KILLER.mts.net>
retrieve actuate report from the web (Samara)
Re: retrieve actuate report from the web <jurgenex@hotmail.com>
Re: Total Utter Just Delivered Perl Newbie with a Pigna <goedicke@goedsole.com>
Re: Total Utter Just Delivered Perl Newbie with a Pigna (Tad McClellan)
Re: Total Utter Just Delivered Perl Newbie with a Pigna <roderick991@yahoo.com>
UnixDate semantics change (Skip Montanaro)
Re: waste of time <roderick991@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 09 May 2003 11:04:39 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: pattern match A or B with Y or Z
Message-Id: <3EBBC387.BA1A099@someserver123abc.com>
how would you find pattern A or B and replace it with Y or Z?
If we find A, we replace it with Y.
If we find B, we replace it with Z.
I *think* I've seen this before but don't remember.
I can imagine:
$var =~ s/(a)|(b)/a|b/g;
but that does not work like I want it to.
------------------------------
Date: Fri, 09 May 2003 17:06:57 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <b9gglr$jbl0a$1@ID-184292.news.dfncis.de>
stinkbomb wrote:
> how would you find pattern A or B and replace it with Y or Z?
> If we find A, we replace it with Y.
> If we find B, we replace it with Z.
>
> I *think* I've seen this before but don't remember.
>
> I can imagine:
> $var =~ s/(a)|(b)/a|b/g;
> but that does not work like I want it to.
$var =~ s/(a)|b/$1 ? 'x' : 'y'/eg;
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 09 May 2003 11:48:18 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <3EBBCDC2.4EDA6091@someserver123abc.com>
Yes!
question mark (?), that's what it was!
Thanks!
Gunnar Hjalmarsson wrote:
>
> stinkbomb wrote:
> > how would you find pattern A or B and replace it with Y or Z?
> > If we find A, we replace it with Y.
> > If we find B, we replace it with Z.
> >
> > I *think* I've seen this before but don't remember.
> >
> > I can imagine:
> > $var =~ s/(a)|(b)/a|b/g;
> > but that does not work like I want it to.
>
> $var =~ s/(a)|b/$1 ? 'x' : 'y'/eg;
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 09 May 2003 16:56:11 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <Xns93768398791EBdkwwashere@216.168.3.30>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> stinkbomb wrote:
>> how would you find pattern A or B and replace it with Y or Z?
>> If we find A, we replace it with Y.
>> If we find B, we replace it with Z.
>>
>> I *think* I've seen this before but don't remember.
>>
>> I can imagine:
>> $var =~ s/(a)|(b)/a|b/g;
>> but that does not work like I want it to.
>
> $var =~ s/(a)|b/$1 ? 'x' : 'y'/eg;
Not that there's anything particularly wrong with that, but in my
opinion it would be easier to read if it were in two lines of code.
$var =~ s/A/Y/g;
$var =~ s/B/Z/g;
Same effect, but you don't have to trace the logic.
Also, if pattern A is logically false, you won't get what you want.
For example,
my $var = '0011';
$var =~ s/(0)|1/$1 ? 'Y' : 'Z'/eg;
print $var;
will print 'ZZZZ' instead of 'YYZZ'.
--
David Wall
------------------------------
Date: Fri, 09 May 2003 13:52:29 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <3EBBEADD.85703A6E@someserver123abc.com>
"David K. Wall" wrote:
>
.......
>
> Not that there's anything particularly wrong with that, but in my
> opinion it would be easier to read if it were in two lines of code.
>
> $var =~ s/A/Y/g;
> $var =~ s/B/Z/g;
>
in your example,
if the pattern is:
$var="<>";
and I decided to:
$var =~ s/</<font color="#ff0000"><<\/font>/g;
$var =~ s/>/<font color="#ff0000">><\/font>/g;
we would have a problem.
see why I have to do one line in one shot?
> Same effect, but you don't have to trace the logic.
>
> Also, if pattern A is logically false, you won't get what you want.
> For example,
>
> my $var = '0011';
> $var =~ s/(0)|1/$1 ? 'Y' : 'Z'/eg;
> print $var;
>
> will print 'ZZZZ' instead of 'YYZZ'.
>
> --
> David Wall
------------------------------
Date: Fri, 9 May 2003 08:11:50 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: regex to extract number
Message-Id: <MPG.19256511fad37eb39897c3@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <1052431740.161075@minime.linuxiceberg.com>, Chris Fowler
(cfowler@linuxiceberg.com) says...
> Maybe someone can help me here. I have the following line I'm receving by a
> remote syslog server
>
>
> <38>login[72]: login exiting
>
> I want to break it into 2 parts.
>
> 1) The numbe part.
> 2) The message after '>'
>
> Can someone give me a regex that will extract that info?
>
> Thanks,
> Chris
>
$buffer = "<38>login[72]: login exiting";
$buffer =~ m/^(<\d+>)(.*)$/;
$first_part = $1;
$message = $2;
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: 9 May 2003 07:20:46 -0700
From: prokurator@aol.com (Samara)
Subject: retrieve actuate report from the web
Message-Id: <d45e82a2.0305090620.76122904@posting.google.com>
I need to write perl script to go to specific URL, retrieve report
from that site, parse it, and update database accordingly.
Reports I am looking for are generated by using Actuate reporting
tool.
Those reports have been generated dynamically upon recieving requests
from the browser and there are no static pages on the web site I am
trying to access.
Every time I go to that site to view reports from browser I type my
username and
password and source code contains a link like this "<IMG
SRC='/cgi-bin/nph-actuate.cgi/acweb/reports/__default/my_company_name/date_of_the_report/name_of_the_report'>.
Can someone to help.
------------------------------
Date: Fri, 09 May 2003 14:27:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: retrieve actuate report from the web
Message-Id: <BVOua.33$f71.11@nwrddc03.gnilink.net>
Samara wrote:
> I need to write perl script to go to specific URL, retrieve report
> from that site,
perldoc -q fetch: " How do I fetch an HTML file?"
> parse it,
perldoc -q HTML: "How do I remove HTML from a string?" (this may not be
literally the same question, but the answer is the same)
> and update database accordingly.
I'd guess you would use one of the database modules from CPAN.
jue
------------------------------
Date: Fri, 09 May 2003 13:19:43 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <m3addww93r.fsf@mail.goedsole.com>
Dear Rod -
"Rod" <roderick991@yahoo.com> writes:
> Can you just call Perl as you would with a a shell script with
> arguments, if so how (?) as all the examples I've seen make it far
> more complicated than a shell script for accepting command line
> arguments, dealing with STDIN as you would with C using ARGV, ARGC
>
> #!/bin/sh
> # change to home directory
> cd $HOME
> case $# in
> 0) echo " no arguments" ;;
> 1) echo "one argument $1";;
> 2) echo "two arguments $2";;
> *) echo "bugger!";;
> esac
I don't see that it's "far more complicated". As with any language it
takes some time to become familiar with the syntax and idioms.
#!/usr/local/bin/perl
# change to home directory
cd $ENV{'HOME'};
if ( $#ARGV < 0 ) { print " no arguments" ; }
elsif ( $#ARGV == 0 ) { print "one arguments $ARGV[0]\n" ; }
elsif ( $#ARGV == 1 ) { print "two arguments $ARGV[1]\n" ; }
else { print "bugger!" ; }
> If it's so great why all the overhead as you don't need in a bash
> script ??
Because you it allows you to do more.
Yours - Billy
============================================================
William Goedicke goedicke@goedsole.com
http://www.goedsole.com:8080
============================================================
Lest we forget:
Conversation: A series of digressions.
- Kevin Montuori
------------------------------
Date: Fri, 9 May 2003 08:18:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <slrnbbnalu.2fg.tadmc@magna.augustmail.com>
Rod <roderick991@yahoo.com> wrote:
> I'm new with Perl, wet behind the ears even,
Please check out the Posting Guidelines that are posted here frequently.
> Can you just call Perl as you would with a a shell script with arguments,
Yes.
> if
> so how (?)
as you would with a a shell script with arguments:
my_perl_script arg1 arg2
> #!/bin/sh
> # change to home directory
> cd $HOME
> case $# in
> 0) echo " no arguments" ;;
> 1) echo "one argument $1";;
> 2) echo "two arguments $2";;
> *) echo "bugger!";;
> esac
(untested!)
#!/usr/bin/perl
use warnings;
use strict;
chdir;
if ( @ARGV == 0 )
{ print "no arguments\n" }
elsif ( @ARGV == 1 )
{ print "one argument $ARGV[0]\n" }
elsif ( @ARGV == 2 )
{ print "one argument $ARGV[1]\n" }
else
{ print "bugger!\n" }
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 9 May 2003 12:24:14 +1000
From: "Rod" <roderick991@yahoo.com>
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <b9gdkc$jeaa2$1@ID-82947.news.dfncis.de>
William Goedicke <goedicke@goedsole.com> wrote in message
news:m3addww93r.fsf@mail.goedsole.com...
: Dear Rod -
:
: "Rod" <roderick991@yahoo.com> writes:
:
: > Can you just call Perl as you would with a a shell script with
: > arguments, if so how (?) as all the examples I've seen make it far
: > more complicated than a shell script for accepting command line
: > arguments, dealing with STDIN as you would with C using ARGV, ARGC
: >
: > #!/bin/sh
: > # change to home directory
: > cd $HOME
: > case $# in
: > 0) echo " no arguments" ;;
: > 1) echo "one argument $1";;
: > 2) echo "two arguments $2";;
: > *) echo "bugger!";;
: > esac
:
: I don't see that it's "far more complicated". As with any language it
: takes some time to become familiar with the syntax and idioms.
:
: #!/usr/local/bin/perl
: # change to home directory
: cd $ENV{'HOME'};
: if ( $#ARGV < 0 ) { print " no arguments" ; }
: elsif ( $#ARGV == 0 ) { print "one arguments $ARGV[0]\n" ; }
: elsif ( $#ARGV == 1 ) { print "two arguments $ARGV[1]\n" ; }
: else { print "bugger!" ; }
:
: > If it's so great why all the overhead as you don't need in a bash
: > script ??
:
: Because you it allows you to do more.
:
very helpful, all the examples I have seen have been STDIN or filehandles.
------------------------------
Date: 9 May 2003 08:16:31 -0700
From: skip@pobox.com (Skip Montanaro)
Subject: UnixDate semantics change
Message-Id: <727daa7e.0305090716.b420d02@posting.google.com>
I use Perl infrequently, and almost always in a Mason context. At some point
in the past, it appears
UnixDate("<format string>")
used to assume an implicit "now", as in
UnixDate("now", "<format string>")
Calls of the first form now return undef.
Some code I inherited used the first form extensively to store last access time
in the session hash. With the new semantics it caused problems which,
because of my minimal Perl skills, took me a long time to uncover.
Is there some way I could have coaxed Mason or mod_perl or something
into barfing noisily instead of silently returning undef?
Thanks,
Skip Montanaro
skip@pobox.com
------------------------------
Date: Fri, 9 May 2003 11:28:15 +1000
From: "Rod" <roderick991@yahoo.com>
Subject: Re: waste of time
Message-Id: <b9gabe$io9qi$1@ID-82947.news.dfncis.de>
Dear Sir,
I openly admit to being a novice, but have found the help here invaluable,
methinks you are a little thin skinned, and expecting of others.
If you walked into a new cube farm tomorrow and were told make X changes to
Y system , code and system test by Tuesday what would you do ? harass the
next person and ask him how to do it for you while he.she is doing their
own work and probably had to learn the hard way without assisatance ?
Obviously never worked in the days of punched cards. Three compiles !
Go contracting son. The harsh realities of life will hit you over the head
like a ton of bricks. These people are doing you a favour by encouraging you
to be proactive. Can't find it within you to do that ?
Thank you to the people here for your tolerance and invaluable assistance.
Rod
smugbuster <smugbuster@hotmail.com> wrote in message
news:677cff64.0304300948.7e8878c4@posting.google.com...
: your little newsgroup or whatever you call it is a waste of time for
: anybody trying to learn anything new.
:
: legitimate questions are disparaged, ridiculed, and made fun of.
: what's wrong with you people? you were all newbies once!
:
: my guess is that half of you don't know what you're talking about
: anyway.
:
: don't you have anything better to do than to get online and "flame"
: people that may not have as much knowledge of the subject as you.
: pathetic.
:
: i suggest you get a life. you're all a little too smug for your own
: good.
:
: oh, also, i guess i'm not cool because i don't have a witty quip at
: the end of my message, or use case sensitive words or end plural words
: with a string of "z's."
:
: jack
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 4965
***************************************