freelanceprogrammers.org Forum Index » Perl
Arrays
Joined: 21 Jun 2005
Posts: 3
Arrays
I have this Array:
$perl = [
{
fname => `Fred`,
lname => `Flintstone`,
residence => `Bedrock`
},
{
fname => `Barney`,
lname => `Rubble`,
residence => `Bedrock`
}
];
How to reach Fred?
How to add new rows to this array?!
Joined: 21 Feb 2005
Posts: 7
Arrays
Okay ....
you want to print the value "Fred".... go through the code
@yes = @$perl;
foreach $ha1 (@yes) {
%val = %$ha1;
print $val{`fname`};
last;
}
redstarfcs <no_reply@yahoogroups.com> wrote:
I have this Array:
$perl = [
{
fname => `Fred`,
lname => `Flintstone`,
residence => `Bedrock`
},
{
fname => `Barney`,
lname => `Rubble`,
residence => `Bedrock`
}
];
How to reach Fred?
How to add new rows to this array?!
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
How much free photo storage do you get? Store your holiday snaps for FREE with
Yahoo! Photos. Get Yahoo! Photos
[Non-text portions of this message have been removed]
Joined: 21 May 2004
Posts: 44
Arrays
>>>>> "redstarfcs" == redstarfcs <no_reply@yahoogroups.com> writes:
redstarfcs> I have this Array:
redstarfcs> $perl = [
redstarfcs> {
redstarfcs> fname => `Fred`,
redstarfcs> lname => `Flintstone`,
redstarfcs> residence => `Bedrock`
redstarfcs> },
redstarfcs> {
redstarfcs> fname => `Barney`,
redstarfcs> lname => `Rubble`,
redstarfcs> residence => `Bedrock`
redstarfcs> }
redstarfcs> ];
redstarfcs> How to reach Fred?
redstarfcs> How to add new rows to this array?!
perldoc perlref
perldoc perlreftut
perldoc perllol
"Learning Perl Objects, References, and Modules" from O`Reilly
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Joined: 22 Jun 2005
Posts: 1
Arrays
Hi,
i beleive this is the way to reach `fred`.
print $perl->[0]->{`fname`};
redstarfcs <no_reply@yahoogroups.com> wrote:
I have this Array:
$perl = [
{
fname => `Fred`,
lname => `Flintstone`,
residence => `Bedrock`
},
{
fname => `Barney`,
lname => `Rubble`,
residence => `Bedrock`
}
];
How to reach Fred?
How to add new rows to this array?!
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[Non-text portions of this message have been removed]
Joined: 22 May 2005
Posts: 3
Arrays
Hello,
Try this:
print $$perl[0]{fname};
Regards,
Georges
-------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
Minitel: 3615 NETCOURRIER (0,16 € TTC/min)
Joined: 21 Apr 2005
Posts: 3
Arrays
Hai,
For getting Fred try this
$perl = [
{
fname => `Fred`,
lname => `Flintstone`,
residence => `Bedrock`
},
{
fname => `Barney`,
lname => `Rubble`,
residence => `Bedrock`
}
];
print $perl->[0]->{fname};
For adding try this..
$perl = [
{
fname => `Fred`,
lname => `Flintstone`,
residence => `Bedrock`
},
{
fname => `Barney`,
lname => `Rubble`,
residence => `Bedrock`
}
];
$perl->[2] = {
fname =>`prasanna`,
lname => `k`,
residence => `panruti`
};
print $perl->[2]->{fname};
Regards
Prasanna.K
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Joined: 06 Apr 2005
Posts: 12
Arrays
> I have this Array:
>
> $perl = [
> {
> fname => `Fred`,
> lname => `Flintstone`,
> residence => `Bedrock`
> },
> {
> fname => `Barney`,
> lname => `Rubble`,
> residence => `Bedrock`
> }
> ];
>
> How to reach Fred?
You can do that in this way: $perl->[0]->{`fname`};
This is referring the first anonymous hash, and in turn the key `fname`.
> How to add new rows to this array?!
This can be achieved by :
push(@$perl, {fname=>`Paul`,lname=>`Alapatt`,residence=>`Bombay`});
Take care,
Paul Alapatt
http://www.bernardlabs.org/
Joined: 22 Jun 2005
Posts: 4
Arrays
--- redstarfcs <no_reply@yahoogroups.com> wrote:
> I have this Array:
>
> $perl = [
> {
> fname => `Fred`,
> lname => `Flintstone`,
> residence => `Bedrock`
> },
> {
> fname => `Barney`,
> lname => `Rubble`,
> residence => `Bedrock`
> }
> ];
>
> How to reach Fred?
>
> How to add new rows to this array?!
>
>
>
>
>
Hi,
Here`s how,
$perl = [
{
fname=> `Fred`,
lname=> `Flintstone`,
residence=> `Bedrock`
},
{
fname=> `Barney`,
lname=> `Rubble`,
residence=> `Bedrock`
}
];
print $perl->[0]->{fname},"
";
$perl->[2]->{New} = "Hello World";
$perl->[2]->{Old} = "GoodBye World";
print $perl->[2]->{pavan},"
";
-Pavan
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
Joined: 01 May 2004
Posts: 7
Arrays
This is how:
$perl->[0]->{fname}
Also, please read about references.
Try:
`perldoc perlref`
or
`perldoc perlreftut`
BTW, that`s an array of hashes.
HTH
redstarfcs wrote:
> I have this Array:
>
> $perl = [
> {
> fname => `Fred`,
> lname => `Flintstone`,
> residence => `Bedrock`
> },
> {
> fname => `Barney`,
> lname => `Rubble`,
> residence => `Bedrock`
> }
> ];
>
> How to reach Fred?
>
> How to add new rows to this array?!
>
>
--
eman
http://www.bloodpet.tk/
gpg --keyserver pgp.mit.edu --recv-keys 4C683E4C
Registered Linux User #287022
+63(2)455-3222
Books just wanna be FREE! See what I mean at:
http://bookcrossing.com/friend/bloodpet
[Non-text portions of this message have been removed]
Joined: 01 May 2004
Posts: 7
Arrays
merlyn@... wrote:
>
> perldoc perlref
> perldoc perlreftut
> perldoc perllol
> "Learning Perl Objects, References, and Modules" from O`Reilly
>
I didn`t know there`s a perllol... hehe
Checked it out, and there is. What does lol in perllol stand for?
--
eman
http://www.bloodpet.tk/ || http://www.bloodpet.dsl.ph/
gpg --keyserver pgp.mit.edu --recv-keys 4C683E4C
Registered Linux User #287022
+63(2)455-3222
Books just wanna be FREE! See what I mean at:
http://bookcrossing.com/friend/bloodpet
[Non-text portions of this message have been removed]
Joined: 21 May 2004
Posts: 44
Arrays
>>>>> "skumar" == skumar <psk_suresh@...> writes:
skumar> %val = %$ha1;
This *copies* the data. That`s inefficient, unnecessary,
and prevents updating the data.
Please read other answers already given, and ignore this answer.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Joined: 21 May 2004
Posts: 44
Arrays
>>>>> "g" == g toullat <g.toullat@...> writes:
g> Hello,
g> Try this:
g> print $$perl[0]{fname};
The preferred syntax for this is $perl->[0]{fname}.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Joined: 21 May 2004
Posts: 44
Arrays
>>>>> "Emanuel" == Emanuel Gardaya Calso <bloodpet@...> writes:
Emanuel> I didn`t know there`s a perllol... hehe
Emanuel> Checked it out, and there is. What does lol in perllol stand for?
"lists of lists".
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Joined: 21 Feb 2005
Posts: 7
Arrays
Randal L. Schwartz,
Don`t think all are perl gurus in this world , but you may be. If a person
approaches for some solution, everyone can give some link for reference (That
you did), but try to provide some solution for that.
I can see many developers (Harish,georges_toullat,k prasanna etc) provided
solutions without giving reference blah blah ...
And please try to understand that this is not a proper place to display your
identity (may be you are a TOP consultant etc...)
Skumar
"Randal L. Schwartz" <merlyn@...> wrote:
>>>>> "skumar" == skumar
writes:
skumar> %val = %$ha1;
This *copies* the data. That`s inefficient, unnecessary,
and prevents updating the data.
Please read other answers already given, and ignore this answer.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
---------------------------------
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[Non-text portions of this message have been removed]
Joined: 21 May 2004
Posts: 44
Arrays
>>>>> "skumar" == skumar <psk_suresh@...> writes:
skumar> Don`t think all are perl gurus in this world , but you may
skumar> be. If a person approaches for some solution, everyone can
skumar> give some link for reference (That you did), but try to
skumar> provide some solution for that.
But the people that give wrong answers need to be told that, so that
the original seeker knows to ignore it as well. And maybe that means
the person who gave the wrong answer also needs to stop answering
questions for a while because apparently they know less than they
think they know.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
All times are GMT
Page 1 of 2
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







