homepage Welcome to WebmasterWorld Guest from 54.226.235.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Retrieving a single line
How to retrieve a single line for script variable
Beethoven




msg:435988
 7:11 am on Jan 2, 2001 (gmt 0)

I have a simple link rotation script I want to use and have been modifying it ith my limited knowledge of Perl.

My question is how can I get a single line from a text "database" of URLs and send it along with the LOcation: command?

Here is what I have so far, but it doesn't work. I also need to "strip" the return and blank space at end of line.
<PRE>
open (LINKS, "$linkfile");

$lines=@file=<LINKS>; # inhale file & get # of lines

foreach $line (@lines) {
chop ($line) if ($line =~ /\n$/);
}
$gpmember=$lines[$member];

print "Location: https://www.goingplatinum.com/member/$gpmember/GP/public/signup.jsp\n\n";

close (LINKS);

</PRE>

Any snippet would be appreciated

 

sugarkane




msg:435989
 8:03 pm on Feb 28, 2001 (gmt 0)

Better late than never... I'd probably do it this way:

open (LINKS, "$linkfile");
chomp(@links=<LINKS>);
close (LINKS);

$gpmember=$links[rand($#links)];

...and then use $gpmember in your "Location: " line.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved