Hello. I have a script that parses csv files for the occurence of an IP address that is passed to the script as an argument when it runs. Currently, I can only run the script from within the same directory as my data files. I would like to be able to move my csv files into a separate data directory, but I seem to be having problems mapping the rest of the script to the new directory. Is there any way to make my input look something like this:
my $input="data/$file" or is there a better way to handle this? Thanks, Jose Any help would be appreciated. Here's what' I've got so far: #!/usr/bin/perl -w use strict; use Text::CSV; my $ip=$ARGV[0]; my $csv=Text::CSV->new(); opendir(DIR, "."); my @files = readdir(DIR); foreach my $file (@files) { my $input="$file"; open(INFILE,"$input") || die "Can't open file $input"; while (<INFILE>) { chomp; if($csv->parse($_)) { if (m|$ip|) { my @fields=$csv->fields; print "$fields[0],$fields[4],$fields[5],$fields[6]\n"; } } } } closedir(DIR); close INFILE;