[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] search string



Hi, Zach,

You're looking for the   .=   assignment operator as shown below (using 
a new variable $result).

=-=-=-=-=-=-=
>                 How can I assign the search output to a new variable so 
>that I could print it out the second time, or use for what would actually 
>be the next part of my script?
>
>#!perl
>
>$file = "myfile.dat";
>
>print ("search?\n");
>$search = <STDIN>;
>chop ($search);
>
>open (INFILE, $file) ||
>        die ("Can't open input file!\n");
>while ($line = <INFILE>) {
>        if ($line =~ /$search/i) {
>                print ("$line\n");
                 $result .= $line;    # See camel book p.11, 92
>
>        }
>
>}

print $result;
=-=-=-=-=-=-=

Cheers,

-Charles Albrecht
 AOL Productions South
 charlesa@aol.net