Re: How to Generate An Expression to A LOL?

2011-04-29 Thread Uri Guttman
> "MM" == Mike McClain writes: MM> On Thu, Apr 28, 2011 at 01:16:25PM -0400, Uri Guttman wrote: >> > "zs" == z sway writes: MM> >> zs> sub grow { zs> my $expr = $_[0]; >> >> this is better: >> my ( $expr ) = @_ ; MM> Better how? * it doesn't require indexing so

Re: How to Generate An Expression to A LOL?

2011-04-29 Thread Mike McClain
On Thu, Apr 28, 2011 at 01:16:25PM -0400, Uri Guttman wrote: > > "zs" == z sway writes: > > zs> sub grow { > zs> my $expr = $_[0]; > > this is better: > my ( $expr ) = @_ ; Better how? Thanks, Mike -- Satisfied user of Linux since 1997. O< ascii ribbon campaign - stop html ma

Re: better way of writing this script

2011-04-29 Thread Rob Dixon
On 29/04/2011 13:17, C.DeRykus wrote: This happened in 5.10 ... at least after 5.8. From: http://rt.perl.org/rt3/Ticket/Display.html?id=89024 Just like the argument list of sub calls, The list over which foreach iterates is evaluated in lvalue context as required by foreach's al

Re: better way of writing this script

2011-04-29 Thread C.DeRykus
On Apr 29, 2:39 am, u...@stemsystems.com ("Uri Guttman") wrote: > > "RD" == Rob Dixon writes: > >   RD> On 29/04/2011 10:27, Uri Guttman wrote: > >   RD> Good call Brian. It's not at all obvious that all the elements of a hash >   RD> slice will be created if they don't exist :) >   >> >   >>

Re: How to Generate An Expression to A LOL?

2011-04-29 Thread Rob Dixon
On 29/04/2011 11:13, z sway wrote: > > Hi, grow($part) returns an array, I don't know how to create a ref to array > in one step. > > @$part = grow($part) doesn't work here.To my knowledge, it is used for > changing the array $part refers to, but $part is not a ref , it‘s a string, > it can't refe

Re: calling a config file that has a hash within multiple perl scripts

2011-04-29 Thread Shlomi Fish
Hi Agnello, On Friday 29 Apr 2011 13:26:29 Agnello George wrote: > HI > > I have as hash within my script.pl file which look like this > > ### code follows > > > > > > But it obviously looks too messy to add it all in one script.pl , as > i am going to add new keys and values to the hash ,

calling a config file that has a hash within multiple perl scripts

2011-04-29 Thread Agnello George
HI I have as hash within my script.pl file which look like this my %verticals = ( 'auto_v1' => { 'tempdir' => '/var/www/html/temp/auto' , 'svnurl' => 'http://svn.int.com/repos/a.com/branch/auto', 'excludes' => 'uploaded_images|includes/config.php|admin/includes/config.php|.svn', '

Re: How to Generate An Expression to A LOL?

2011-04-29 Thread z sway
Hi, grow($part) returns an array, I don't know how to create a ref to array in one step. @$part = grow($part) doesn't work here.To my knowledge, it is used for changing the array $part refers to, but $part is not a ref , it‘s a string, it can't refer anything until it's changed to a ref. $part =

Re: better way of writing this script

2011-04-29 Thread Uri Guttman
> "RD" == Rob Dixon writes: RD> On 29/04/2011 10:27, Uri Guttman wrote: RD> Good call Brian. It's not at all obvious that all the elements of a hash RD> slice will be created if they don't exist :) >> >> and they won't be anyhow. you need have lvalues to autovivify hash (or >> a

Re: better way of writing this script

2011-04-29 Thread Rob Dixon
On 29/04/2011 10:27, Uri Guttman wrote: "RD" == Rob Dixon writes: RD> On 29/04/2011 09:15, Brian Fraser wrote: >> On Fri, Apr 29, 2011 at 5:02 AM, Uri Guttman wrote: >>> >>> so you can streamline yours with a slice: >>> >>> my $status = join '', grep defined, @jvalue{

Re: better way of writing this script

2011-04-29 Thread Uri Guttman
> "RD" == Rob Dixon writes: RD> On 29/04/2011 09:15, Brian Fraser wrote: >> On Fri, Apr 29, 2011 at 5:02 AM, Uri Guttman wrote: >>> >>> so you can streamline yours with a slice: >>> >>> my $status = join '', grep defined, @jvalue{ 0 .. 5 } ; >> >> This one was on purpose t

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 10:15, Agnello George wrote: sorry i ment if (stdout == keys (%$retrn{$stdout}) ) { ##so some code } Erm, perhaps if ($stdout == keys %{$retrn{$stdout}}) { But that would compare the value of $stdout with the /number/ of keys in the hash, which is always

Re: retrieving key from hash of hashes

2011-04-29 Thread Uri Guttman
> "AG" == Agnello George writes: AG> sorry i ment AG>if (stdout == keys (%$retrn{$stdout}) ) { AG>##so some code AG> } i don't think you are getting it yet. keys gets you the list of keys ONLY in a list context. == provides a scalar context which will get you the

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 10:14, Agnello George wrote: On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: On 29/04/2011 09:47, Agnello George wrote: my %retrn = ( 0 =>{ 0 =>' successful'}, 1 =>{ 1 =>'insufficient'}, 2 =>{ 2 =>'txtfile missing'}, 3 =>

Re: retrieving key from hash of hashes

2011-04-29 Thread Agnello George
On Fri, Apr 29, 2011 at 2:44 PM, Agnello George wrote: > On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: >> On 29/04/2011 09:47, Agnello George wrote: >>> >>>  my %retrn = ( 0 =>  { 0 =>  '  successful'}, >>>         1 =>  { 1 =>  'insufficient'}, >>>         2 =>  { 2 =>  'txtfile missing'}, >

Re: better way of writing this script

2011-04-29 Thread Rob Dixon
On 29/04/2011 09:15, Brian Fraser wrote: On Fri, Apr 29, 2011 at 5:02 AM, Uri Guttman wrote: so you can streamline yours with a slice: my $status = join '', grep defined, @jvalue{ 0 .. 5 } ; This one was on purpose though - The slice might insert new keys into the hash, and I recently spent

Re: retrieving key from hash of hashes

2011-04-29 Thread Agnello George
On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: > On 29/04/2011 09:47, Agnello George wrote: >> >>  my %retrn = ( 0 =>  { 0 =>  '  successful'}, >>         1 =>  { 1 =>  'insufficient'}, >>         2 =>  { 2 =>  'txtfile missing'}, >>         3 =>  { 3 =>  'bad dir'}, >>         ); >> >> ( i kno

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 09:47, Agnello George wrote: my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir'}, ); ( i know this hash looks funny , but is the hash i got to use ) suppose $s

Re: retrieving key from hash of hashes

2011-04-29 Thread John W. Krahn
Agnello George wrote: Hi All Hello, I got a hash like this : my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir'}, ); ( i know this hash looks funny , but is the hash i g

retrieving key from hash of hashes

2011-04-29 Thread Agnello George
Hi All I got a hash like this : my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir '}, ); ( i know this hash looks funny , but is the hash i got to use ) suppose $stdout = 0; i need to

Re: better way of writing this script

2011-04-29 Thread Brian Fraser
On Fri, Apr 29, 2011 at 5:02 AM, Uri Guttman wrote: > > also why use qw for sequential numbers when a range will do? > > Because I went stupid and just blindly copypasted instead of thinking :) Seriously, why use qw when I'm not _quoting words_? > so you can streamline yours with a slice: > > m

Re: better way of writing this script

2011-04-29 Thread Uri Guttman
> "BF" == Brian Fraser writes: BF> On Fri, Apr 29, 2011 at 4:27 AM, Agnello George wrote: >> Hi All >> >> is there a better way of writing this script >> >> BF> "Better" is fairly subjective - And with only a part of the program, there BF> isn't much that can be said. Is

Re: better way of writing this script

2011-04-29 Thread Agnello George
On Fri, Apr 29, 2011 at 1:09 PM, Uri Guttman wrote: >> "AG" == Agnello George writes: > >  AG> is there a better way of writing this script > > this is not a script but a short code snippet. there are many ways to > redo this. many questions could be asked as well. > >  AG>  my @resultss = qw

Re: better way of writing this script

2011-04-29 Thread Uri Guttman
> "AG" == Agnello George writes: AG> is there a better way of writing this script this is not a script but a short code snippet. there are many ways to redo this. many questions could be asked as well. AG> my @resultss = qw( 0 1 2 3 4 5 ) ; is that always a fixed list? could @jvalue h

Re: better way of writing this script

2011-04-29 Thread Brian Fraser
On Fri, Apr 29, 2011 at 4:27 AM, Agnello George wrote: > Hi All > > is there a better way of writing this script > > "Better" is fairly subjective - And with only a part of the program, there isn't much that can be said. Is $status a global variable, or lexical? On the other hand, if you mean mo

better way of writing this script

2011-04-29 Thread Agnello George
Hi All is there a better way of writing this script my @resultss = qw( 0 1 2 3 4 5 ) ; foreach ( @resultss) { if ( defined( $jvalue{$_}){ $status .= $jvalue{$_} ; } } Thanks -- Regards Agnello D'souza -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,