On Wed, Mar 21, 2012 at 9:04 PM, Mendor wrote:
> You can use reverse() for this, can't you?
Thanks for both of you.
I didn't know the reverse() can do this, and didn't realize how mature
the perl has evolved.
About the $array, before I mistook %h as %array, later writing email I
realize this.
ׁHi Lina,
On Wed, 21 Mar 2012 21:00:53 +0800
lina wrote:
> Hi,
>
> I tried to write something, but chocked in the end,
>
> Thanks ahead for your advice,
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
>
> my %h = (
> 1 => "a",
> 2 => "b",
> 3 => "c"
> );
>
> forea
You can use reverse() for this, can't you?
--
Regards.
On 21.03.2012 17:00, lina wrote:
Hi,
I tried to write something, but chocked in the end,
Thanks ahead for your advice,
#!/usr/bin/env perl
use strict;
use warnings;
my %h = (
1 => "a",
2 => "b",
3 => "c"
);
Hi,
I tried to write something, but chocked in the end,
Thanks ahead for your advice,
#!/usr/bin/env perl
use strict;
use warnings;
my %h = (
1 => "a",
2 => "b",
3 => "c"
);
foreach my $key ( sort keys %h){
$h{$h{$key}}=$key;
delete $h{$key};
}
Daniel Falkenberg wrote:
>
> Hello All,
Hello,
> I currently have a hash of a hash...
>
> > %HoH = (
> > Key1=> {
> > Apple => "Green",
> > Banna => "Yellow",
> > },
> > Key2=> {
> > Carrot=> "Or
On Tuesday 29 June 2004 08:49, Daniel Falkenberg wrote:
> Hello All,
Hi Dan,
> I currently have a hash of a hash...
>
> > %HoH = (
> > Key1=> {
> > Apple => "Green",
> > Banna => "Yellow",
> > },
> > Key2=> {
> >
On Tue, 2004-06-29 at 12:19, Daniel Falkenberg wrote:
> Hello All,
>
> I currently have a hash of a hash...
>
> > %HoH = (
> > Key1=> {
> > Apple => "Green",
> > Banna => "Yellow",
> > },
> > Key2=> {
> >
Hello All,
I currently have a hash of a hash...
> %HoH = (
> Key1=> {
> Apple => "Green",
> Banna => "Yellow",
> },
> Key2=> {
> Carrot=> "Orange",
> Tomoatoe => "Red",
> }
On Feb 9, Matt C. said:
>my @array=split; #split on space by default
>$HASH{ $array[0] } = @array[1,2];
>
># Above is the slice. Notice the @arry[1,2]; it's in array context.
No, it's in scalar context.
$x = @array[1,2];
is like
$x = ($array[1], $array[2]);
which sets $x to
This example shows an array slice, which can be very useful from time to time
(although the example Briac wrote saves a step). This would make a good one liner.
#!/usr/local/bin/perl -w
use strict;
my %HASH;
while(){
my @array=split; #split on space by default
$HASH{ $array[0] } = @array
On Sat, 09 Feb 2002 13:49:59 +, Terri Harrison
<[EMAIL PROTECTED]> wrote:
> What do I do so that the Name is the key and the Species and Gender
> together are the value?
You were not too far from what you wanted to do.
#!/usr/bin/perl -w
use strict;
my %zoo;
while (){
chomp;
If this is my input:
Happy Cat Male
Evil Snake Female
Patches Dog Male
Bubbles Fish Female
Harley dog Female
Goldy Fish Male
What do I do so that the Name is the key and the Species and Gender together
are the value?
while (<>) {
chomp;
%chars = split(' ', $_);
$chars{
12 matches
Mail list logo