Re: Files Operations in Pearl

2007-03-16 Thread Jeff Pang
>> @tmp = map { (split)[2] } grep { /localhost/ } ; > >This is a bad idea if the file you are reading from is at all large. Yes memory consuming of using map and grep is the fact. But AFAIK postgresql.conf is not big at all (just a few lines) b/c I'm pretty familiar with it. :) -- To unsubscr

Re: Files Operations in Pearl

2007-03-16 Thread Chas Owens
On 3/16/07, Jeff Pang <[EMAIL PROTECTED]> wrote: snip @tmp = map { (split)[2] } grep { /localhost/ } ; snip This is a bad idea if the file you are reading from is at all large. It is better to use a real loop rather than map or grep when reading from a file. The problem lies in the fact that

Re: Files Operations in Pearl

2007-03-16 Thread Jeff Pang
>In shell-script I get a variable with command line: > >AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" > | awk '{print $3}' | head -n1` > Hello, In Perl it can most likely be written as: open FILE,"$INPUTDB/postgresql.conf" or die $!; @tmp = map { (split)[2] } grep { /localhost/ } ; c

Re: Files Operations in Pearl

2007-03-16 Thread John W. Krahn
Rodrigo Faria Tavares wrote: > Hello, Hello, > In shell-script I get a variable with command line: > > AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" > | awk '{print $3}' | head -n1` UUOC: AUXIP=`grep "localhost" "$INPUTDB/postgresql.conf" | awk '{print $3}' | head -n1` AWK can do re

Files Operations in Pearl

2007-03-16 Thread Rodrigo Tavares
Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And Pearl ? After I open the file, i like to get a simple word and store

Re: Files Operations in Pearl

2007-03-16 Thread Chas Owens
On 3/16/07, Rodrigo Faria Tavares <[EMAIL PROTECTED]> wrote: snip After I open the file, i like to get a simple word and store in a scalar variable. Or write after line 10 for example. And others. snip In Perl file operations are generally handled by file handles. If you want to use the object

Re: Files Operations in Pearl

2007-03-16 Thread Igor Sutton Lopes
Hi Rodrigo, On 2007/03/16, at 18:09, Rodrigo Faria Tavares wrote: Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And P

Files Operations in Pearl

2007-03-16 Thread Rodrigo Faria Tavares
Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And Pearl ? After I open the file, i like to get a simple word and store