Re: I'd like to explain to me how to do testing on lists and list slices

2012-03-10 Thread m...@roundcube.fakessh.eu
Le samedi 10 mars 2012 à 10:51 +0200, Shlomi Fish a écrit : > Hi ml, > > I find you hard to understand, but I'll try. > > On Sat, 10 Mar 2012 03:06:27 +0100 > ml wrote: > > > hello the list > > hello "the" perl guru > > hello this > >

Re: I'd like to explain to me how to do testing on lists and list slices

2012-03-10 Thread Shlomi Fish
Hi ml, I find you hard to understand, but I'll try. On Sat, 10 Mar 2012 03:06:27 +0100 ml wrote: > hello the list > hello "the" perl guru > hello this > > I want to know how to work on slices of lists. > I has 3 slices of the form. > $t[0] = user; > $

I'd like to explain to me how to do testing on lists and list slices

2012-03-09 Thread ml
hello the list hello "the" perl guru hello this I want to know how to work on slices of lists. I has 3 slices of the form. $t[0] = user; $t[1] = ip; $t[2] = time(); the registration of the list are checked by me I know what the file contains and recording are separated by a space

Re: anonymous hash slices

2010-02-24 Thread Uri Guttman
> "BRH" == Bryan R Harris writes: BRH> Just as an academic exercise, I thought I should be able to do this: BRH> ** BRH> @a=(l=>35,k=>31,r=>7,k=>6); BRH> @r=qw/l r r k/; try to use some white space in your code. even in short examples it helps.

anonymous hash slices

2010-02-24 Thread Bryan R Harris
Just as an academic exercise, I thought I should be able to do this: ** @a=(l=>35,k=>31,r=>7,k=>6); @r=qw/l r r k/; # make an anonymous hash using @a, then grab values from it using @r as keys @a...@a}{@r}; print join(",",@a), "\n"' ***

Re: slices

2007-08-14 Thread Chas Owens
ing that "a list of subscripts" must contain a comma or a range, but there is such a thing as a list of one element, and subscripts on lists and arrays slices are such a list. This can be proven with wantarray again: perl -le 'sub a { wantarray } $_ = ("f", "t")[a

Fwd: slices

2007-08-14 Thread Jay Savage
ce accesses several elements of a list, an array, or a hash simultaneously using a list of subscripts. It's more convenient than writing out the individual elements as a list of separate scalar values." Therefore: (qw/one two three four)[0]; # not a slice (qw/one two three fou

Re: slices

2007-08-09 Thread Paul Lalli
On Aug 9, 10:39 am, [EMAIL PROTECTED] wrote: > - Original Message - > From: Paul Lalli <[EMAIL PROTECTED]> > Date: Thursday, August 9, 2007 8:52 am > Subject: Re: slices > To: [EMAIL PROTECTED] > > > $ perl -wle'my @bar = qw/alph

Re: slices

2007-08-09 Thread kviel
- Original Message - From: Paul Lalli <[EMAIL PROTECTED]> Date: Thursday, August 9, 2007 8:52 am Subject: Re: slices To: beginners@perl.org > $ perl -wle'my @bar = qw/alpha beta gamma/;  @bar[

Re: slices

2007-08-09 Thread Paul Lalli
On Aug 9, 8:29 am, [EMAIL PROTECTED] (Paul Lalli) wrote: > On Aug 8, 11:05 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: > > > > Subject: slices > > > Your examples are not using slices. A slice implies a list (more than one) > > of > > indexes > > No &

Re: slices

2007-08-09 Thread Paul Lalli
On Aug 8, 11:05 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: > > Subject: slices > > Your examples are not using slices. A slice implies a list (more than one) of > indexes No "more than one" required. A 1 element list is a list. @bar[0,1] = `$cmd`; assigns the first t

Re: slices

2007-08-08 Thread John W. Krahn
Subject: slices Your examples are not using slices. A slice implies a list (more than one) of indexes oryann9 wrote: Trying to understand from perldoc perldata the diff between these 3 CLIs and why the 2nd CLI has no elements? From perldata: "A slice of an empty list is still an

Re: slices

