On Tue, Jun 19, 2001 at 11:35:08PM +, Robin Gerard wrote:
> On Mon, Jun 18, 2001 at 12:56:11PM -0500, will trillich wrote:
> > try
> >
> > perldoc -f each
> > perldoc -f keys
>
> ok it's just what I need.
>
> > the camel book and the llama book are both wonderful resources
> > (for
On Mon, Jun 18, 2001 at 12:56:11PM -0500, will trillich wrote:
> On Mon, Jun 18, 2001 at 01:24:28AM +, Robin Gerard wrote:
> > this script runs fine:
> >
> try
>
> perldoc -f each
> perldoc -f keys
ok it's just what I need.
> the camel book and the llama book are both won
On Mon, Jun 18, 2001 at 01:24:28AM +, Robin Gerard wrote:
> this script runs fine:
>
> #!/usr/local/bin/perl
>
> print "\n\n";
> %loginpsswd=("gerard","12345678","jaimie","78945612","andy","45632178");
for clarity, you should usually write hash-list expressions
with the => operator:
Robin Gerard <[EMAIL PROTECTED]> writes:
> %loginpsswd=("gerard","12345678","jaimie","78945612","andy","45632178");
> print $loginpsswd{"gerard"};
> print $loginpsswd{"$loginpasswd[2*$i]"};
A hash variable is not the same symbol as an array variable.
%loginpasswd is a hash variable
@logi
> $i=0;
> while ($i<3)
> {
> print $loginpsswd{"$loginpasswd[2*$i]"};
> print "\n\n";
> }
> I get error ...
>
> can someone whose knows perl explain me how to write
> this loop correctly.
An easy way is this:
foreach $k (keys %loginpsswd) {
print $loginpsswd{$k}."\n\n";
}
--
Jonathan
5 matches
Mail list logo