CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Variable question

 



wjbell
stranger

Dec 19, 2003, 7:39 PM

Post #1 of 2 (970 views)
Variable question Can't Post

Say I have a variable that contains a URL. Could I limit the characters it outputs with the {n}. It's hard to explain, somthing like:

foreach $line (@text) {
$line =~ s/(http:\/\/www.foo.com\/index.cgi?longurlstring)/<a href=$1>$1{20}<\/a>/g;
}

So what I want to do is capture the url to put in the a href but use a shortened version for the link text that shows on the page.


Recall
Novice

Dec 20, 2003, 6:45 AM

Post #2 of 2 (968 views)
Re: [wjbell] Variable question [In reply to] Can't Post


Code
 
foreach (@text) {
$_ = qq!<a href="$_">@{[ substr($_, 0, 20) ]}</a>!;
}



(This post was edited by Recall on Dec 20, 2003, 6:46 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives