[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Passing arguments to "sprintf"...



On Wed, Feb 09, 2005 at 01:27:45PM -0600, Daniel Linder (dan@linder.org) wrote:
>     # This section prints "2" for the
>     my $myline = sprintf (@LogString);

sprintf's prototype is ($;@), meaning it demands the first parm be a
scalar.  Because it wants a scalar first, it coerces @LogString into a
scalar, in this case "2" since that's the number of elements in
@LogString;

Do it as:

my $mask = shift @LogString;
my $line = sprintf( $mask, @LogString );

xoxo,
Andy

-- 
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance