Re: Rookie Perl Question
- From: "Eric R. Meyers" <ermeyers@xxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 14:35:45 -0400
swangdb wrote:
I want to run some unix commands from a perl script.
This works, it prints out all lines that don't begin with a # in the
file $ALIASES:
***
$temp = "egrep -v \^# $ALIASES";
system($temp);
***
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);
***
I get the following output:
Usage: egrep [OPTION]... PATTERN [FILE]...
Try `egrep --help' for more information.
How can I make this work?
Thanks!
$aliases = 'some/file/name';
open( FH, $aliases ) || die "opening aliases: $!\n";
while ( <FH> )
{
print if ( ! m/^[#]/ );
} ## end while
close( FH );
## FYI: Buy Perl programming book "Learning Perl" ISBN: 1-56592-284-0.
## The system() call doesn't return output to you.
## Another means is open( FH, "egrep -v ... |" ) which opens a piped FH.
.
- Follow-Ups:
- Re: Rookie Perl Question
- From: Tad McClellan
- Re: Rookie Perl Question
- From: swangdb
- Re: Rookie Perl Question
- References:
- Rookie Perl Question
- From: swangdb
- Rookie Perl Question
- Prev by Date: Re: Professional IDE for a cross-platform Perl application
- Next by Date: Re: Professional IDE for a cross-platform Perl application
- Previous by thread: Rookie Perl Question
- Next by thread: Re: Rookie Perl Question
- Index(es):