in reply to RE: Things are not what they seem like.
in thread Things are not what they seem like.
Let's first clean it up (which takes all the fun out of it, but still...):
Looks more understandable, now, right?$; = $"; $;{Just=>another=>Perl=>Hacker=>} = $/; print %;
The first line sets the value of the special variable $; to the value of $". $" is the list separator and has the default value of a space. $; is the subscript separator, which is used (or used to be used) for multidimensional array emulation. As explained in perlvar. So saying
really means$foo{$a, $b, $c}
Since we've set $; equal to the value of $", the subscript separator is now a space (' ').$foo{ join $;, $a, $b, $c }
Next line, then:
Let's fix it up a bit:$;{Just=>another=>Perl=>Hacker=>} = $/;
That actually isn't legal, though, because the special => makes it okay to use the barewords. If we replace them with commas, we'll get errors. And that's why we need the => after "Hacker"; if we take it off, we get an error.$;{Just,another,Perl,Hacker,} = $/;
Anway, though, now it makes more sense, doesn't it? Because it looks like the example above, the example from perlvar. We're just assigning to a hash element in the hash %;.
And $/ is the input record separator, the default of which is a carriage return ("\n"). So we assign that value to the hash element, so what we really have is something like this:
Which is just this:$;{ join ' ', "Just", "another", "Perl", "Hacker", "" } = "\n";
And then we're at the last line:$;{"Just another Perl Hacker"} = "\n";
Which is very simple. We're just printing out the hash %;, which we just assigned to. In list context, the hash is flattened to a list. This list, in fact:print %;
And what happens when we print out that list? Just what you'd expect:("Just another Perl Hacker", "\n")
So that's it. Doesn't it make you love Perl? :)Server Error (Error ID 5303814c2134618)Just another Perl Hacker
An error has occurred. The site administrators have been notified of the problem and will likely soon fix it. We thank you, for you're patients.
Replies are listed 'Best First'. | |
---|---|
RE: RE: RE: Things are not what they seem like.
by halxd2 (Monk) on Jul 26, 2000 at 15:37 UTC | |
Re^3: Things are not what they seem like.
by gvenkat (Novice) on Mar 30, 2009 at 13:40 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |