Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Corrupt Data?

by ikegami (Patriarch)
on Jul 14, 2008 at 22:50 UTC ( [id://697593]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Corrupt Data?
in thread Corrupt Data?

The first argument of map is code executed for every other argument of map.

print map uc($_), qw( a b c d ); # Prints ABCD print map { uc($_) } qw( a b c d ); # Same thing

unpack '(A4)*', $val splits the value into as many 4 byte blocks as possible. I would have used "W" instead of "A", though. unpack '(W4)*', $val splits the value into as many 4 character blocks as possible.

@_ is not unamed —its name is @_— and nothing is being stored in it —its contents are being passed to map.

@_ holds the arguments of the current function (convert).

Replies are listed 'Best First'.
Re^4: Corrupt Data?
by almut (Canon) on Jul 14, 2008 at 23:27 UTC
    I would have used "W" instead of "A"

    The reason I used "A" is because it works in older Perls, too, like 5.8.8.  "W" is available in 5.10 only.

      Then I wouldn't have used unpack. /(.{1,4})/sg would do the trick too.
      The point is moot (between "A" and "W") because splickles stated that the input consists of hexadecimal MAC addresses, that would be matched by either one of them.
      []s, HTH, Massa
Re^4: Corrupt Data?
by BrowserUk (Patriarch) on Jul 15, 2008 at 02:02 UTC
      pack (from v5.10.0):
      W An unsigned char value (can be greater than 255).

        Ah yes, Thanks. From the proposed use above, '(W4)*' as an alternative for '(A4)*', I was expecting it to be grouped with a,A & Z, or with U, and just looked right past it.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (1)
As of 2024-04-24 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found