Re: Rookie Perl Question



Eric R. Meyers wrote:
swangdb wrote:

This doesn't work, it tries to take the egrep output and cut out part
of it:

***
$temp = "egrep -v \^# $ALIASES | cut -d: -f1";
system($temp);
***

$aliases = 'some/file/name';

open( FH, $aliases ) || die "opening aliases: $!\n";

while ( <FH> )
{
print if ( ! m/^[#]/ );

} ## end while

close( FH );

Eric,

Thanks for showing a real perl way to do this. I received a quick fix
to my command, add one backslash before the existing backslash:

$temp = "egrep -v \\^# $ALIASES | cut -d: -f1";
system($temp);

I actually want to put this output to a file, so I guess system is
okay:

$temp = "egrep -v \\^# $ALIASES | cut -d: -f1 > $outfile";
system($temp);

Thanks again!

.