Re: why on while?

2010-03-08 Thread Uri Guttman
> "BRH" == Bryan R Harris writes: >>> "BRH" == Bryan R Harris writes: >> how would that work any better as $_ is still set to each element? BRH> Because somehow the $_ is localized with foreach where it is not with the BRH> implicit (?) while loop. foreach always localizes its

Re: why on while?

2010-03-08 Thread Bryan R Harris
>> "BRH" == Bryan R Harris writes: > > BRH> Much to my chagrin I realized this morning that this notation: > > BRH> while() { > > BRH> evaluates as: > > BRH> while(defined($_ = )) { > > BRH> ... and NOT as: > > BRH> while(defined(local $_ = )) { > > BRH> I ha

Re: why on while?

2010-03-08 Thread Jeff Peng
On Tue, Mar 9, 2010 at 12:41 PM, Bryan R Harris wrote: > > > Much to my chagrin I realized this morning that this notation: > >    while() { > > evaluates as: > >    while(defined($_ = )) { > > ... and NOT as: > >    while(defined(local $_ = )) { > so how about while (my $line = ) instead of usin

Re: why on while?

2010-03-08 Thread Uri Guttman
> "BRH" == Bryan R Harris writes: BRH> Much to my chagrin I realized this morning that this notation: BRH> while() { BRH> evaluates as: BRH> while(defined($_ = )) { BRH> ... and NOT as: BRH> while(defined(local $_ = )) { BRH> I had a subroutine that was set up

why on while?

2010-03-08 Thread Bryan R Harris
Much to my chagrin I realized this morning that this notation: while() { evaluates as: while(defined($_ = )) { ... and NOT as: while(defined(local $_ = )) { I had a subroutine that was set up to read and parse a file, but it was trashing the value of $_ out in the main program!

Re: good practice in File::Find

2010-03-08 Thread Harry Putnam
"John W. Krahn" writes: >> Like: next if(! $File::Find::dir =~ /$dir_rgx/); > > No. Because you are inside a subroutine you have to use return: > > return unless $File::Find::dir =~ /$dir_rgx/; > > Or perhaps: > > return if $File::Find::dir !~ /$dir_rgx/; > Thanks. >> or >> Like I've don

Re: Controlling one process depending on the status of another

2010-03-08 Thread Eric Veith1
Jay: Jay Savage wrote on 03/08/2010 08:53:40 PM: > It sounds like Term::Readline is using Term::ReadLine::Gnu as the > back-end. The problem there is that, to Perl, the XS call for GNU > readline() looks like a single system call. > Try setting the PERL_RL environment to "Perl" instead of "Gnu":

Re: Controlling one process depending on the status of another

2010-03-08 Thread Jay Savage
On Mon, Mar 8, 2010 at 10:27 AM, Eric Veith1 wrote: > "Bob McConnell" wrote on 03/05/2010 08:22:23 PM: >> The way I read his problem description, it sounded neither simple nor >> easy. > > Bob, Jay, > [snip] > You see, there's IPC on the local machine and possibly sockets to a remote > machine.

Re: tr// versus s///g

2010-03-08 Thread Uri Guttman
> "TE" == Tony Esposito writes: TE> You miss my point but thanks for the syntax check.  I am concerned TE> with comparing the functionality, one versus the other. they are not comparable at all. tr/// works on individual characters and nothing else. s/// works with regexes which can modi

Re: tr// versus s///g

2010-03-08 Thread John W. Krahn
Tony Esposito wrote: On Mon, 8/3/10, John W. Krahn wrote: Tony Esposito wrote: Does tr/'\n'/' '/ Replace every ' with ' and every "\n" with " " and every ' with '. Should probably just be tr/\n/ /. do the same as tr/'\n'/' '/g? I assume you mean s/'\n'/' '/g because /g is not a valid o

Re: tr// versus s///g

2010-03-08 Thread Tony Esposito
Sorry about the syntax errors ... Yes, just want to replace all newline characters with a space and since tr does not have g (global) 'option' I was thinking that s/\n/ /g is actually better. Or does tr do a global translate by default?   Thanks --- On Mon, 8/3/10, John W. Krahn wrote: From:

Re: tr// versus s///g

2010-03-08 Thread Tony Esposito
You miss my point but thanks for the syntax check.  I am concerned with comparing the functionality, one versus the other.   Thanks. --- On Mon, 8/3/10, Shawn H Corey wrote: From: Shawn H Corey Subject: Re: tr// versus s///g To: "Tony Esposito" Cc: "Beginners Perl" Date: Monday, 8 March, 20

Re: good practice in File::Find

2010-03-08 Thread John W. Krahn
Harry Putnam wrote: I want to know if doing something like what is in the code below would be expensive or for some other reason a bad choice. There is more code, that either feeds the `find()' function or further processes the results of the `find()' part. The code is not in finished form, or

Re: tr// versus s///g

2010-03-08 Thread John W. Krahn
Tony Esposito wrote: Does tr/'\n'/' '/ Replace every ' with ' and every "\n" with " " and every ' with '. Should probably just be tr/\n/ /. do the same as tr/'\n'/' '/g? I assume you mean s/'\n'/' '/g because /g is not a valid option for tr///. That will replace the string "'\n'" with

Re: tr// versus s///g

2010-03-08 Thread Shawn H Corey
Tony Esposito wrote: > Does tr/'\n'/' '/ do the same as tr/'\n'/' '/g? ( replace newline with space > ) > If so, is one preferred over the other? Neither of the above is correct. The correct forms are: tr/\n/ /; s/\n/ /g; -- Just my 0.0002 million dollars worth, Shawn Programming is

Re: Can anybody explain me what this shebang line is doing?

2010-03-08 Thread Eric Veith1
YAPH wrote on 03/05/2010 06:57:19 PM: > It was the shell construc, eval '' if 0; (Will this ever > execute?) > > and the > > exec /bin/perl $0 ${1+"$@"}; > > that threw me off. YAPH: Actually, the first constructs gets read and interpreted by both shell and perl. However, Perl doesn't e

RE: Controlling one process depending on the status of another

2010-03-08 Thread Eric Veith1
"Bob McConnell" wrote on 03/05/2010 08:22:23 PM: > The way I read his problem description, it sounded neither simple nor > easy. Bob, Jay, I fear, Jay, my explanaitions weren't fully able to depict what my app is trying to archieve. It is not only a matter of IPC on one machine that happens to

tr// versus s///g

2010-03-08 Thread Tony Esposito
Does tr/'\n'/' '/ do the same as tr/'\n'/' '/g?  ( replace newline with space ) If so, is one preferred over the other?  

Re: good practice in File::Find

2010-03-08 Thread Shawn H Corey
Harry Putnam wrote: > find( > sub { > ## if we have a directory name that matches > if($File::Find::dir =~ /$dir_rgx/){ > ## if that directory has files with all numeric names > if(/^\d+$/){ if( ! /\D/ ){ > ## Open the files and search for a regex in

Re: good practice in File::Find

2010-03-08 Thread Harry Putnam
Harry Putnam writes: > [...] > > find( > sub { > ## if we have a directory name that matches > if($File::Find::dir =~ /$dir_rgx/){ > ## if that directory has files with all numeric names > if(/^\d+$/){ > ## Open the files and search for a regex in

Re: question on software development

2010-03-08 Thread Raymond Wan
Randal L. Schwartz wrote: "ANJAN" == ANJAN PURKAYASTHA writes: ANJAN> OK, suppose I develop a Perl application. I want to create an icon for the ANJAN> program so that a user may download the program and start it in the GUI by ANJAN> double-clicking on the icon. Did I miss something? Wher

good practice in File::Find

2010-03-08 Thread Harry Putnam
I want to know if doing something like what is in the code below would be expensive or for some other reason a bad choice. There is more code, that either feeds the `find()' function or further processes the results of the `find()' part. The code is not in finished form, or tested, but more to s