2009/11/13 Anant Gupta :
> ohhh ok.
> Thanks for the help
>
> But there is an XML example using XML::Twig in which
> the author has defined the hash as
> my $hash={ 'abc'=>'def'.
> 'ghi'=>'jkl',
> 'mnp'=>'pqr'
> }
>
> I thought it is a refe
ohhh ok.
Thanks for the help
But there is an XML example using XML::Twig in which
the author has defined the hash as
my $hash={ 'abc'=>'def'.
'ghi'=>'jkl',
'mnp'=>'pqr'
}
I thought it is a reference to a hash.
Is it so? Can we directl
Anant Gupta wrote:
..
use strict;
..
my %hash;
my $abc;
my $count;
while(defined($ARGV[$count]))
{
push(@hash{$abc},$ARGV[$count]);
}
@ARGV gets its values from the command line so all its elements should
be defined, unless you are using delete() on one of its elements. You
are not chan
2009/11/12 Anant Gupta :
> my %hash;
> my $abc;
> my $count;
> while(defined($ARGV[$count]))
> {
> push(@hash{$abc},$ARGV[$count]);
> }
>
> The error is "Type of arg 1 must be array not hash element ..."
The error is correct, you can't "push" to a hash element. Question is,
what exactly do you
On Thu, Nov 12, 2009 at 6:01 PM, Anant Gupta wrote:
> ..
> use strict;
> ..
>
> my %hash;
> my $abc;
> my $count;
> while(defined($ARGV[$count]))
> {
> push(@hash{$abc},$ARGV[$count]);
> }
>
If I guess that correctly, what you want is:
push(@{$hash{$abc}},$ARGV[$count]);
--
To unsubscribe, e
Anant Gupta wrote:
..
use strict;
..
my %hash;
my $abc;
my $count;
while(defined($ARGV[$count]))
{
push(@hash{$abc},$ARGV[$count]);
}
Can't i use this
The error is "Type of arg 1 must be array not hash element ..."
@hash{$abc} is a hash slice. You probably want @{$hash{$abc}}.
John
..
use strict;
..
my %hash;
my $abc;
my $count;
while(defined($ARGV[$count]))
{
push(@hash{$abc},$ARGV[$count]);
}
Can't i use this
The error is "Type of arg 1 must be array not hash element ..."
Help
Anant
From: Kevin Viel <[EMAIL PROTECTED]>
> > > my %fruit_color = ( apple => "red"
> > > , banana => "yellow"
> > > ) ;
> >
> > Sure, you can use it, you can skip it, whichever works better
> > for you.
> > (I find this style ... erm ... strange, but that's your d
> > my %fruit_color = ( apple => "red"
> > , banana => "yellow"
> > ) ;
>
> Sure, you can use it, you can skip it, whichever works better
> for you.
> (I find this style ... erm ... strange, but that's your decision.)
Thanks for your reply. Could you clari
On 30 Oct 2007 at 9:31, Kevin Viel wrote:
> > -Original Message-
> > From: Kaushal Shriyan [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 29, 2007 11:25 PM
> > To: beginners@perl.org
> > Subject: Re: Hash Variables
> >
> > I am referrin
> -Original Message-
> From: Kaushal Shriyan [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 29, 2007 11:25 PM
> To: beginners@perl.org
> Subject: Re: Hash Variables
>
> I am referring to perldoc perlintro
> my %fruit_color = ("apple", "red&
On Oct 29, 8:25 pm, [EMAIL PROTECTED] (Kaushal Shriyan) wrote:
> Hi
>
> I am referring to perldoc perlintro
> my %fruit_color = ("apple", "red", "banana", "yellow");
>
> You can use whitespace and the "=>" operator to lay them out more nicely:
>
>my %fruit_color = (
>
Hi
I am referring to perldoc perlintro
my %fruit_color = ("apple", "red", "banana", "yellow");
You can use whitespace and the "=>" operator to lay them out more nicely:
my %fruit_color = (
apple => "red",
banana => "yellow",
);
sivasakthi wrote:
> On Mon, 2007-10-29 at 17:06 +0530, Kaushal Shriyan wrote:
>
>
>
>>
>>
>> #!/usr/bin/perl -w
>>
>> %states = ( "California","Sacramento", "Wisconsin","Madison", "New York",
>> "Albany");
>>
>> print "Capital of Californi
On Mon, 2007-10-29 at 17:06 +0530, Kaushal Shriyan wrote:
>
>
> #!/usr/bin/perl -w
>
> %states = ( "California","Sacramento", "Wisconsin","Madison", "New York",
> "Albany");
>
> print "Capital of California is " . $states{"California"} .
Hi,
I have a sample code
#!/usr/bin/perl -w
%states = ( "California","Sacramento", "Wisconsin","Madison", "New York",
"Albany");
print "Capital of California is " . $states{"California"} . "\n\n";
###
16 matches
Mail list logo