in reply to Trimming unpack'ed strings
Maybe something like that?
$_ = "foo bar baz "; my $catdesc = " extra "; print join(",", ("", map /^\s*(.*\S)/, unpack("a10 a10 a10", $_), $cat +desc)[0,0,-1,0,0,3,0,0,1,2,0] ); # output: ",,extra,,,baz,,,foo,bar,"
(I simplified the format, because you didn't provide sample input, and I was too lazy to create a matching string)
That said, writing unnecessarily compact code usually isn't the best idea...
Update: added $catdesc to show that extra variables could in principle also be handled.
|
|---|