On Jun 4, 8:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> April wrote:
> > sprintf( "%s%$Fmt%s", ("%$Fmt=|", $TestStr, "|"))
>
> > This is in Perl for Dummies, 4th ed, p160.
>
> > I'm trying to understand this ...
>
> > the first part, "%s%$Fmt%s", my understanding is the format part,
> > which specifies the formats for the second part, thelist part, ("%
> > $Fmt=|", $TestStr, "|"): %s for "%$Fmt=|", %$Fmt for $TestStr, and %s
> > for "|", respectively.  Is this correct?
>
> > Then what is %$Fmt, it seems a % for format and then a variable $Fmt,
> > the book did not mention any format string like this ...
>
> > Anyone can shed some light?  Thanks!
>
> Hi April
>
> The value of $Fmt will be interpolated into the double-quoted sting before it 
> is
> used as a format. It needs to be one of the single-character format 
> conversion.
> If you're not clear what I mean then try running this piece of code.
>
> for my $Fmt ('s', 'd') {
>   print "%s%$Fmt%s", "\n";
>
> }
>
> HTH,
>
> Rob- Hide quoted text -
>
> - Show quoted text -

I understand now Rob, thanks!


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to