- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to access hash values in "arrays of hases"...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2006 08:12 AM
тАО08-09-2006 08:12 AM
Re: How to access hash values in "arrays of hases" ?
my %loopdata;
being inside of your while loop. I'm thinking that having it inside rather than outside is going to cause that variable to be defined each time you go through the loop. For instance, try these two small examples to see the difference:
my $j = 0;
my $k; # $k defined on the outside
while ($k < 10) {
$j++;
$k = $j;
print "k = $k\n"; # prints 1 - 10
}
--- vs. ---
my $j = 0;
while ($k < 10) {
my $k; # $k defined on the inside
$j++;
$k = $j;
print "k = $k\n"; # prints 1 - infinity
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2006 05:17 PM
тАО08-09-2006 05:17 PM
Re: How to access hash values in "arrays of hases" ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2006 08:40 AM
тАО08-10-2006 08:40 AM
Re: How to access hash values in "arrays of hases" ?
my @array=(80,70,60,50,40,30,20,10);
my $i = 3;
print "i before = $i\n";
print "array elements $i = $array[$i]\n";
print "array elements " . ($i + 1) . " = " . $array[$i + 1] . "\n";
print "i after = $i\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2006 04:37 PM
тАО08-10-2006 04:37 PM
Re: How to access hash values in "arrays of hases" ?
I got what I wanted.
I have given you the points.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2006 07:40 PM
тАО08-10-2006 07:40 PM
Re: How to access hash values in "arrays of hases" ?
you may not have come accross array and hash slices.
These allow you to "slice" more than one list element in one go.
Remember in Perl (up until now, but they are going to change this in Perl6 because it seems to cause too much confusion among Perl beginners) that an "$" in a variable refers to always what you get, viz. a scalar,
while a "@" refers to a list.
So often in beginners' scripts you will see statements like
$someval = @ary[$i];
which in fact is calling for a slice.
But as you only index one element it doesn't make much sence.
Whereas if you are after, say the 3rd, 8th, and 12th to 14th element, you could reference them in one go
($elem3, $elem8, $elem12, $elem13, $elem14) = @ary[3,8,12..14];
or better
@myslice = @ary[3,8,12..14];
The same of course works for hash slices.
Say those keys exist, neglecting testing for their existence.
@myslice = @loopdata{qw(interval type date)}
- « Previous
-
- 1
- 2
- Next »