View Single Post
  #2 (permalink)  
Old 11-21-2007, 02:20 AM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 25
Posts: 35
Credits: 0
Rep Power: 4
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Thumbs down

That's pretty simple, but first of all I've got a few questions. Is the location of the text file on the same or a different server than your script? if it is on the same server you should just be able to "open" it...otherwise you'll need to use LWP::Simple and use "get".

Assuming that the file is on the same server you should be able to do something like this...(this is a CGI app...so instead of using CGI you'll just be able to use $ARGV[0] (that will contain the first argument passed to the script)

Code:
#!/usr/bin/perl
use strict; use warnings;
use CGI;
my $cgi = CGI->new;

open(FILE, "data.txt") || die("Could not open file!");
my @contents=<FILE>;
close(FILE);

my $argv = $cgi->param('argv');

print "Content-type:text/plain\n\n";
foreach my $content (@contents){
    if($content =~ m/^$argv=(.+)\sMB/){
        print "$1\n";
   }
}
That should do what you need.
__________________
Visit My Google Group Here: Web Development Innovation
Reply With Quote