[19363] in Perl-Users-Digest
Perl-Users Digest, Issue: 1558 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 18 11:05:35 2001
Date: Sat, 18 Aug 2001 08:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998147112-v10-i1558@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Aug 2001 Volume: 10 Number: 1558
Today's topics:
Re: "shifting" values of the @_ array?? <bernie@fantasyfarm.com>
Re: "shifting" values of the @_ array?? (Tad McClellan)
Re: Coercing list context onto pair of regexps in a com <uri@sysarch.com>
Re: Coercing list context onto pair of regexps in a com (Eric Bohlman)
FAQ: How do I select a random line from a file? <faq@denver.pm.org>
Re: Help! Multiple line extract from file based on use <bcaligari@fireforged.com>
Re: Help! Multiple line extract from file based on use <bcaligari@fireforged.com>
Re: Help! Multiple line extract from file based on use <bcaligari@fireforged.com>
Re: Local Perl via browser <samneric@tigerriverOMIT-THIS.com>
Re: Local Perl via browser <pne-news-20010818@newton.digitalspace.net>
Re: Local Perl via browser <Tassilo.Parseval@post.rwth-aachen.de>
Re: Local Perl via browser (Tad McClellan)
Re: Looking for Script (T Mesbah)
Re: Looking for Script (T Mesbah)
Re: newbie regexp question <linux.gadget.guy@home.com>
Re: OT active perl and dos <spamfree@sorted2000.net>
Re: OT active perl and dos <Tassilo.Parseval@post.rwth-aachen.de>
Re: Please help in Regular expression question!! (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Aug 2001 07:24:36 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: "shifting" values of the @_ array??
Message-Id: <ujjsnt48ms14fm8o24qv9cn599ddsbaahd@news.supernews.net>
demerphq@hotmail.com (Yves Orton) wrote:
} > sub method2
} > {
} > my $a = $_[0];
} > print " Method - \$_[0]: $a\n";
} > }
}
} This one is used because of two reasons, first because it is slightly
} faster as there is no intermediate variable, second because it allows
} the original variable to be changed. Remember that @_ is ALIASED to
} the input, NOT copied.
Sorry, but this method copies, also. All three of the methods he mentioned
copy the variable. I'm not sure it is possible to get a 'my'ed variable to
inherit the alias-ness of the argument.
As you point out:
$ perl -e 'sub f {$_[0] = 1;} $b = 2; f($b); die $b'
1 at -e line 1.
yes, @_ has _aliases_ for the variables, but the assignment breaks the
aliasing:
$ perl -e 'sub f { my $a = $_[0] ; $a = 1;} $b = 2; f($b); die $b'
2 at -e line 1.
The only way I know of to get a 'local variable' that preserves the
alias-ness of the calling args is to use a local and some fanciness:
$ perl -e 'sub f { local *a = \$_[0] ; $a = 1;} $b = 2; f($b); die $b'
1 at -e line 1.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Sat, 18 Aug 2001 09:50:27 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "shifting" values of the @_ array??
Message-Id: <slrn9nssl3.ein.tadmc@tadmc26.august.net>
Bernie Cosell <bernie@fantasyfarm.com> wrote:
>I'm not sure it is possible to get a 'my'ed variable to
>inherit the alias-ness of the argument.
[snip]
>The only way I know of to get a 'local variable' that preserves the
>alias-ness of the calling args is to use a local and some fanciness:
>
>$ perl -e 'sub f { local *a = \$_[0] ; $a = 1;} $b = 2; f($b); die $b'
>1 at -e line 1.
You can make use of multiple levels of aliasness though:
------------------------
#!/usr/bin/perl -w
use strict;
$_ = "do what i mean\n";
title_case($_);
print;
sub title_case {
foreach my $str ( @_ ) {
$str =~ s/(\w+)/\u$1/g;
}
}
------------------------
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Aug 2001 09:25:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Coercing list context onto pair of regexps in a comparison
Message-Id: <u28otbycyy.dic@home.sysarch.com>
When will we kill after Zachary reloads the powerful
shelter's mixmaster? Ignatius doesn't load lost investigators, do you
confront them? Joey floats, then Beryl halfheartedly
deletes a clear modem outside Thomas's buffer. Why does
Morris close so admiringly, whenever Ronette learns the
flat RAM very undoubtably? The backup throughout the
lazy room is the hacker that trains dully. What did
Debbie defeat the artichoke about the junk BASIC? My
specialized iteration won't outwit before I disconnect it.
She may stupidly inflate under rogue opaque modules.
Chuck authenticates once, vends weekly, then formats
within the advertisement at the data center. Who will you
exclude the slow virulent ethernets before Beryl does?
What Steven's pathetic ActiveX reboots, Anastasia disappears
inside strong, fake cafes. I was slumping to negotiate you some of my
important outputs. Who doesn't Jason produce freely? Just
vexating with a CDROM alongside the kiosk is too minor for
Will to recycle it. One more connectors easily engulf the
erect DEA. Are you surreptitious, I mean, crawling
without outer rumours?
------------------------------
Date: 18 Aug 2001 13:05:08 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Coercing list context onto pair of regexps in a comparison
Message-Id: <9llp64$rf0$1@bob.news.rcn.net>
Someone forging the name of Uri Guttman <uri@sysarch.com> wrote:
> When Charlie's violent fax machine moans, ...
I think there's potential for a song title here.
------------------------------
Date: Sat, 18 Aug 2001 12:17:04 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I select a random line from a file?
Message-Id: <41tf7.228$V3.171377664@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I select a random line from a file?
Here's an algorithm from the Camel Book:
srand;
rand($.) < 1 && ($line = $_) while <>;
This has a significant advantage in space over reading the whole file
in. A simple proof by induction is available upon request if you doubt
the algorithm's correctness.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
05.34
--
This space intentionally left blank
------------------------------
Date: Sat, 18 Aug 2001 12:19:37 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Help! Multiple line extract from file based on user input.
Message-Id: <9llf7202ima@enews2.newsguy.com>
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m38zgi2pa3.fsf@mumonkan.sunstarsys.com...
> Joe Schaefer <joe+usenet@sunstarsys.com> writes:
>
> > Golf?
> >
> > % perl -pe '@b[grep{$.==$a[$_]}0..$#a]=($_)x@a}BEGIN{$_=shift;
> > s/-/../g;@a=eval}for(@b){' <string> <file>
>
> Better, and one shorter- follows Brendon's approach:
>
> % perl -pe 'exists$h{$.}and$h{$.}=$_}BEGIN{$_=shift;s/-/../g;
> \@h{@a=eval}}for(@h{@a}){' <string> <file>
perl -e " $_=shift;s/-/../g;print ((<>)[eval])" "string" < filename
couldn't get shorter
....however it's reading in the whole file
..and the first line is 0 not 1 :-(
Brendon
------------------------------
Date: Sat, 18 Aug 2001 12:28:21 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Help! Multiple line extract from file based on user input.
Message-Id: <9llfnf02k4u@enews2.newsguy.com>
"B. Caligari" <bcaligari@fireforged.com> wrote in message
news:9llf7202ima@enews2.newsguy.com...
> > > % perl -pe '@b[grep{$.==$a[$_]}0..$#a]=($_)x@a}BEGIN{$_=shift;
> > > s/-/../g;@a=eval}for(@b){' <string> <file>
> >
> > Better, and one shorter- follows Brendon's approach:
> >
> > % perl -pe 'exists$h{$.}and$h{$.}=$_}BEGIN{$_=shift;s/-/../g;
> > \@h{@a=eval}}for(@h{@a}){' <string> <file>
>
> perl -e " $_=shift;s/-/../g;print ((<>)[eval])" "string" < filename
>
>
> couldn't get shorter
> ....however it's reading in the whole file
> ..and the first line is 0 not 1 :-(
perl -e " $_=shift;s/-/../g;print (('',(<>))[eval])" "string" < filename
restors 1 as the index for the first line
B.
------------------------------
Date: Sat, 18 Aug 2001 12:48:58 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Help! Multiple line extract from file based on user input.
Message-Id: <9llgu402nnp@enews2.newsguy.com>
"B. Caligari" <bcaligari@fireforged.com> wrote in message
news:9llfnf02k4u@enews2.newsguy.com...
>
> "B. Caligari" <bcaligari@fireforged.com> wrote in message
> news:9llf7202ima@enews2.newsguy.com...
> > > > % perl -pe '@b[grep{$.==$a[$_]}0..$#a]=($_)x@a}BEGIN{$_=shift;
> > > > s/-/../g;@a=eval}for(@b){' <string> <file>
> > >
> > > Better, and one shorter- follows Brendon's approach:
> > >
> > > % perl -pe 'exists$h{$.}and$h{$.}=$_}BEGIN{$_=shift;s/-/../g;
> > > \@h{@a=eval}}for(@h{@a}){' <string> <file>
> >
> > perl -e " $_=shift;s/-/../g;print ((<>)[eval])" "string" < filename
> >
> >
> > couldn't get shorter
> > ....however it's reading in the whole file
> > ..and the first line is 0 not 1 :-(
>
> perl -e " $_=shift;s/-/../g;print (('',(<>))[eval])" "string" < filename
Actually, there was an extra set of parentheses, and a pointless redirection
perl -e "$_=shift;s/-/../g;print (('',<>)[eval])" "string" filename
B
------------------------------
Date: Sat, 18 Aug 2001 09:26:10 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: Local Perl via browser
Message-Id: <MPG.15e836dfeb8d397d989687@news.usit.net>
William Alexander Segraves wrote:
> "Shah Kashani" <skashani@uk.ibm.com> wrote in message
> news:9liuko$nfi$1@sp15at20.hursley.ibm.com...
> > is it possible to run perl files locally in a browser?
> > I write quite a lot of Perl stuff for the web, and every
> > time I want to test them, I have to keep uploading them.
> Witn MSWindows, TinyWeb (server) works well with localhost. YMMV.
If you don't want to install and configure a webserver, check out Micro Web, by
Indigo Star ( www.indigostar.com/microweb.htm ). Very simple to use with
Activestate's perl, requiring that you only unzip it to a directory.
It allows you to burn an "executable" website onto a CD, but works from a
harddrive. It also allows you to copy/paste your installed perl directory
structure over its own supplied perl directories.
------------------------------
Date: Sat, 18 Aug 2001 15:53:28 +0200
From: Philip Newton <pne-news-20010818@newton.digitalspace.net>
Subject: Re: Local Perl via browser
Message-Id: <8nssntsp9h36j01cascl140366o322p2ms@4ax.com>
On Sat, 18 Aug 2001 09:34:03 +0200, Tassilo von Parseval
<Tassilo.Parseval@post.rwth-aachen.de> wrote:
> Philip Newton wrote:
> > On Fri, 17 Aug 2001 23:40:18 -0400, tadmc@augustmail.com (Tad McClellan)
> > wrote:
> >
> >>It is never possible to run Perl programs in a (major) browser.
> >
> > Then you probably missed the thread here about "Self-Searchable Perl
> > Documentation" that started about three weeks ago. It used PerlScript
> > inside MSIE, IIRC. Those scripts do not, of course, use the CGI, but
> > they were "Perl programs running in a (major) browser".
>
> But you are also missing something. :-)
> The OP asked about running applications written for the web locally.
True.
> PerlScript works on top of ActiveX and thus it is not portable.
Agreed.
What I disagreed with was Tad's categorical statement "Is is never
possible to run Perl programs in a (major) browser". If he had said
something like "you can't do CGI without a web server", I would have
agreed, since PerlScript is not CGI.
> Actually, PerlScript is an approach to client-side scripting whereas the
> opriginal post was very likely about CGI, that is: server-side scripting.
>
> And in this concern, Tad was totally right: It is never possible to run
> programs in a (major) browser.
If you put in 'CGI' there, I'll agree with you. Deal? :)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 18 Aug 2001 16:03:32 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Local Perl via browser
Message-Id: <3B7E75B4.5030303@post.rwth-aachen.de>
Philip Newton wrote:
>>And in this concern, Tad was totally right: It is never possible to run
>>programs in a (major) browser.
>>
>
> If you put in 'CGI' there, I'll agree with you. Deal? :)
Well.......ok, for the sake of comp.lang.perl.misc's peace. :-)
Alright then, EOT for me.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sat, 18 Aug 2001 09:09:28 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Local Perl via browser
Message-Id: <slrn9nsq88.ein.tadmc@tadmc26.august.net>
Philip Newton <pne-news-20010818@newton.digitalspace.net> wrote:
>On Fri, 17 Aug 2001 23:40:18 -0400, tadmc@augustmail.com (Tad McClellan)
>wrote:
>
>> It is never possible to run Perl programs in a (major) browser.
>
>It used PerlScript
>inside MSIE, IIRC.
I knew that of course, but I figure:
PerlScript is not Perl.
If it was, it would be called Perl, not PerlScript.
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Aug 2001 07:26:14 -0700
From: tmesbah@hotmail.com (T Mesbah)
Subject: Re: Looking for Script
Message-Id: <6e9d9699.0108180626.6a53c552@posting.google.com>
1)We need to use the path defined with the static route first because
of the bandwith (path defined with Encryptor)
2) The backup for this path is frame-relay using OSPF
=====
| | ======== ===
=========
| R1 |--- ENCRYPTOR --- ISP1 ----ENCRYPTOR---- R3-------- |
| | ======== === |
===== |
| |
|OSPF
|Switch
| |
======= |
| | Frame Relay ======== == |
| R2 |------------------ ISP2 ------------- R4------------|
| | ======== ==
==========
=======
"Dennis H" <dennis@noreplies.com> wrote in message news:<vBaf7.56128$rV6.2628169@e420r-atl2.usenetserver.com>...
> You could do this by making a floating static route... when the main route
> goes down the floating static will take over... no need to logon and
> reconfigure anything...
>
>
>
> "T Mesbah" <tmesbah@hotmail.com> wrote in message
> news:6e9d9699.0108170605.2eddec74@posting.google.com...
> > The reason of using a static route is that we use encryptor on front
> > of the router and these encryptor block all routing protocols and the
> > only way to make it working is to use static route. I am looking for
> > script to remove the static route and use an another path without
> > caming in at the office and remove them manually.
> >
> > Thanks
> >
> >
> > "Ian M" <ian.mulvihill.no.spam@computer.org> wrote in message
> news:<3b7bc173$0$227$cc9e4d1f@news.dial.pipex.com>...
> > > "Dennis H" <dennis@noreplies.com> wrote in message
> > > news:KGOe7.42984$rV6.2110903@e420r-atl2.usenetserver.com...
> > > >
> > > >
> > > > Uhhhh... why?
> > > >
> > > >
> > > > "T Mesbah" <tmesbah@hotmail.com> wrote in message
> > > > news:6e9d9699.0108151340.4493cafd@posting.google.com...
> > > > > Hi,
> > > > >
> > > > > 1) I have two Cisco router routerA and routerB.
> > > > > 2) In routerA I have static route "ip route X.X.X.X Y.Y.Y.Y Z.Z.Z.Z"
> > > > > to access routerB.
> > > > >
> > > > > I am looking for script that ping routerB each 5 minutes and if
> > > > > routerB is down then the script need to telnet to routerA and remove
> > > > > these static route.
> > > > >
> > > > > Many Thanks
> > > >
> > > >
> > >
> > > That's what routing protocols are for. Is this too easy and efficient?
> > >
> > > Either you have a more complicated and unsual reason to do it this way,
> or
> > > misunderstand the (preferable) options. Do you want clarify what you're
> > > trying to solve, and we could make some suggestions?
> > >
> > >
> > > Cheers,
> > > Ian
------------------------------
Date: 18 Aug 2001 07:31:04 -0700
From: tmesbah@hotmail.com (T Mesbah)
Subject: Re: Looking for Script
Message-Id: <6e9d9699.0108180631.5b238d48@posting.google.com>
1)We need to use the path defined with the static route first because
of the bandwith (path defined with Encryptor)
2) The backup for this path is frame-relay using OSPF
===== STATIC ROUTE
| | ===== === ========
| R1 |--- ENCRY--- ISP1----ENCRY----R3------| |
| | ===== === | |
===== | |
| | |
|OSPF |Switch |
| | |
======= | |
| | ===== == | |
| R2 |------------ ISP2 -------R4--------| |
| | ===== == =========
======= Frame Relay
"Dennis H" <dennis@noreplies.com> wrote in message news:<vBaf7.56128$rV6.2628169@e420r-atl2.usenetserver.com>...
> You could do this by making a floating static route... when the main route
> goes down the floating static will take over... no need to logon and
> reconfigure anything...
>
>
>
> "T Mesbah" <tmesbah@hotmail.com> wrote in message
> news:6e9d9699.0108170605.2eddec74@posting.google.com...
> > The reason of using a static route is that we use encryptor on front
> > of the router and these encryptor block all routing protocols and the
> > only way to make it working is to use static route. I am looking for
> > script to remove the static route and use an another path without
> > caming in at the office and remove them manually.
> >
> > Thanks
> >
> >
> > "Ian M" <ian.mulvihill.no.spam@computer.org> wrote in message
> news:<3b7bc173$0$227$cc9e4d1f@news.dial.pipex.com>...
> > > "Dennis H" <dennis@noreplies.com> wrote in message
> > > news:KGOe7.42984$rV6.2110903@e420r-atl2.usenetserver.com...
> > > >
> > > >
> > > > Uhhhh... why?
> > > >
> > > >
> > > > "T Mesbah" <tmesbah@hotmail.com> wrote in message
> > > > news:6e9d9699.0108151340.4493cafd@posting.google.com...
> > > > > Hi,
> > > > >
> > > > > 1) I have two Cisco router routerA and routerB.
> > > > > 2) In routerA I have static route "ip route X.X.X.X Y.Y.Y.Y Z.Z.Z.Z"
> > > > > to access routerB.
> > > > >
> > > > > I am looking for script that ping routerB each 5 minutes and if
> > > > > routerB is down then the script need to telnet to routerA and remove
> > > > > these static route.
> > > > >
> > > > > Many Thanks
> > > >
> > > >
> > >
> > > That's what routing protocols are for. Is this too easy and efficient?
> > >
> > > Either you have a more complicated and unsual reason to do it this way,
> or
> > > misunderstand the (preferable) options. Do you want clarify what you're
> > > trying to solve, and we could make some suggestions?
> > >
> > >
> > > Cheers,
> > > Ian
------------------------------
Date: Sat, 18 Aug 2001 13:01:19 GMT
From: Fred Richards <linux.gadget.guy@home.com>
Subject: Re: newbie regexp question
Message-Id: <3B7E671D.9090503@home.com>
Tassos Chatzithomaoglou wrote:
>$string = [1.2.3.4.5.6];
>
>$string =~ s/[\[\]]//g;
>@string_temp = split(/\./,$string);
>$string = join(".", $string_temp[0],$string_temp[1],$string_temp[2],$string_temp[3]);
>
>print "str=$string\n";
>
>
>desired output
>--------------
>str=1.2.3.4
>
>I'm sure someone will have a cleverer idea....
>
>
Yet another way of doing it...
#!/usr/bin/perl -w
use strict;
my $string = '[1.2.3.4.5.6]';
$string =~ s/\[((\d+\.){3}\d+).*/$1/;
print "str=$string\n";
The Gadget Guy
------------------------------
Date: Sat, 18 Aug 2001 10:27:54 GMT
From: "spamfree" <spamfree@sorted2000.net>
Subject: Re: OT active perl and dos
Message-Id: <Kqrf7.12066$EV3.930263@news1.cableinet.net>
> > Hi,
> > Sorry for being off topic but cannot get a reply in alt.msdos and other
> > groups after nearly 2 weeks!
> > Trying to debug a large perl script running active perl for windows Dos
> > Version 4.10.2222
> >
> > Is it possible to print the output to a text file via dos?
>
> Yes, of course:
> script.pl > output.txt
Exactly what I was looking for! Thanks
>
> > The output scroll's and the /P and /W switches only work for dir
listings.
>
> For that, you should use 'more':
> script.pl | more
Im having trouble typing the pipe character in dos!
Instead of | I get ¦ from the keyboard, or ^V when pasted from Character
Map!
Any ideas please?
--
millside
_____________
------------------------------
Date: Sat, 18 Aug 2001 12:56:01 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: OT active perl and dos
Message-Id: <3B7E49C1.7030803@post.rwth-aachen.de>
spamfree wrote:
> Im having trouble typing the pipe character in dos!
> Instead of | I get ¦ from the keyboard,
That's fine! I guess these two are actually equivalent. At least, on the
console, my pipe just looks as your DOS-pipe.
Tassilo--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sat, 18 Aug 2001 09:40:52 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Please help in Regular expression question!!
Message-Id: <slrn9nss34.ein.tadmc@tadmc26.august.net>
Eric Chow <eric138@yahoo.com> wrote:
>
>Would you please to teach me how can I get the following result with Regular
>Expression ?
print "$1\n" while /<font[^>]*>([^<]+)/g;
But that is an extremely shaky way of doing it. It will break
easily. It will work only with data like you have shown. It
is likely/possible that you have other data that would cause
it to fail.
Using regexs to "parse" structured markup is the Wrong Thing To Do.
Don't do it.
Use a module that understands whatever markup it is that
you are using (and you haven't told us what that is...).
>data.txt
>===================================================
><small><font color=red size=20>Hello World</font></small>
><small><font color=blue size=22>I am Eric</font></small>
>===================================================
>
>The above is the contents of data.txt.
>
>How can use one Regular Expression, so that it can return "Hello World" and
>"I am Eric" ?
my($hello, $eric) = /(Hello World|I am Eric)/g;
A poor specification often leads to an unsatisfactory implementation.
Can't give a real example (using the appropriate module) because
you have not told us what your data is (HTML, XML, custom...).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 1558
***************************************