[Memphis.pm] Regexes, finding a <BR> tag and throwing into arrays.

Hal Phillips HPhillips at harrahs.com
Tue Apr 17 08:08:41 CDT 2001


>From my buddy Steve, who I'm encouraging to join the list...
-Hal
>>
This works for me.  Send it on to Brock if you would please.

#!/usr/bin/perl

while( <DATA> )
{
   @names = map { /(.+?<br>)/gi } $_;

   print( join( "\n", @names ), "\n" );
}
__DATA__
foo1<BR>foo2<BR>foo3<BR>foo4<BR>


	-----Original Message-----
	From:	Hal Phillips 
	Sent:	Tuesday, April 17, 2001 7:49 AM
	To:	Steve Turman
	Subject:	FW: [Memphis.pm] Regexes, finding a <BR> tag and
throwing into arrays.

	Hey Man, are you on the perl monger's list?  We should start
some conversations on there.
	-hp

	-----Original Message-----
	From:	Brock Sides [SMTP:philarete at mindspring.com]
	Sent:	Tuesday, April 17, 2001 7:13 AM
	To:	memphis-pm-list at pm.org
	Subject:	Re: [Memphis.pm] Regexes, finding a <BR> tag and
throwing into arrays.

	* Alaric Ravenhall <alaricravenhall at hotmail.com> [010417 06:52]:

	> Hi all.
	> Can anyone tell me of an easy way to take a string of text,
parsing by a 
	> <BR> tag at the end each word, and put it into an array?
	> I will have something similar to this:
	> 
	>
Ravenhall<BR>Nemesis<BR>Thulsa<BR>Imoen<BR>Tweedledum<BR>Tweedledee<BR>
	> 
	> I want to INCLUDE the <BR> tag in the array thusly:
	> 
	> 
	> @names = 
	>
{"Ravenhall<BR>","Nemesis<BR>","Thulsa<BR>","Imoen<BR>","Tweedledum<BR>"
,"Tweedledum<BR>"}

	foreach ($string =~ m/(.+?<br>)/gi) {
	   push @names, $_;
	}

	I'm sure there's a more elegant way, but this

	@names = $string =~ m/(.+?<br>/gi/;

	doesn't seem to create the list context for m//g. I'm not sure
why.

	-- 
	Brock Sides
	philarete at mindspring.com

	The original plan [for GNOME] was to aim to make a desktop as
good as 
	the Macintosh, and we should not lower our ambition by making
one 
	merely as good as Windows. -- RMS 
	
------------------------------------------------------------------------
----
	To unsubscribe, please send email to majordomo at pm.org
	with 'unsubscribe memphis-pm-list' in the body of the message.
	
------------------------------------------------------------------------
----

----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------




More information about the Memphis-pm mailing list