thanks Jim for taking the time to look at my code - i figured out what was
going on
its seems that using the qw() structure to define my arrays caused the \ signs
to be passed on - once i rewrote the array definitions using " ", quoting like
this everything worked as i wanted:
my @phraseA = ("%1\$s16-> ", "%2\$s16-> ", "%3\$s16-> ");
i also had to convert the array to a scalar for the InsertPitches subroutine
to work correctly with the sprintf.
thanks again to John and Jim for your hints,
rob
this now works for me
my @phraseA = ("%1\$s16-> ", "%2\$s16-> ", "%3\$s16-> ");
my @phraseB = ("%4\$s16 ", "%5\$s16 ", "%6\$s16-> " );
my @phraseC = ("%7\$s16 ", "%8\$s16 ", "%9\$s16 ");
my @phraseD = ("%10\$s16-> ", "%11\$s16 ", "%12\$s16");
my @phraseE = ("%13\$s16 ", "%14\$s16 ", "%15\$s16->");
my @phrasegroup = ([ @phraseA ], [ @phraseB ], [ @phraseC ], [ @phraseD ], [
@phraseE ]);
my @phraseperm = map {...@$_} permute(@phrasegroup);
#flatten permutation array
my @App = map {...@$_, " "} @phraseperm;
my $App = join(" ",@App);
Jim Gibson said :
> On 2/18/09 Wed Feb 18, 2009 10:20 AM, "Rob Canning" <[email protected]>
> 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: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
>
--------------
[email protected]
rob.goto10.org
--------------
signature.asc
Description: Digital signature
