[Chicago-talk] Not enough format arguments

tiger peng tigerpeng2001 at yahoo.com
Mon May 10 12:35:05 PDT 2010

Sorry, I  did not make the question clear. To make the question clearer, I simplifye it as below.

#for a list of list
@lol = (["a"], ["b", 1], ["c", 1,2], ['d', 1, 2, 3]);
#I expet the output to be displaied like:
#b          1
#c          1
#           2
#d          1
#           2
#           3
foreach (@lol) {
  @ll = @$_;
  write FMFILE;
#format used:
format FMFIEL = 
@<          @>>
shift(@ll), shift(@ll) if @ll,
            @>> ~~
            shift(@ll) if @ll,

The question is when there is only one element in the sub-list, it will complain for the first and second line of the format has not enough argument. I cheat it with:

push @ll, '' if @==1;

There is no complain for the first line noe, but it cannot make the second line quiet if there is only two elements, while empty line is not wanted in  the output.
As the @lol is very long, it makes a lot of noise; I do not like to turn off the warning, as it may cover other real issue.

From: "Andy_Bach at wiwb.uscourts.gov" <Andy_Bach at wiwb.uscourts.gov>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Mon, May 10, 2010 11:34:14 AM
Subject: Re: [Chicago-talk] Not enough format arguments

Not sure what exactly would be best (splice and numbers seems odd) but:

splice(@{$printArray[$ii]}, 0, 4) if @{$printArray[$ii]}

You could use the "pitchfork" ? : operator

@{$printArray[$ii]} ? splice(@{$printArray[$ii]}, 0, 4) : 0

That is, a default of zero if the array is empty.


Andy Bach
Systems Mangler
Internet: andy_bach at wiwb.uscourts.gov
Voice: (608) 261-5738;
Cell: (608) 658-1890

Ducharme's Axiom:
If you view your problem closely enough you
will recognize yourself as part of the problem.

Chicago-talk mailing list
Chicago-talk at pm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20100510/dc5c4a1a/attachment.html>

More information about the Chicago-talk mailing list