On 2/18/09 Wed Feb 18, 2009 10:20 AM, "Rob Canning" <r...@goto10.org> scribbled:
> John W. Krahn said : >> Rob Canning wrote: >>> hi i have a sprintf which uses a scalar as its format: >>> my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$s16 >>> %8\$s16" [...] >>> any ideas what i am doing wrong? >> >> Strings like '%1\$s16->' are not valid sprintf/printf formats. What >> does your data look like and what do you expect it to look like after >> using sprintf? >> > > hi, > > i have put the code here http://pastebin.com/m5d4debbb > you will see a my $formatA that works fine > and a my @App gives the error There is no $formatA in your program. You define $Aformat in lines 62-125, but do not use it anywhere in your program. Compare lines 226 and 240: 226 InsertPitches( 15, @App, @Aflatperm ), 240 InsertPitches(15, $Bformat, @Bflatperm ), and the first few lines of InsertPitches: sub InsertPitches { my ($num, $form, @notes) = @_; ... } When InsertPitches is called from line 226, the first element of @App will be copied to $form, and the rest of @App will be copied to @notes. The contents of @Aflatperm will be concatenated to the end of @notes. Is this what you want? Did you mean to call InsertPitches with $Aformat instead of @App in line 226? HTH. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/