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

help neeed in unpack

by uva (Sexton)
on Feb 10, 2006 at 07:39 UTC ( [id://529295]=perlquestion: print w/replies, xml ) Need Help??

uva has asked for the wisdom of the Perl Monks concerning the following question:

$line="123 456 789"; @w=unpack('A3A3A3A3',$line); print "@w";
its is giving output as 123 45 6 7.actually..unpack('A8',"hello   ");# produces "hello" right why it is not working for the prevoius one.

Replies are listed 'Best First'.
Re: help neeed in unpack
by Corion (Patriarch) on Feb 10, 2006 at 07:43 UTC

    unpack counts spaces as characters of their own. You might want the following unpack template:

    $line="123 456 789"; @w=unpack('A3xA3xA3',$line); print "@w";

    Or maybe you just want split:

    my @w = split /\s/, $line;
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found