Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > pack V length changes

Reply
Thread Tools

pack V length changes

 
 
Shaun Jackman
Guest
Posts: n/a
 
      08-12-2003
Running the following little bit
$header = pack "V12 v6 V6 v8", @fields;
print length $header;
prints
100

However, the following
$header = pack "V12 v6 V6 v8", @fields;
print $header;
then (where foo is the above script)
./foo | wc -c
prints
107

Where did the extra 7 characters come from? I'm very confused. Why does the
length of the $header report 100, but 107 characters get printed? Do I have
to set STDOUT to a binary stream somehow?

Please cc me in your reply,
Thanks,
Shaun

 
Reply With Quote
 
 
 
 
Bob Walton
Guest
Posts: n/a
 
      08-12-2003
Shaun Jackman wrote:

> Running the following little bit
> $header = pack "V12 v6 V6 v8", @fields;
> print length $header;
> prints
> 100
>
> However, the following
> $header = pack "V12 v6 V6 v8", @fields;
> print $header;
> then (where foo is the above script)
> ./foo | wc -c
> prints
> 107
>
> Where did the extra 7 characters come from? I'm very confused. Why does the
> length of the $header report 100, but 107 characters get printed? Do I have
> to set STDOUT to a binary stream somehow?



Yes.

perldoc -f binmode


....
> Shaun


--
Bob Walton

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When Is A Visaster Service Pack Not A Service Pack? Lawrence D'Oliveiro NZ Computing 5 06-26-2008 09:11 PM
Buy 1 pack or 3 pack? (XP Pro x64) Rich Olver Windows 64bit 11 11-25-2006 11:33 PM
Excellent discount software packs - ImTOO Ripper Pack Platinum and ImTOO Ripper Pack Gold zhangelf01@gmail.com DVD Video 6 09-17-2006 03:27 AM
Pack parent control in child using control.pack(in_= syntax? Tim Jones Python 0 01-31-2004 10:22 PM
Poor Mans NIMH Battery Pack and SLA Battery Pack ajacobs2 Digital Photography 0 08-19-2003 12:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57