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
> > $
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
um_until' => undef,
'business_account_id' => undef,
'time_format' => 1,
'start_day' => 7,
'theme' => 3,
'date_format' =&g
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
'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
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
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.
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
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,
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
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
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
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
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
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.
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( <<'
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
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 = $
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],
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
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
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
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
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
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
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
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 ($
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/
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
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
> "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
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
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
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
>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";
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-
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
-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
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
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
[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'
>
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
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
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
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
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
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
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
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
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};
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
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
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
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
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
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
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'
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
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>
}
> }
> else {
> while (my @row = $sel->fetchrow_array) {
> print OUTPUT '"';
> print OUTPUT join '","', map {$_||0} @row;
> print OUTPUT '"',"\n";
> }
> }
The fetchrow_array
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
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
--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
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}
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 )
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
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
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
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
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
{
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' =>
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
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
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
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
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
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
&
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
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
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;
> 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
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
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
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
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
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 '@
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
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
> -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
>
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
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
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
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) /
> 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
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 '$
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
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
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
"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
> 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 - 100 of 129 matches
Mail list logo