Evan Panagiotopoulos wrote:
> I have a text file and I would like to use the print command. I read the
> documentation but I couldn't make heads or tails.
> I have the variable containing the string in variable $fields{add}, the text
> file in in variable taxfile.dat, and the receiving variable is $lines.

 Okay you want to print every lines of a file (taxgfile.dat) that match
 the string in $field{add} ?

 Here's a way to do it:

#!/usr/bin/perl -w
use strict;

my %fields = (
        # We use quotemeta to avoid interpreting special characters
    # (like *, +, ?) in the regular expression
        'add'   => quotemeta('string to match'),
);

open(FILE, "< taxfile.dat") or die "Cannot open taxfile.dat: $!\n";
while (<FILE>){
        print if /$fields{add}/i
}

__END__

Hope this helps,
Briac

> $lines = print  if (/(?i) $fields{add}/ ) taxfile.dat;
> I wanted to ignore the case (upper or lower is irrelevant).
> HELP, after many hours of trying, searching and cursing I finally give up
> and I ask for your suggestions.
> 
> Thanks,
> 
> Evan Panagiotopoulos
> 


-- 
briac
        A pair of lovers contending 
        under an oak. A 
        old man. A bear walks.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to