Gasp has asked for the wisdom of the Perl Monks concerning the following question:

Is there some way using "format" that I can get a single character followed by a * with no spaces in between? This is the code I have now followed by the results.
format LEVELS= USGS @<<<<<<<<<<<<<< R=234* T=A* 235#@<<<<<<<* 709#@<<<* 234=L* $file2{$grid}, $date, $time, $level USGS @<<<<<<<<<<<<<< 239=@* $file2{$grid}, $method .
USGS 312232084391701 R=234* T=A* 235#20000601* 709#1200* 234=L*
USGS 312232084391701 239=S@*

What I want is the "239=S@*" to read "239=S*"

The character that goes into $method will always be a letter if that helps any. I'd appreciate any help with this.

Replies are listed 'Best First'.
Re: Help using FORMAT
by merlyn (Sage) on Mar 08, 2001 at 20:52 UTC
    formats are pretty primitive. You'd be better off your spending time learning about printf than to learn about format workarounds like the kludge I'm about to show you:
    USGS @<<<<<<<<<<<<<< 239=@@ $file2{$grid}, $method, '@'
    Yeah, ugly, and that's the only way to do that one. The "escape" mechanism is to provide constant text in the value list. Bleh.

    I'll repeat this again strongly:

    • learn to use printf for anything that isn't immediately obvious with formats—do not waste your time trying to learn format workarounds.

    -- Randal L. Schwartz, Perl hacker

Re: Help using FORMAT
by Albannach (Monsignor) on Mar 08, 2001 at 20:51 UTC
    How about appending the asterisk to the variable before it's printed:
    format LEVELS= USGS @<<<<<<<<<<<<<< R=234* T=A* 235#@<<<<<<<* 709#@<<<* 234=L* $file2{$grid}, $date, $time, $level USGS @<<<<<<<<<<<<<< 239=@* $file2{$grid}, $method.'*' .

    --
    I'd like to be able to assign to an luser