2007-08-08 Thread John W. Krahn
Lawrence Statton wrote: From [EMAIL PROTECTED] Wed Aug 8 15:44:30 2007 Return-Path: <[EMAIL PROTECTED]> X-Original-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: from localhost (localhost [127.0.0.1]) by hummer.cluon.com (Postfix) with ESMTP id 25F66339A0 for <[

Re: slices

2007-08-08 Thread Jeff Pang
-Original Message- >From: oryann9 <[EMAIL PROTECTED]> >Sent: Aug 9, 2007 4:43 AM >To: Perl List >Subject: slices > >$ perl -le 'use Data::Dumper; @c = (0,1)[2]; print >Dumper([EMAIL PROTECTED]);' >$VAR1 = []; > > This is because the e

Re: slices

2007-08-08 Thread Lawrence Statton
SXvqCGz > Received: from [12.20.127.229] by web63413.mail.re1.yahoo.com via HTTP; Wed, > 08 Aug 2007 13:43:46 PDT > Date: Wed, 8 Aug 2007 13:43:46 -0700 (PDT) > From: oryann9 <[EMAIL PROTECTED]> > Subj

RE: slices

2007-08-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: oryann9 [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 08, 2007 13:44 > To: Perl List > Subject: slices > > Trying to understand from perldoc perldata the diff > between these 3 CLIs and why the 2nd CLI has no > elements

slices

2007-08-08 Thread oryann9
Trying to understand from perldoc perldata the diff between these 3 CLIs and why the 2nd CLI has no elements? $ perl -le 'use Data::Dumper; @c = (0,1)[1]; print Dumper([EMAIL PROTECTED]);' $VAR1 = [ 1 ]; $ perl -le 'use Data::Dumper; @c = (0,1)[2]; print Dumper([EMAIL PROTECTED]

Re: hash slices

2006-09-28 Thread Rob Dixon
ORDER BY is pointless with selectall_hashref, as hashes are unordered. > So I'm still confused about what I need to do. I want to: > > 1. display the rows with ifFollowedProtocol eq '' or 'yes' in order of > medCategory > 2. display the rows with ifFollowed

Re: hash slices

2006-09-28 Thread John W. Krahn
Gerald Host wrote: > I'm using DBI's selectall_hashref with 5 key columns. I want to display > each row where key col 1 is 'yes' or NULL (undef or '' ?) > > > foreach my $medCategory (keys %{$href->{'yes'}->{qw('' 'yes')}->{qw('' > 'yes')}}) { > foreach my $med (keys %{$href->{qw('yes')}->{

Re: hash slices

2006-09-28 Thread Gerald Host
)); So I'm still confused about what I need to do. I want to: 1. display the rows with ifFollowedProtocol eq '' or 'yes' in order of medCategory 2. display the rows with ifFollowedProtocol eq '' or 'no' in order of medCategory I thought I could do

Re: hash slices

2006-09-28 Thread Rob Dixon
Gerald Host wrote: > > I'm using DBI's selectall_hashref with 5 key columns. I want to display > each row where key col 1 is 'yes' or NULL (undef or '' ?) > > > foreach my $medCategory (keys %{$href->{'yes'}->{qw('' 'yes')}->{qw('' 'yes')}}) { > foreach my $med (keys %{$href->{qw('yes')}->{qw(

hash slices

2006-09-28 Thread Gerald Host
I'm using DBI's selectall_hashref with 5 key columns. I want to display each row where key col 1 is 'yes' or NULL (undef or '' ?) foreach my $medCategory (keys %{$href->{'yes'}->{qw('' 'yes')}->{qw('' 'yes')}}) { foreach my $med (keys %{$href->{

Re: hashref slices

2006-04-25 Thread John W. Krahn
7;, 'four', 'five', 'six'); > print join("'\t'", keys %{$hashref}), "'\n"; > print join("\t", values %{$hashref}), "'\n"; > > How do I properly use hashref slices? perldoc perlreftut perldoc

hashref slices

2006-04-25 Thread Ryan Perry
my $hashref; my @num=qw( 0 1 2 3 4 5 ); @hashref->[EMAIL PROTECTED] = ('one', 'two', 'three', 'four', 'five', 'six'); print join("'\t'", keys %{$hashref}), "'\n"; print join("\t", values %

Re: hashref slices

2006-04-03 Thread John W. Krahn
Ryan Perry wrote: > I wanted to use a hash slice, but I'm using a hashref. Can I do both? Yes. > my @current_Flags=( $hormone . 'DoseCycle', anotherVar, somethingElse ); > $flags->[EMAIL PROTECTED]>selectrow_array(qq{$SQLstmt}); #returns @{ $flags }{ @current_Flags } = $dbh->selectrow_array-

hashref slices

2006-04-03 Thread Ryan Perry
I wanted to use a hash slice, but I'm using a hashref. Can I do both? my @current_Flags=( $hormone . 'DoseCycle', anotherVar, somethingElse ); $flags->[EMAIL PROTECTED]>selectrow_array(qq{$SQLstmt}); #returns an array, $flags is my hashref Thanks! -- To unsubscribe, e-mail: [EMAIL PROTE

Re: slices of hashes

2005-07-21 Thread Gerard Robin
On Thu, Jul 21, 2005 at 04:04:36PM -0400 Scott R. Godin wrote: > Gerard Robin wrote: > >Hello, > >the slices of hashes work strangely ... > > > > >PS > >if I write: > >@h3{"Mamadoo".."Lulu"} = (30, 40, 50 ); > >the script hangs

Re: slices of hashes

2005-07-21 Thread Jeff 'japhy' Pinyan
On Jul 21, Gerard Robin said: my %h1 = (a => 1, b => 2, c => 3, d => 4, e => 5, f => 6); [snip] print " ", map{ $_." " } @h1{'b'..'e'}; [snip] @h1{'b'..'e'} = (20, 30, 40, 50); print " ", map{ $_." " } @h1{'b'..'e'}; What do you think 'b'..'e' is producing? It's producing the list ('b',

Re: slices of hashes

2005-07-21 Thread Scott R. Godin
Gerard Robin wrote: Hello, the slices of hashes work strangely ... PS if I write: @h3{"Mamadoo".."Lulu"} = (30, 40, 50 ); the script hangs (no error is displayed) yes because that's not a hash slice there: what happens when you do these: ? perl -wle 'pri

slices of hashes

2005-07-21 Thread Gerard Robin
Hello, the slices of hashes work strangely ... The parts 1, 2 and 4 work fine; but the part 3 doesn't do what I expect. What is wrong in what I do in part 3 ? #!/usr/bin/perl #slice3.pl use warnings; use strict; # 1 my %h1 = (a => 1, b => 2, c => 3, d => 4, e => 5, f =&

Re: Slices

2004-01-26 Thread Steve Grazzini
Paul Kraus wrote: Can I declare from this element to end with an array slice. @arary[3...] but this doesn't work?. You can refer to the last index with $#arary, so: @arary[3 .. $#arary]; Is that what you meant? -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-m

Re: Slices

2004-01-26 Thread wolf blaum
> > @arary[3...] but this doesn't work?. What about @array[3..$#array] PS: @arary = typo? Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Slices

2004-01-26 Thread Paul Kraus
Can I declare from this element to end with an array slice. @arary[3...] but this doesn't work?. Paul Kraus --- PEL Supply Company Network Administrator --- 800 321-1264 Toll Free 216 267-5775 Voice 216 267-6176 Fax www.pelsupply.com

RE: hash of hash of array slices

2004-01-26 Thread Tim Johnson
ct: RE: hash of hash of array slices This worked fine. However I was under the impression that any time you worked with a slice that you had to surround the array in parenthesis. When else does this not apply? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [

RE: hash of hash of array slices

2004-01-26 Thread Charles K. Clarkson
: -Original Message- : From: Paul Kraus [mailto:[EMAIL PROTECTED] : Sent: Monday, January 26, 2004 10:52 AM : To: 'Charles K. Clarkson'; 'Perl Beginners' : Subject: RE: hash of hash of array slices : : : > Paul Kraus <[EMAIL PROTECTED]> wrote: : > : : &g

RE: hash of hash of array slices

2004-01-26 Thread Paul Kraus
> -Original Message- > From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] > Sent: Monday, January 26, 2004 12:10 PM > To: Paul Kraus > Cc: 'Perl Beginners' > Subject: Re: hash of hash of array slices > > On Jan 26, Paul Kraus said: > > &

Re: hash of hash of array slices

2004-01-26 Thread Jeff 'japhy' Pinyan
On Jan 26, Paul Kraus said: >foreach ( @{($hash{$key1}{$key2})[9..1]} ) It should be: foreach ( @{ $hash{$key1}{$key2} }[1 .. 10] ) { ... } based on your other email. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmon

RE: hash of hash of array slices

2004-01-26 Thread Paul Kraus
> Paul Kraus <[EMAIL PROTECTED]> wrote: > : > : This works > : > : Foreach ( @{$hash{$key1}{$key2}} ) > : > : This does note > : > : Foreach ( @{($hash{$key1}{$key2})[9..1]} ) > : > : This gives me this error > : Can't use undefined value as an array reference. > : > > > foreach ( reverse @

RE: hash of hash of array slices

2004-01-26 Thread Charles K. Clarkson
Paul Kraus <[EMAIL PROTECTED]> wrote: : : This works : : Foreach ( @{$hash{$key1}{$key2}} ) : : This does note : : Foreach ( @{($hash{$key1}{$key2})[9..1]} ) : : This gives me this error : Can't use undefined value as an array reference. : foreach ( reverse @{ $hash{$key1}{$key2} }[

hash of hash of array slices

2004-01-26 Thread Paul Kraus
This works Foreach ( @{$hash{$key1}{$key2}} ) This does note Foreach ( @{($hash{$key1}{$key2})[9..1]} ) This gives me this error Can't use undefined value as an array reference. TIA, Paul Kraus --- PEL Supply Company Network Administrator ---

Re: Need help on Hash Slices. !!

2003-09-23 Thread David Storrs
On Tue, Sep 23, 2003 at 08:49:11PM +0530, Pandey Rajeev-A19514 wrote: > Hi, > > I have a list like > > @list = ( "key1: Vlan1 :0989\n" > "key2: Vlan2 :0989\n" > "key3: Vlan3 :0989\n" > "key4: Vlan4 :0989\n"); > > I wanted to make a hash with keys as key1, key2 , key3, key4. >

RE: Need help on Hash Slices. !!

2003-09-23 Thread Bob Showalter
akes all the elements in the list as the key. > > Regards > Rajeev I'm sorry, I don't see what any of this has to do with what you originally posted. Perhaps we need to start over. > > -Original Message- > From: Bob Showalter [mailto:[EMAIL PROTECTED] > Sent: Tuesday, Sep

RE: Need help on Hash Slices. !!

2003-09-23 Thread Dan Muey
> Hi, Howdy > > I have a list like > > @list = ( "key1: Vlan1 :0989\n" > "key2: Vlan2 :0989\n" > "key3: Vlan3 :0989\n" > "key4: Vlan4 :0989\n"); > > I wanted to make a hash with keys as key1, key2 , key3, key4. > Soemthing like this perhaps? ++UNTESTED++ my %hsh; for(@lis

RE: Need help on Hash Slices. !!

2003-09-23 Thread Pandey Rajeev-A19514
s/CAT/ => SERVER_NAME => sunomcr sunomcr => TEST_CASE_OUTPUT_PATH => ../testlogs/ ../testlogs/ => It seems it takes all the elements in the list as the key. Regards Rajeev -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 23, 2003 8:56 PM

RE: Need help on Hash Slices. !!

2003-09-23 Thread Bob Showalter
Pandey Rajeev-A19514 wrote: > Hi, > > I have a list like > > @list = ( "key1: Vlan1 :0989\n" > "key2: Vlan2 :0989\n" > "key3: Vlan3 :0989\n" > "key4: Vlan4 :0989\n"); > > I wanted to make a hash with keys as key1, key2 , key3, key4. > > I want to write something like this : >

Need help on Hash Slices. !!

2003-09-23 Thread Pandey Rajeev-A19514
Hi, I have a list like @list = ( "key1: Vlan1 :0989\n" "key2: Vlan2 :0989\n" "key3: Vlan3 :0989\n" "key4: Vlan4 :0989\n"); I wanted to make a hash with keys as key1, key2 , key3, key4. I want to write something like this : **

Re: Wanted: Explanation of array slices used in hash creation

2001-06-27 Thread Me
@$hashref{@array}; One thing I remember finding useful in understanding this sort of stuff is that the sigils (@, $, etc.) are more binding (have a higher precedence, as it were), than subscript parens. So you deal with them first. So @ followed by other sigils is going to end up with a bunch of

Re: Wanted: Explanation of array slices used in hash creation

2001-06-27 Thread Jeff 'japhy' Pinyan
On Jun 27, Peter Cline said: >After studying examples in "Effective Perl Programming" I devised the >following working code snippet: > >@people{@newkeys} = @$contact{sort keys %$contact}; All a slice is, is a list of elements of the structure. @array[1,3,5] is ($array[1], $array[3], $arr

Wanted: Explanation of array slices used in hash creation

2001-06-27 Thread Peter Cline
After studying examples in "Effective Perl Programming" I devised the following working code snippet: @people{@newkeys} = @$contact{sort keys %$contact}; I am trying to understand exactly how and why it works. This appears in a subroutine that is passed a hash reference ($contact) @newkeys is d