Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, here's how it works.

Let's first clean it up (which takes all the fun out of it, but still...):

$; = $"; $;{Just=>another=>Perl=>Hacker=>} = $/; print %;
Looks more understandable, now, right?

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

$foo{$a, $b, $c}
really means
$foo{ join $;, $a, $b, $c }
Since we've set $; equal to the value of $", the subscript separator is now a space (' ').

Next line, then:

$;{Just=>another=>Perl=>Hacker=>} = $/;
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.

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:

$;{ join ' ', "Just", "another", "Perl", "Hacker", "" } = "\n";
Which is just this:
$;{"Just another Perl Hacker"} = "\n";
And then we're at the last line:
print %;
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:
("Just another Perl Hacker", "\n")
And what happens when we print out that list? Just what you'd expect:
Just another Perl Hacker
So that's it. Doesn't it make you love Perl? :)

In reply to RE: RE: Things are not what they seem like. by btrott
in thread Things are not what they seem like. by Abigail

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found