space in variable referencing
- From: ciwei2103@xxxxxxxxx (ciwei)
- Date: Fri, 11 Jan 2008 15:03:06 -0800 (PST)
Question from a newbie: how to properly use space
when reference to variables, array, hash etc.
please see the code below:
why the first line, second, and third line all output differiently.
thanks.
ciwei
========code below ======
#!/usr/bin/perl
my %ttys =();
open ( WHO, "who|") or die "can;t \n";
while ( <WHO> ){
( $user, $tty ) = split ;
push @{$ttys{ $user}} , $tty;
}
foreach $user ( sort keys %ttys ){
print "first line : $user => @{$ttys {$user}} \n";
print "second line: $user => @ {$ttys { $user}} \n";
print "third line: $user => @{$ttys{$user}} \n";
}
__OUTPUT__
first line : root =>
second line: root => @ { { root}}
third line: root => pts/1 pts/4 pts/6 pts/7 pts/8
.
- Follow-Ups:
- Re: space in variable referencing
- From: John W. Krahn
- Re: space in variable referencing
- From: "Tom Phoenix"
- Re: space in variable referencing
- Prev by Date: Re: Why doesn't this work: trinary operator?
- Next by Date: Re: Why doesn't this work: trinary operator?
- Previous by thread: Why doesn't this work: trinary operator?
- Next by thread: Re: space in variable referencing
- Index(es):
Relevant Pages
|