Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 17:20:43 -0800
Local: Tues, Nov 22 2005 8:20 pm
Subject: Text spacers - What do you use?
I'm generating an HTML report page using Perl. I'm reticent to use a table
for formatting the page. What do most folks use for text spacers? As I see it, I can use a javascript loop to generate a passed value of Or, should I generate the space within Perl? -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: Mark Parnell <webmas...@clarkecomputers.com.au>
Date: Wed, 23 Nov 2005 12:26:23 +1100
Local: Tues, Nov 22 2005 8:26 pm
Subject: Re: Text spacers - What do you use?
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 01:37:08 GMT
Local: Tues, Nov 22 2005 8:37 pm
Subject: Re: Text spacers - What do you use?
Ed Jay <ed...@aes-intl.com> wrote: &nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; > I'm generating an HTML report page using Perl. I'm reticent to use a > table for formatting the page. What do most folks use for text > spacers? &nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; &nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; &nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; > As I see it, I can use a javascript loop to generate a passed value of print "<br>\n" for 1 .. 100000; # outer space > spaces ( ) or I can use a blank, one-pixel tall gif and pass the > width parameter to a javascript. (All my users will have js enabled.) > Or, should I generate the space within Perl? Ok, the real answer: if you want to use tables, you could set a margin on -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 17:55:17 -0800
Local: Tues, Nov 22 2005 8:55 pm
Subject: Re: Text spacers - What do you use?
John Bokma <j...@castleamber.com> wrote: I'm going blind reading my Perl scripts as it is. The above will serve >Ed Jay <ed...@aes-intl.com> wrote: >> I'm generating an HTML report page using Perl. I'm reticent to use a >&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; only to further my blindness. :-) >> As I see it, I can use a javascript loop to generate a passed value of >> Or, should I generate the space within Perl? >print "<br>\n" for 1 .. 100000; # outer space But, this is what I'm think of. For example, call a function along the where spaceFunction() is a js scripted loop that generates n spaces and in >Ok, the real answer: if you want to use tables, you could set a margin on layout. Mark Parnell <webmas...@clarkecomputers.com.au> wrote: I wouldn't call it tabular data. >Why? Is it not tabular data? <pre> may be an option. It's hard to say >from the information given. Name Date City State Zip etc. >Ultimately, format it the same way you would if you were writing the blank images in the raw Perl script. -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 02:14:38 GMT
Local: Tues, Nov 22 2005 9:14 pm
Subject: Re: Text spacers - What do you use?
Then you forgot the most important rule: be lazy. In Perl you could
write the above as: print ( ( ' ' x 12, "\n" ) x 4 ); > The above will serve So... get lazy :-D > only to further my blindness. :-) >>print "<br>\n" for 1 .. 100000; # outer space Don't > I'd replace <br> with . :-) > But, this is what I'm think of. For example, call a function along the > where spaceFunction() is a js scripted loop that generates n spaces Don't. Just set a margin on your table. > and in my example, it would print 35 spaces between text and more > text. >>Ok, the real answer: if you want to use tables, you could set a margin So, there you go >>on the table element over which you have quite some control. > Tables are no problem, except I've adopted the discipline of using CSS Please don't reply to 2 people in one reply. -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 18:21:51 -0800
Local: Tues, Nov 22 2005 9:21 pm
Subject: Re: Text spacers - What do you use?
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: mbstevens <NOXwebmast...@xmbstevensx.com>
Date: Wed, 23 Nov 2005 03:23:58 GMT
Local: Tues, Nov 22 2005 10:23 pm
Subject: Re: Text spacers - What do you use?
Ed Jay wrote: Ooook. Please tell me you forgot your smiley. > John Bokma <j...@castleamber.com> wrote: >>Ed Jay <ed...@aes-intl.com> wrote: >>>I'm generating an HTML report page using Perl. I'm reticent to use a >>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; You can style generated pages with CSS the same as regular pages. > I'm going blind reading my Perl scripts as it is. The above will serve bad style. Give yourself a break. As you write, think kind thoughts of you future self. >>>As I see it, I can use a javascript loop to generate a passed value of >>>spaces ( ) or I can use a blank, one-pixel tall gif and pass the That gets very tiresome and hard to read. Here, have a look: >>>width parameter to a javascript. (All my users will have js enabled.) >>>Or, should I generate the space within Perl? >>print "<br>\n" for 1 .. 100000; # outer space http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi > I'd replace <br> with . :-) > But, this is what I'm think of. For example, call a function along the > where spaceFunction() is a js scripted loop that generates n spaces and in Whether it's tabular or not, style it with CSS. You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 03:54:14 GMT
Local: Tues, Nov 22 2005 10:54 pm
Subject: Re: Text spacers - What do you use?
Yeah, I did (although I use in a very few locations indeed )
>>>print "<br>\n" for 1 .. 100000; # outer space Why? > That gets very tiresome and hard to read. Done, I hope you be prepared :-D. sub dofile - pick a good sub routine name open(XIN, "$ff") || err('open', $ff ); has a few: - you should localize XIN, or better, see below to summarize: open my $fh, $filename (I recommend using CGI::Carp 'fatalsToBrowser' instead of home brew err If you're paranoid, you could add \n after $!. make_substitutions @dat; - probably smarter to pass around a as print "@dat\n"; - "@dat" does join ' ' => @dat, I doubt you really want that foreach my $s (@_) { $s =~ s/TEMPLATE_REPLACE_FNAME/$nm/eg; has a few to: - by dropping the $s (or pick a good name), you can actually make for ( @_ ) { s/TEMPLATE_REPLACE_FNAME/$nm/g; } which has some another thing: it uses globals (yikes). by a lottle [1] rewriting, you might get: sub use_template_file { my ( $filename, $variables ) = @_; open my $fh, $filename s{TEMPLATE_REPLACE_(\w+)}{ defined $variables->{ lc $1 } print; close $fh } use_template_file( 'helloworld.tmp', { title => 'Hello, world!', (untested, assumes a Content-type header has already been printed). [snip noise] [1] not a little -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: mbstevens <NOXwebmast...@xmbstevensx.com>
Date: Wed, 23 Nov 2005 05:03:54 GMT
Local: Wed, Nov 23 2005 12:03 am
Subject: Re: Text spacers - What do you use?
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 06:55:39 GMT
Local: Wed, Nov 23 2005 1:55 am
Subject: Re: Text spacers - What do you use?
mbstevens <NOXwebmast...@xmbstevensx.com> wrote: How many people do read the mark up? > John Bokma wrote: >>>>>print "<br>\n" for 1 .. 100000; # outer space >>>That gets very tiresome and hard to read. >> Why? > Not tiresome to read in Perl, but tiresome to read in >>>Here, have a look: XIN? no, it's not local :-) >>>http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi >> Done, I hope you be prepared :-D. >> sub dofile - pick a good sub routine name > You do realize this is a local in an eight line function? >> open(XIN, "$ff") || err('open', $ff ); it has nothing to do with strict. >> has a few: >> - you should localize XIN, or better, see below > The program uses strict and doesn't complain. > $ff, the string that no, it's a lexical scoped variable (IIRC there is a difference :-) > opens the file, is localized. > XIN is a file handle. It's documented in perldoc -f open > The way you've done it in your version below is not a practice I've > often seen. > People reading code expect to see file handles in all note that there is a difference between XIN and my $fh. > caps. > Your version using Because it's new to you? > "open my $fh, $filename" > ...is not as readable. > I can just glance at a function with file in that case you could use $file_handle, or even $FILE_HANDLE, although > handles in all caps and say "hey, the programmer is playing with files > here." the latter is confusing, since to me that looks like a scalar holding a constant. > I see no reason to torture myself over the niceties of Since I read the snippet as an example, I recommend to show good > localization and globalization in such a short program. programming practices in an example. I read, reread and rerereread my Perl code examples many times before I put them on my site :-) > If I ever open(XIN, "$ff") > roll the two tiny functions into an object, It'll get taken care of. >> - you *shouldn't* put quotes around "" ^^^^ Somehow I forgot to make clear around what :-) > I can't seem to find what you're talking about. I recommend to not add it to the error function, since it's value might >> - you *should* use the value of $! in your error report (how > That's reasonable. I might add that to the error function. not always be as expected, better to pass it to the error function, or better use die with CGI::Carp 'fatalsToBrowser'; >> make_substitutions @dat; - probably smarter to pass around a better since the whole array is copied into memory. When passing around >> as >> ref > Why better? Works fine as it is. arrays, especially when they can be large, it's better to use a reference. >> print "@dat\n"; Uhm, how does an \n at the end of the file make the markup more >> - "@dat" does join ' ' => @dat, I doubt you really want that > Insurance against no newline at the end of the file, so that the readable? However, the other question is more important, you add extra spaces <pre><code>print becomes <pre><code>print which renders as print >> foreach my $s (@_) { If so, then so is $_, which is implicit, and hence you can drop it :-D >> $s =~ s/TEMPLATE_REPLACE_FNAME/$nm/eg; >> has a few to: >> - by dropping the $s (or pick a good name), you can actually > I think $s for string is quite good enough for a 6 line function. >> for ( @_ ) { To me, no. Since this is cleary a snippet that is going to be part of >> s/TEMPLATE_REPLACE_FNAME/$nm/g; >> which has some another thing: it uses globals (yikes). > This is a situation where globals are perfectly OK. another (CGI) program. > It could easily Because it's not a program. It's a piece of code you suggest someone can > be rolled into an object, but for such a short program, why bother? add to a program. > It's easier for the visitor to modify functions to suit their needs No, it has nothing to do with OO programming, nor encapsulation. I > when they're this small. Perl doesn't _force_ you to write very short > programs as objects. I really think that with your love of > encapsulation you would be much more happy with Python. I like > Python, too, but this ain't Python. recommend not to use globals in general. >> by a lottle [1] rewriting, you might get: Uhm, die is an error function, overloaded by CGI::Carp. And you can use >> sub use_template_file { >> my ( $filename, $variables ) = @_; >> open my $fh, $filename > I really prefer my own error function to this kind of thing. It can it in other places in your program. Moreover, die is what a lot of programmers recognize and understand. err has to be looked up... [ .. ] > I think my way of breaking this into two functions instead of one long Note that my function is just 7 lines. I use a lot of white space. Also > function is much more readable. note that my function works as easy with 1 variable as with 1000. make_substitutions needs an additional line for each substitution. -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
| Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy |
| ©2013 Google |