Welcome to WebmasterWorld Guest from 54.163.168.15

Forum Moderators: coopster & jatar k & phranque

Retrieving a single line

How to retrieve a single line for script variable

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

5+ Year Member



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: [goingplatinum.com...]

close (LINKS);

</PRE>

Any snippet would be appreciated

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

WebmasterWorld Senior Member 10+ Year Member



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month