Re: dereferencing an object

2016-11-08 Thread derrick
ok, Thank you for that. I was misunderstanding what the -> represented. It is working now. Derrick On Tue, Nov 08, 2016 at 11:29:41AM +, Chas. Owens wrote: > On Tue, Nov 8, 2016 at 5:38 AM wrote: > > > Hi, > > > > Yes, I was using a ref with my dumper. When i don't do that I don't get > > $

Re: dereferencing an object

2016-11-08 Thread Chas. Owens
On Tue, Nov 8, 2016 at 5:38 AM wrote: > Hi, > > Yes, I was using a ref with my dumper. When i don't do that I don't get > $VAR1 = \{ . > I am still getting an error when I dereference. > > my $name = ${$hash_ref_decode}->{items}[0]{content}; snip This says dereference $hash_ref_decode as a

Re: dereferencing an object

2016-11-08 Thread derrick
um_until' => undef, 'business_account_id' => undef, 'time_format' => 1, 'start_day' => 7, 'theme' => 3, 'date_format' =&g

Re: dereferencing an object

2016-11-07 Thread Uri Guttman
element of 'items'. I tried $$hash_ref{'items'}[0]{'content'} to get 'Practice pilates' but I got an error. Experimental keys on scalar is now forbidden at todoist.pl line 79. Am I on the right track? I am just learning about dereferencing now as I go thr

dereferencing an object

2016-11-07 Thread derrick
'items'}[0]{'content'} to get 'Practice pilates' but I got an error. Experimental keys on scalar is now forbidden at todoist.pl line 79. Am I on the right track? I am just learning about dereferencing now as I go through the intermediate perl book. I tried adding curlin

Re: Access class symtab by dereferencing an object

2012-03-14 Thread Jenda Krynicky
Date sent: Sat, 03 Mar 2012 14:42:35 -0500 From: Steve Bertrand > I've been writing a program that will perform extra work for diagnostics > upon each method call. > > As of now, I need to write a call to an outside function manually into > each method. To automa

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Uri Guttman
On 03/03/2012 02:42 PM, Steve Bertrand wrote: I've been writing a program that will perform extra work for diagnostics upon each method call. attributes can do that for each sub. there are modules that let you call code before/after each method call. or class techniques that allow that.

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Paul Johnson
On Sat, Mar 03, 2012 at 02:42:35PM -0500, Steve Bertrand wrote: > I've been writing a program that will perform extra work for > diagnostics upon each method call. > > As of now, I need to write a call to an outside function manually > into each method. To automate this so the original methods do

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Steve Bertrand
On 2012-03-03 14:18, Paul Johnson wrote: On Sat, Mar 03, 2012 at 01:51:28PM -0500, Steve Bertrand wrote: Is there a proper way to do this that someone could point out? no strict "refs"; foreach my $entry ( keys %{ ref($dog) . "::" }) But why? If you really need class introspection then OK,

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Uri Guttman
On 03/03/2012 01:51 PM, Steve Bertrand wrote: Hi all, I have a need to examine and manipulate certain aspects of a class symbol table. I can do this: you claim you have this need but given your skill level, i wonder if that is actually a real need. please state the larger problem you are tr

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Paul Johnson
On Sat, Mar 03, 2012 at 01:51:28PM -0500, Steve Bertrand wrote: > Hi all, > > I have a need to examine and manipulate certain aspects of a class > symbol table. I can do this: > > my $dog = Animal->new(); > foreach my $entry ( keys %Animal:: ){ > ... > } > > ...but what I'd like to do is der

Access class symtab by dereferencing an object

2012-03-03 Thread Steve Bertrand
Hi all, I have a need to examine and manipulate certain aspects of a class symbol table. I can do this: my $dog = Animal->new(); foreach my $entry ( keys %Animal:: ){ ... } ...but what I'd like to do is dereference the object itself to get the class, as there will be times I won't know w

Re: Dereferencing an array

2012-01-27 Thread Igor Dovgiy
Hi Rob, Just'd like to add my $0.02 to the brilliant solutions you offered. ) You can access the anonymous arrays from @desc using > > foreach my $rest (@desc) { >print "@$rest\n"; > } > > Or just... say "@$_" for @desc; ... if one prefers conciseness - and is able to use 5.010, of course

