[ale] Perl Question

Robert L. Harris Robert.L.Harris at rdlg.net
Thu Sep 26 16:27:54 EDT 2002





$MyGrep=m/<textarea>(.*)</textarea>
print "\$1 $1\n";

Note however that perl is greedy.  If you have:

Pre-data <textarea>some random data</textarea> <textarea>some more random data</textarea> Post Data

Then you will match:

some random data</textarea> <textarea>some more random data


If you know you're looking for something like
Pre-data <textarea>20020926</textarea> <textarea>10:00am</textarea> Post Data

then use:

$MyGrep=m/<textarea>(\d\d\d\d\d\d\d\d)</textarea>
print "\$1 $1\n";

which will look for 8 digits and assign them to $1.  Theres a way to say
something like 8\d but my perl book is at home.



Thus spake cfowler (cfowler at outpostsentinel.com):

> From: cfowler <cfowler at outpostsentinel.com>
> To: ale at ale.org
> X-Mailer: Ximian Evolution 1.0.3 (1.0.3-6) 
> Date: 26 Sep 2002 16:06:42 -0400
> Subject: [ale] Perl Question
> 
> Okay I started doing some perl for testing and have a quick question.
> 
> I have grabed a web page and it is stuck in $resp->content
> 
> How can I walk through that line for line looking for data.
> 
> I actually need what is between <textarea> </textarea>.  The first
> instance of that.
> 
> Thanks,
> Chris
> 
> 
> 
> 
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
> sent to listmaster at ale dot org.



:wq!
---------------------------------------------------------------------------
Robert L. Harris                
                               
DISCLAIMER:
      These are MY OPINIONS ALONE.  I speak for no-one else.
FYI:
 perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list