bv has asked for the wisdom of the Perl Monks concerning the following question:
So this one bit me today, and I'm wondering if it's documented anywhere or if I just am missing something in my implementation. I have a sub that sorts some lines based on the IP address at the beginning of the line:
my $fp = \&by_ip; print $fp->(@input); sub by_ip { return map { unpack('x4A*') } sort map { pack('A4A*',inet_aton((split /\s/,$_,2)[0]),$_) } @_; }
The output is printed all on one line, which I do not want. I am sure that every line in the input ends with "\n", since this sub is swappable (via assignment to $fp) with several others that do not exhibit this behavior. The only unique thing about this sub is that it uses pack. Does anyone have a clue as to what is going on here? Many thanks.
| print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972))) |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pack auto-chomps/chops?
by ikegami (Patriarch) on Oct 07, 2009 at 18:49 UTC | |
by bv (Friar) on Oct 07, 2009 at 19:14 UTC | |
by ikegami (Patriarch) on Oct 07, 2009 at 19:18 UTC | |
by bv (Friar) on Oct 07, 2009 at 20:04 UTC |