SPUG: Self referecing URL

Jeremy Devenport jeremy at weezel.com
Fri Sep 22 22:30:38 CDT 2000


If your data looks like:
a line with a NUM1234 in it

and you want to have
a line with a <a href="get_page.pl?cat_num=1234">NUM1234</a>

then how about
$item_text =~ s/(NUM(\d+))/<a href="get_page.pl?cat_num=$2">$1<\/a>/g;

It is much easier to help if you show an example of the expected input and
output.

Jeremy

-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
marlin
Sent: Friday, September 22, 2000 6:15 PM
To: spug-list at pm.org
Subject: SPUG: Self referecing URL


I need to detect a catalog number in a text line and reference it to
another page as a link.

The text is $item_text. I want to swap the number (NUM + some digits)
with itself as a <A HREF> tag.

I tried...

$item_text =~ s/(NUM.*\s)/<A HREF=get_page.pl?cat_num=\1>\1</A>/g;
which sort of works except that the closing > after the \1 is ignored,
that is the tag never closes and the entire line is linked.

I'm missing something.

Thanks is advance for telling me what I'm missing.

Marlin Greene
--
	3 Hats Design
	INTERNET  PRINT  ILLUSTRATION
	5201 15 Ave NW
	Suite 220
	Seattle, WA 98107
	206.784.1641 phone
	206.784.2231 fax
	marlin at 3hats.com
	http://www.3hats.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/




 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list