Re: Dereferencing an array

2012-01-27 Thread Rob Dixon
On 27/01/2012 10:14, Owen wrote: In the program below, I think I end up with an array of array references. But I can not get back the @rest from @desc where it is stored. Is it possible that @rest is just over written? Might have to think about doing something else. I can't use hashes as data

Dereferencing an array

2012-01-27 Thread Owen
In the program below, I think I end up with an array of array references. But I can not get back the @rest from @desc where it is stored. Is it possible that @rest is just over written? Might have to think about doing something else. I can't use hashes as data elements are sometimes duplicated.

Re: Dereferencing problem

2011-02-24 Thread Dr.Ruud
On 2011-02-23 13:53, HACKER Nora wrote: my $sql = "select secondname || ' ' || firstname from supp_verantw_v"; my $sth = $dbh->prepare($sql); my $personen = $dbh->selectall_arrayref($sql) or die "geht net: $!\n"; You are not usubng the $sth that you set up, why? my $sth = $dbh->prepare( <<'

AW: Dereferencing problem

2011-02-23 Thread HACKER Nora
erl.org > Cc: HACKER Nora > Betreff: Re: Dereferencing problem > > Hi Nora > > On 23/02/2011 12:53, HACKER Nora wrote: > > Hi, > > > > I want to work with data from my database. The following select and > > dereferencing for display is fine: > &g

Re: Dereferencing problem

2011-02-23 Thread Rob Dixon
Hi Nora On 23/02/2011 12:53, HACKER Nora wrote: > Hi, > > I want to work with data from my database. The following select and > dereferencing for display is fine: > > my $sql = "select secondname || ' ' || firstname from supp_verantw_v"; > my $sth = $

Re: Dereferencing problem

2011-02-23 Thread Brian Fraser
0; $i <= $#{$personen}; ++$i ) { print "Person $i: @{$personen->[$i]}\n"; } The main problem has in the print line; You were dereferencing a $person scalar that didn't exist! But even then, I'm guessing from your original program that $personen->[$i] (or $personen[$i],

Re: Dereferencing problem

2011-02-23 Thread Shawn H Corey
On 11-02-23 07:53 AM, HACKER Nora wrote: my @personen = @$personen; foreach my $person ( @personen ) { print "Dereferencing: @$person\n\n"; } Use Data::Dumper to inspect your data structures: use Data::Dumper; for my $person ( @$personen ){ print "Debug: $person = &q

Dereferencing problem

2011-02-23 Thread HACKER Nora
Hi, I want to work with data from my database. The following select and dereferencing for display is fine: my $sql = "select secondname || ' ' || firstname from supp_verantw_v"; my $sth = $dbh->prepare($sql); my $personen = $dbh->selectall_arrayref($sql) or die

Re: issue with dereferencing a hash

2010-11-04 Thread galeb abu-ali
thanks, you're right. I took another look at the data structure and got the script to work. On Wed, Nov 3, 2010 at 6:07 PM, Jim Gibson wrote: > On 11/3/10 Wed Nov 3, 2010 1:13 PM, "galeb abu-ali" > > scribbled: > > > Hi, > > > > I'm parsing

Re: issue with dereferencing a hash

2010-11-03 Thread Jim Gibson
On 11/3/10 Wed Nov 3, 2010 1:13 PM, "galeb abu-ali" scribbled: > Hi, > > I'm parsing an xml file and get an error when dereferencing a hash. I get an > error saying "Not a HASH reference as line 15." > Not sure where my syntax is off. Your syntax i

issue with dereferencing a hash

2010-11-03 Thread galeb abu-ali
Hi, I'm parsing an xml file and get an error when dereferencing a hash. I get an error saying "Not a HASH reference as line 15." Not sure where my syntax is off. thanks, galeb My script is: #!/usr/local/bin/perl # parse_xml_OMap.pl use strict; use warnings; use Data::Du

Re: dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
wow! My impending question about usage of -> also got answered ... On Thu, Aug 19, 2010 at 5:59 PM, Chas. Owens wrote: > On Thu, Aug 19, 2010 at 07:51, Sharan Basappa > wrote: >> Hello, >> >> Assuming I have reference to an hash array $rHash, what would be the >> way to dereference it. >> Woul

Re: dereferencing hash arrays

2010-08-19 Thread Chas. Owens
On Thu, Aug 19, 2010 at 07:51, Sharan Basappa wrote: > Hello, > > Assuming I have reference to an hash array $rHash, what would be the > way to dereference it. > Would it be: %hashEntry = %{$rHash}; ? snip The ways to dereference a hash are # treat $ref as a hash variable %$ref # treat $ref as

Re: dereferencing hash arrays

2010-08-19 Thread Robert Wohlfarth
On Thu, Aug 19, 2010 at 6:51 AM, Sharan Basappa wrote: > Assuming I have reference to an hash array $rHash, what would be the > way to dereference it. > Would it be: %hashEntry = %{$rHash}; ? > Yes, that dereferences the hash. It's useful notation in loops... foreach (keys %{$rHash}) while (my ($

dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
Hello, Assuming I have reference to an hash array $rHash, what would be the way to dereference it. Would it be: %hashEntry = %{$rHash}; ? Regards, Sharan -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Dereferencing hash with array value

2010-02-13 Thread Shawn H Corey
Dermot wrote: > On 13 February 2010 06:42, Owen wrote: >> The program below works, but I don't believe I have to make the >> reference # my $svgs = \...@svgs; to get it into the hash; >> >> I think I should be able to do something like >> >> $folders{$folder} = @svgs; >> print "$folders{Zt

Re: Dereferencing hash with array value

2010-02-13 Thread Dermot
On 13 February 2010 06:42, Owen wrote: > The program below works, but I don't believe I have to make the > reference  #  my $svgs = \...@svgs;     to get it into the hash; > > I think I should be able to do something like > >  $folders{$folder} = @svgs; >  print "$folders{Ztyx}->[3]\n"; You want

Re: Dereferencing hash with array value

2010-02-12 Thread Uri Guttman
> "O" == Owen writes: O> The program below works, but I don't believe I have to make the O> reference # my $svgs = \...@svgs; to get it into the hash; believe it. O> I think I should be able to do something like O> $folders{$folder} = @svgs; why do you think that should wo

Dereferencing hash with array value

2010-02-12 Thread Owen
The program below works, but I don't believe I have to make the reference # my $svgs = \...@svgs; to get it into the hash; I think I should be able to do something like $folders{$folder} = @svgs; print "$folders{Ztyx}->[3]\n"; But can't get my head around how to do it (The error message

Re: passing a hash via cookie and dereferencing it

2010-01-20 Thread Brad Baxter
On 1/18/2010 2:10 PM, mike wrote: Hello everyone: I am trying to pass a hash of hashes from one script to another via a cookie. I can get the cookie to pass, but when I try to get the inner hash keys and values using what I think is the correct method, I cannot get them. Here are two scripts wh

AW: passing a hash via cookie and dereferencing it

2010-01-19 Thread Thomas Bätzler
mike asked: > I am trying to pass a hash of hashes from one script to another via a > cookie. I can get the cookie to pass, but when I try to get the inner > hash keys and values using what I think is the correct method, I > cannot get them. Here are two scripts which should do it, but don't: A

passing a hash via cookie and dereferencing it

2010-01-19 Thread mike
>center( $xx->h2("\$KK is $KK\n") ); print SCRATCH "In test.cgi!\n"; print SCRATCH "\$KK is $KK\n"; for (keys %{$KK}) { print SCRATCH "Key: ",$_,"\t"; print SCRATCH "Value from reference: ",${$KK}{$_},"\n";

Re: Question about dereferencing

2008-06-10 Thread Jenda Krynicky
From: Christopher Yee Mon <[EMAIL PROTECTED]> > I have a bit of Perl homework where we got a code sample. I can see what > the code sample is doing except for two little bits > > There's a part that has $row->[$i] and a part that has @$row . What do > these two parts mean? $row-

Re: Question about dereferencing

2008-06-10 Thread Rob Dixon
Christopher Yee Mon wrote: > > I have a bit of Perl homework where we got a code sample. I can see what > the code sample is doing except for two little bits > > There's a part that has $row->[$i] and a part that has @$row . What do > these two parts mean? > > The code sample turns csv into fixe

Question about dereferencing

2008-06-10 Thread Christopher Yee Mon
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I have a bit of Perl homework where we got a code sample. I can see what the code sample is doing except for two little bits There's a part that has $row->[$i] and a part that has @$row . What do these two parts mean? The code sample turns csv

Re: Hash dereferencing problem

2007-11-13 Thread John W . Krahn
On Tuesday 13 November 2007 12:02, Chas. Owens wrote: > On Nov 13, 2007 12:55 PM, <[EMAIL PROTECTED]> wrote: > > > > my %napMD_ProgressCode = ( > > snip > > > drawInputRowControlled('napMD_ProgressCode'); > > snip > > That is because you are passing a scalar containing the string > "napMD_Progress

Re: Hash dereferencing problem

2007-11-13 Thread John W . Krahn
On Tuesday 13 November 2007 09:55, [EMAIL PROTECTED] wrote: > Folks, Hello, > I am having a problem dereferencing a hash and am hoping somebody can > assist. I am getting the error: It appears that you are actually having a problem creating a reference to a hash. perldoc perldat

Re: Hash dereferencing problem

2007-11-13 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > use strict; > my %napMD_ProgressCode = ( >[...] > ); > > sub drawInputRowControlled{ > my $ControlList = $_[0]; > my %ControlList = %$ControlList; #Problem line > > for my $i (sort keys %ControlList) { > print qq{ > name='status' >

Re: Hash dereferencing problem

2007-11-13 Thread Chas. Owens
On Nov 13, 2007 12:55 PM, <[EMAIL PROTECTED]> wrote: > Folks, > > I am having a problem dereferencing a hash and am hoping somebody can > assist. I am getting the error: > > Can't use string ("napMD_ProgressCode") as a HASH ref

Hash dereferencing problem

2007-11-13 Thread exlibris
Folks, I am having a problem dereferencing a hash and am hoping somebody can assist. I am getting the error: Can't use string ("napMD_ProgressCode") as a HASH ref while "strict refs" in use for the code below. I have tried various combinations of brack

Re: dereferencing

2007-10-29 Thread Aaron Priven
and requires lots of extra dereferencing by the interpreter. If %hash has a few thousand entries, routine (%hash); sub routine { my %myhash = @_; ... } is wasteful and timeconsuming, and I don't want to have to type lots of extra arrows just because I passed the hash to a subroutin

Re: dereferencing

2007-10-29 Thread Aaron Priven
Playing around with this, indeed, proves it can be done: #!/usr/bin/perl use strict; use warnings; use Data::Alias; my $hashref = { a => 5, b => 8}; alias my %hash = %{$hashref}; print $hash{a} , "\n"; prints 5. (And \%hash == $hashref evaluates true.) I knew that Data::Alias existed -- it's me

Re: dereferencing

2007-10-29 Thread Jeremy Kister
even possible, but I can't see any reason to need it, either. Oops. I knew I was making a new hash (hence the variable name). I read his message (and subject) to imply that all he wanted was dereferencing. My fault. -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e-ma

Re: dereferencing

2007-10-29 Thread John W . Krahn
On Monday 29 October 2007 15:23, Aaron Priven wrote: > I can do this: > > my $hashref = \%hash; > > But as near as I can tell, there is no way to do the reverse > operation: making a "my %hash" that is an alias for a hash reference. Correct. You can alias a package variable but not a lexical vari

Re: dereferencing

2007-10-29 Thread Paul Johnson
On Mon, Oct 29, 2007 at 05:21:52PM -0700, Tom Phoenix wrote: > On 10/29/07, Jeremy Kister <[EMAIL PROTECTED]> wrote: > > On 10/29/2007 7:23 PM, Aaron Priven wrote: > > > my $hashref = \%hash; > > > > > > But as near as I can tell, there is no way to do the reverse > > > operation: making a "my %ha

Re: dereferencing

2007-10-29 Thread Tom Phoenix
to a hash, create a named lexical hash that that reference refers to? No, that's not possible. Why would you even want to do that? Is it just a matter of convenience, so you can avoid dereferencing? As you found, you can manipulate the symbol table so that a name refers to a hash from a referen

Re: dereferencing

2007-10-29 Thread Tom Phoenix
On 10/29/07, Jeremy Kister <[EMAIL PROTECTED]> wrote: > On 10/29/2007 7:23 PM, Aaron Priven wrote: > > my $hashref = \%hash; > > > > But as near as I can tell, there is no way to do the reverse > > operation: making a "my %hash" that is an alias for a hash reference. > > my %newhash = %{$hashref};

Re: dereferencing

2007-10-29 Thread Jeremy Kister
On 10/29/2007 7:23 PM, Aaron Priven wrote: my $hashref = \%hash; But as near as I can tell, there is no way to do the reverse operation: making a "my %hash" that is an alias for a hash reference. my %newhash = %{$hashref}; -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e

dereferencing

2007-10-29 Thread Aaron Priven
I can do this: my $hashref = \%hash; But as near as I can tell, there is no way to do the reverse operation: making a "my %hash" that is an alias for a hash reference. It's possible with a package variable: #/usr/bin/perl our %hash; my $hashref = { a => 5 , b => 8 }; *hash = $hashref; print

Re: dereferencing hashes

2007-08-29 Thread Hunter Barrington
thnx for the reply. code @ http://barringtonweb.com/code.txt trying to pull data out of the td elements without iterating over them will look at html::element perldoc thanks a lot i think thats what i was missing, -Hunter Rob Dixo

Re: dereferencing hashes

2007-08-29 Thread Rob Dixon
Hunter Barrington wrote: ok so im using HTML::TreeBuilder to pull some data off of a website and parse it. If I'm understanding this right each tag of the tree is put inside the tree as a hash reference with hash references inside of it for each tag thats below it. Like: = $root_hash_ref->$body

dereferencing hashes

2007-08-29 Thread Hunter Barrington
ok so im using HTML::TreeBuilder to pull some data off of a website and parse it. If I'm understanding this right each tag of the tree is put inside the tree as a hash reference with hash references inside of it for each tag thats below it. Like: = $root_hash_ref->$body_hash_ref->$p_hash_ref

Re: dereferencing

2005-08-24 Thread Edward WIJAYA
On Thu, 25 Aug 2005 10:31:18 +0800, Christopher Spears <[EMAIL PROTECTED]> wrote: I'm trying to brush up on my Perl by learning object oriented Perl! This may not be the best way to brush up on this subject, but I am sure that I will learn a lot! Here is a script: #!/usr/bin/perl -w use str

Re: dereferencing

2005-08-24 Thread John W. Krahn
array" > Execution of ./anonymousData aborted due to > compilation errors. > > What am I doing wrong? Out of curiousity, if the > array was anonymous, then how can I find it's size. > > $arrayref = [1, 2, ['a', 'b', 'c', 'd'

dereferencing

2005-08-24 Thread Christopher Spears
sData line 8, near "->@array" Execution of ./anonymousData aborted due to compilation errors. What am I doing wrong? Out of curiousity, if the array was anonymous, then how can I find it's size. $arrayref = [1, 2, ['a', 'b', 'c', 'd&#

dereferencing array of hashes in a Tk widget

2004-09-13 Thread Michael Ragsdale
y of the value changing, and this is was is passed to the subroutine, but I'm getting lost in the referencing/dereferencing. Suggestions on how to make this work? Am I making it too hard? -Mike -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Problem with dereferencing of $_

2004-01-14 Thread Rob Dixon
} > } > else { > while (my @row = $sel->fetchrow_array) { > print OUTPUT '"'; > print OUTPUT join '","', map {$_||0} @row; > print OUTPUT '"',"\n"; > } > } The fetchrow_array

Re: Problem with dereferencing of $_

2004-01-13 Thread drieux
On Jan 13, 2004, at 10:12 AM, Duan Toh wrote: [..] while ($sel->fetchrow_array) { print OUTPUT '"'; print OUTPUT join '","', map {$_||0} @$_; print OUTPUT '"',"\n"; } [..] you might want to go back

Re: Problem with dereferencing of $_

2004-01-13 Thread Duan Toh
Hello all, testing the use of DBI. Having a problem (highlighted in red) with using "@$_" as the topic. When I use @row the program writes records as expected to test.txt but when I use the topic it only writes ... "" "" "" in the file. I have reread documentation to see if I am using @$_ co

RE: dereferencing a list from a class

2003-11-24 Thread Rajesh Dorairajan
--Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Saturday, November 22, 2003 8:18 AM To: Rajesh Dorairajan Cc: '[EMAIL PROTECTED]' Subject: Re: dereferencing a list from a class On Nov 21, 2003, at 3:19 PM, Rajesh Dorairajan wrote: > I've

Re: dereferencing a list from a class

2003-11-22 Thread drieux
On Saturday, Nov 22, 2003, at 08:17 US/Pacific, James Edward Gray II wrote: On Nov 21, 2003, at 3:19 PM, Rajesh Dorairajan wrote: I've a class (blessed, of course :)) that has variables like: $self->a = "1"; $self->b = "2"; $self->c = [ '1', '2', '3', '4' ]; I think/hope you meant: $self->{a}

Re: dereferencing a list from a class

2003-11-22 Thread R. Joseph Newton
Rajesh Dorairajan wrote: > I've a class (blessed, of course :)) that has variables like: > > $self->a = "1"; > $self->b = "2"; > $self->c = [ '1', '2', '3', '4' ]; > > Now, I want to write a foreach loop to iterate through $self->c and print > the values. However: > > foreach my $foo ( $self->c )

Re: dereferencing a list from a class

2003-11-22 Thread James Edward Gray II
On Nov 21, 2003, at 3:19 PM, Rajesh Dorairajan wrote: I've a class (blessed, of course :)) that has variables like: $self->a = "1"; $self->b = "2"; $self->c = [ '1', '2', '3', '4' ]; I think/hope you meant: $self->{a} = '1';# any reason we're quoting integers? $self->{b} = '2'; $self

FW: dereferencing a list from a class

2003-11-22 Thread Rajesh Dorairajan
message bounced. retrying -Original Message- From: Rajesh Dorairajan Sent: Friday, November 21, 2003 1:19 PM To: '[EMAIL PROTECTED]' Subject: dereferencing a list from a class I've a class (blessed, of course :)) that has variables like: $self->a = "1"; $se

dereferencing a list from a class

2003-11-22 Thread Rajesh Dorairajan
I've a class (blessed, of course :)) that has variables like: $self->a = "1"; $self->b = "2"; $self->c = [ '1', '2', '3', '4' ]; Now, I want to write a foreach loop to iterate through $self->c and print the values. However: foreach my $foo ( $self->c ) { print $foo; } gets me the whole

Re: Dereferencing an array reference

2003-07-20 Thread Wiggins d'Anconia
Rob Richardson wrote: Greetings! I am seriously confoogled about how to get my array back from a reference. This is the train scheduling program you've been hearing a lot about from me. The array holds the names of the crew members on the train. The train object is created with the following ro

Dereferencing an array reference

2003-07-19 Thread Rob Richardson
Greetings! I am seriously confoogled about how to get my array back from a reference. This is the train scheduling program you've been hearing a lot about from me. The array holds the names of the crew members on the train. The train object is created with the following routine: sub new {

RE: Dereferencing an XML data structure...

2003-06-17 Thread Paul Johnson
Hamish Whittal said: > Appologies for not making myself clear first time round. Let me try that > again: > > I have said XML file, which when read in using XML::Simple leaves me > with below data structure. > > Now, I want to end up with: > $NEWSTRUCT = { > 'device' => { >'sysObjectID' =>

RE: Dereferencing an XML data structure...

2003-06-17 Thread Hamish Whittal
Appologies for not making myself clear first time round. Let me try that again: I have said XML file, which when read in using XML::Simple leaves me with below data structure. Now, I want to end up with: $NEWSTRUCT = { 'device' => { 'sysObjectID' => '.1.3.6.1.4.1.9.1.219', 'commonM

Dereferencing an XML data structure...

2003-06-17 Thread Hamish Whittal
Hi Everybody, I have a data structure as follows (I used XML::Simple to read the XML file) $VAR1 = { 'device' => { 'sysObjectID' => '.1.3.6.1.4.1.9.1.219', 'chassis' => { 'chassisType' => '.1.3.6.1.4.1

Re: Dereferencing: help!!!!

2002-12-17 Thread Wim
Hi all, Found it double quotes did the trick! Thanx anyway. Cheers! Wim Wim wrote: Hi, I'm trying to put some data in a postgres database, but it is not so easy as I expected This is my code: foreach $ipaddress (sort keys %ifipaddr) { $ip = new NetAddr::IP "$ipaddress", "$ifnetma

Dereferencing: help!!!!

2002-12-17 Thread Wim
Hi, I'm trying to put some data in a postgres database, but it is not so easy as I expected This is my code: foreach $ipaddress (sort keys %ifipaddr) { $ip = new NetAddr::IP "$ipaddress", "$ifnetmask{$ipaddress}"; $sth4 -> execute

RE: dereferencing a array element reference

2002-10-18 Thread Jeff 'japhy' Pinyan
On Oct 18, HENRY,MARK (HP-Roseville,ex1) said: >Huh, so pointers with the purpose of modifying the original data are not >necessary in perl? > >Why then would you use references (apart from the performance of passing >large amounts of data by value)? > >For larger & more data structures? It's bet

RE: dereferencing a array element reference

2002-10-18 Thread HENRY,MARK (HP-Roseville,ex1)
Message- > From: Jeff 'japhy' Pinyan [mailto:japhy@;perlmonk.org] > Sent: Thursday, October 17, 2002 10:35 PM > To: HENRY,MARK (HP-Roseville,ex1) > Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]' > Subject: RE: dereferencing a array element reference &

Re: dereferencing a array element reference

2002-10-18 Thread Jeff 'japhy' Pinyan
On Oct 17, HENRY,MARK (HP-Roseville,ex1) said: >I'm passing a few variables into a function, and I want to be hip so I send >them in as references.. > >my_function (\$var_1, \$var_2); You really don't need to, but ok. >print "var 1 is $$_[0] and 2 is $$_[1]"; > >This doesn't work, but you get th

Re: dereferencing a array element reference

2002-10-18 Thread Jenda Krynicky
From: "HENRY,MARK (HP-Roseville,ex1)" <[EMAIL PROTECTED]> > I'm passing a few variables into a function, and I want to be hip so I > send them in as references.. > > my_function (\$var_1, \$var_2); > > Now, within the function, can I dereference them immediately? I've > assigni

RE: dereferencing a array element reference

2002-10-18 Thread Jeff 'japhy' Pinyan
On Oct 17, HENRY,MARK (HP-Roseville,ex1) said: >> You really don't need to, but ok. >> >This depends on whether I want to modify the passed in variable.. (as well >as to be hip :) You can modify variables sent to a function by modifying @_ by index: sub foo { $_[0] += 2; } $r = 13;

RE: dereferencing a array element reference

2002-10-18 Thread HENRY,MARK (HP-Roseville,ex1)
> You really don't need to, but ok. > This depends on whether I want to modify the passed in variable.. (as well as to be hip :) > >print "var 1 is $$_[0] and 2 is $$_[1]"; > > > >This doesn't work, but you get the idea... > > That's because the $ binds to the $_, and not to the $_[0]. You wa

dereferencing a array element reference

2002-10-18 Thread HENRY,MARK (HP-Roseville,ex1)
Hi All, Wondering if someone can give me a shortcut for the following.. I'm passing a few variables into a function, and I want to be hip so I send them in as references.. my_function (\$var_1, \$var_2); Now, within the function, can I dereference them immediately? I've assigning them to inter

Re: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
ECTED]] > > Sent: Wednesday, July 10, 2002 12:26 PM > > To: Timothy Johnson; [EMAIL PROTECTED] > > Cc: Shawn; Connie Chan; [EMAIL PROTECTED] > > Subject: more example code Re: help dereferencing arrayref so > > I can put > > the value into a hash > &g

Re: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
olz [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, July 10, 2002 12:26 PM > > To: Timothy Johnson; [EMAIL PROTECTED] > > Cc: Shawn; Connie Chan; [EMAIL PROTECTED] > > Subject: more example code Re: help dereferencing arrayref so > > I can put > > the valu

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >you get a warning with @x[2] if 'x' is an array, >but no warning with @$x[2] where 'x' is an array ref. >so perl isn't handling quite the same. Well, let me refer to the source. toke.c is where the "scalar value @x[1] better written as $x[1]" comes from. To raise

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:05 AM, Jeff 'japhy' Pinyan wrote: > On Jul 10, bob ackerman said: > >> and, as someone pointed out, this does work: >> $x = ['abc','def','ghi']; >> print @$x[2]."\n"; # prints 'ghi' >> >> but i couldn't tell you how perl reads this, except to say that '@

RE: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Timothy Johnson
our code doesn't fat-finger it and try to dereference the wrong thing. E.g. $$x[2] should always be written as ${$x}[2], or the alternate $x->[2], that way it is clear that you are dereferencing $x, NOT $x[2]. - (on smtp3.sandisk.com) P

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >> All lists get auto-cast into a scalar, in scalar context. An array slice >> is merely a list of array elements. >> >> $x = @y[2]; >> >> is the same as >> >> $x = ($y[2]); > >except you will get warnings on these lines. Perl warns about @x[$i] because it was

RE: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Bob Showalter
> -Original Message- > From: Zachary Buckholz [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 10, 2002 12:26 PM > To: Timothy Johnson; [EMAIL PROTECTED] > Cc: Shawn; Connie Chan; [EMAIL PROTECTED] > Subject: more example code Re: help dereferencing arrayref so >

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:39 AM, Jeff 'japhy' Pinyan wrote: > On Jul 10, George Schlossnagle said: > >> Am I alone in thinking that $x->[2] is much more readable that @$x[2] >> or $$x[2]? > > No; I always use the $ref->... syntax, unless I'm golfing. > >> @b[2] is an array slice with

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, George Schlossnagle said: >Am I alone in thinking that $x->[2] is much more readable that @$x[2] >or $$x[2]? No; I always use the $ref->... syntax, unless I'm golfing. >@b[2] is an array slice with a single element (which strangely seems to >get auto-cast as a scalar). All lists

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:29 AM, George Schlossnagle wrote: >> and, as someone pointed out, this does work: >> $x = ['abc','def','ghi']; >> print @$x[2]."\n"; # prints 'ghi' > > > Am I alone in thinking that $x->[2] is much more readable that @$x[2] > or $$x[2]? i was only sa

more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
s); } sub get_pct_up_time($sum_checks, $sum_errors) { my $sum_checks = $_[0]; my $sum_errors = $_[1]; my @pct_up_time; for(my $i = 0; $i <= 6; $i++) { if(@$sum_checks[$i] == 0) {next;}; my $sum_good = @$sum_checks[$i] - @$sum_errors[$i]; $pct_up_time[$i] = (($sum_good * 100) /

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread George Schlossnagle
> and, as someone pointed out, this does work: > $x = ['abc','def','ghi']; > print @$x[2]."\n"; # prints 'ghi' Am I alone in thinking that $x->[2] is much more readable that @$x[2] or $$x[2]? > > but i couldn't tell you how perl reads this, except to say that '@$x' > dereferences and

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >and, as someone pointed out, this does work: >$x = ['abc','def','ghi']; >print @$x[2]."\n"; # prints 'ghi' > >but i couldn't tell you how perl reads this, except to say that '@$x' >dereferences and then '[2]' gets the array element. >but i don't know why a '$

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 01:31 AM, Janek Schleicher wrote: > Shawn wrote at Wed, 10 Jul 2002 09:59:54 +0200: > >> I think what you are looking for is: >> $avg_resp_time->[0] >> >> if you want to have the '@' at the front, I think you would need >> something like this: >> @{$avg_resp_t

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Janek Schleicher
Shawn wrote at Wed, 10 Jul 2002 09:59:54 +0200: > I think what you are looking for is: > $avg_resp_time->[0] > > if you want to have the '@' at the front, I think you would need something like this: > @{$avg_resp_time}[0] > What should be better written as ${$avg_resp_time}[0] if you want to

RE: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Timothy Johnson
First of all, don't forget to 'use strict;' at the top of your script. But here's a couple of scenarios. The last two are what you are looking for. Always remember to put curly braces around the reference when you are dereferencing, and you won't run into this proble

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Shawn
"Zachary Buckholz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I understand how to use a foreach on a reference to an array as follows: > > my $avg_resp_time = get_avg_resp_time($durations, $url_id); > foreach my $avg_resp(@$avg_resp_time) { > print

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Connie Chan
> But how do I directly access one array value from the reference to the > array? > > print "DEBUG TEST @$avg_resp_time[0]\n";Fails > print "DEBUG TEST @$avg_resp_time->[0]\n";Fails > print "DEBUG TEST @{$avg_resp_time[0]}\n";Fails > Why don't just print "DEBUG TEST $avg_resp_time

  1   2   >