Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Binary to decimal conversion

by andreas1234567 (Vicar)
on Dec 11, 2007 at 10:34 UTC ( #656370=note: print w/ replies, xml ) Need Help??


in reply to Re: Binary to decimal conversion
in thread Binary to decimal conversion

Hmm.. I'm surprised to see it works to reverse a scalar like that. read's 2nd argument is a SCALAR, and reverse's single argument is a LIST. What is it I do not understand?

--
Andreas


Comment on Re^2: Binary to decimal conversion
Re^3: Binary to decimal conversion
by pfaut (Priest) on Dec 11, 2007 at 11:48 UTC

    From reverse

    reverse LIST
          In list context, returns a list value consisting of the ele-
          ments of LIST in the opposite order.  In scalar context, con-
          catenates the elements of LIST and returns a string value with
          all characters in the opposite order.
    
    90% of every Perl application is already written.
    dragonchild
      In list context:
      my @array = reverse( LIST );
      In scalar context:
      my $value = reverse( LIST );
      Fine. But it does not say how it's supposed to behave when fed a SCALAR instead of a LIST, does it?

      I'm still confused.

      --
      Andreas

        Erm . . . a LIST may consist of a single scalar value. That single scalar value is concatenated with all the other elements in the LIST (very quickly, obviously, since they're non-existent) and the bytes in that concatenated string (i.e. the single scalar argument) are returned in reverse order, just like the docs say.

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://656370]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2015-07-06 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls