develooper Front page | perl.beginners | Postings from February 2009

Invalid conversion in sprintf "%\"

Thread Next
Rob Canning
February 18, 2009 09:31
Invalid conversion in sprintf "%\"
Message ID:
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"

what i would like to do is generate a new format for the sprintf by doing 
permutations of 5 arrays like this:

my @phraseA = qw( %1\$s16-> %2\$s16-> %3\$s16-> ); 
my @phraseB = qw( %4\$s16 %5\$s16 %6\$s16-> );
my @phraseC = qw( %7\$s16 %8\$s16 %9\$s16 );
my @phraseD = qw( %10\$s16-> %11\$s16 %12\$s16 ); 
my @phraseE = qw( %13\$s16 %14\$s16 %15\$s16-> ); 

my @phrasegroup = ([@phraseA], [@phraseB], [@phraseC], [@phraseD], [@phraseE]);
my @phraseperm  = map {@$_} permute(@phrasegroup);

#flatten permutation array
my @Bformat = map { @$_ } @phraseperm;

but when i do this i get :

Invalid conversion in sprintf: "%\" at line 53.

so i thought maybe i needed to turn the array into a scalar:

#my $test = join(" ",@Bformat);

but that gave the same error

any ideas what i am doing wrong?



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About