How can I make @<<<<<<<<< variable ? 
Author Message
 How can I make @<<<<<<<<< variable ?

Hi,

I have a form which uses something like this;

the thing is some of the above vars can vary according to the
input. I can use printf but the above line is in the middle of
a big form, so I wonder if there is any way to tell the format
to adjust the length of each variable.

Something like this?


or even

with which you can tell the form you want the string length
variable in such scope(s).

I also appreciate if you can tell me any alternatives for this
kind of formatting.

Thanks,

Jong.
____________________________________________________________________
Try Perl5 !! (it is more productive than C, C++.) (yet fast enough.)

Quote:
>      Are you a Biologist?  Programming? Then, try Perl !



>Jong, Tim Hubbard's Student, http://www.*-*-*.com/



Tue, 03 Mar 1998 03:00:00 GMT  
 How can I make @<<<<<<<<< variable ?

Quote:

>Hi,

>I have a form which uses something like this;


>the thing is some of the above vars can vary according to the
>input. I can use printf but the above line is in the middle of
>a big form, so I wonder if there is any way to tell the format
>to adjust the length of each variable.

>Something like this?


>or even


>with which you can tell the form you want the string length
>variable in such scope(s).

>I also appreciate if you can tell me any alternatives for this
>kind of formatting.

My understanding is that formats get built at compile time, but you could
build one at run time with an eval as follows:

8x------snip------x8

$width_of_variable = 10; # or whatever

$dynamic_format = <<END_DYNAMIC_FORMAT;
format STDOUT =
$actual_format
\$variable
.
END_DYNAMIC_FORMAT

eval $dynamic_format;

$variable = 'Hi Jong';
write;

8x------snip------x8

There are several examples in the Dromedary book.  Check the one on page 325.

 >Jong.

Hope this helps,
Jim Shapiro



Tue, 03 Mar 1998 03:00:00 GMT  
 How can I make @<<<<<<<<< variable ?

Jong> Hi,

Jong> I have a form which uses something like this;


Jong> the thing is some of the above vars can vary according to the
Jong> input. I can use printf but the above line is in the middle of
Jong> a big form, so I wonder if there is any way to tell the format
Jong> to adjust the length of each variable.

Just use the universal escape:

        format BIG_LONG_FORM =
        blah blah
        blah blah
        blah blah

        sprintf("%10.10s %5.5s %.20s %10s %10s",$one,$two,$three,$four,$five)
        blah blah
        blah blah
        blah blah
        .

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me



Tue, 03 Mar 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ^<<<<<<<<<<<~~ with \n

2. ^<<<<<<<<<<< ~~ format question

3. How can grep the 8th of Field <<<<<<<<

4. Question on Cutting and Paste things in a File <<<<<<<<

5. Using $: and ^<<<<~~~ in formatting

6. <<<<<< HELP >>>>>>>>

7. format @<<<

8. 4.036 Bug using $: and ^<<<~~ fields

9. >>>> A Singaporean Girl looking for more penpals!!<<<<<

10. print <<END (with variables)

11. receiving variable from web page with <cgiscript>?<var>=x

12. >>>Please add your Perl Script to the Perlcoders Archive of free scripts <<<<

 

 
Powered by phpBB® Forum Software