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 directly define reference variables like this? On Thu, Nov 12, 2009 at 4:06 PM, John W. Krahn <jwkr...@shaw.ca> wrote: > 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 > changing the value of $count in the loop so that probably won't work very > well. You should just assign to the hash: > > my $abc; > my %hash = ( $abc => [ grep defined, @ARGV ] ); > > Or just: > > my $abc; > my %hash = ( $abc => [ @ARGV ] ); > > > > > > John > -- > The programmer is fighting against the two most > destructive forces in the universe: entropy and > human stupidity. -- Damian Conway > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >