From: bagman on 13 Nov 2009 21:21 On Fri, 13 Nov 2009 18:00:32 -0800, Jim Gibson <jimsgibson(a)gmail.com> wrote: >In article <aj1sf59htl6b9tnv5opvoqo5c03jkg51uc(a)4ax.com>, bagman ><elopppoer(a)yughi.net> wrote: > >> I'm not that familiar with Perl but am trying to enter a couple of >> <br> into a perl script. It needs to go where this appears. >> >> if ($arg eq 'only') { >> print <<END; >> >> I want to enter a couple of line breaks before the routine ends. >> I've tried to enter it after the { using <br><br> and "<br><br>"; >> I've tried to use it using print "<br><br>"; with no luck. >> >> I've tried to enter it after the print command in various ways with no >> luck. Can someone tell me the correct syntax to enter a couple of line >> breaks in the above code? Thanks. > >The '<<END;' is a "here" document that generates a string starting with >the next line and continuing until an 'END' token appearing by itself >at the beginning of a line. It would have helped if you had shown us >the entire string or, better still, a complete program demonstrating >the problem. > >You should be able to add anything to be printed verbatim anywhere >between the 'print <<END'; line and the terminating 'END' line: > > if ($arg eq 'only') { > print <<END; ><br><br> >...whatever else needs to be printed... >END > > } Thanks, sresovoir, but the --- print "\n\n"; --- didn't work.It didn't generate an error though as all my other attempts have done. Jim, I need the line breaks in the' if' section. Because if that argument is not true it falls through to another section before the END command. I only want the line breaks if the 'if' argument is true. Here's the rest of the code. Thanks for the reply. if ($arg eq 'only') { print <<END; <br><div align="center"><a class="white" href="javascript:history.back()"> Return to Vote</a></div> END } print table_bottom(); exit; }
From: J�rgen Exner on 13 Nov 2009 21:31 bagman <elopppoer(a)yughi.net> wrote: >I'm not that familiar with Perl but am trying to enter a couple of ><br> into a perl script. It needs to go where this appears. You can't. Or rather it has no meaning to perl. <br> is an HTML element and as far as Perl is concerned it is just good old plain boring text. > if ($arg eq 'only') { > print <<END; The <<END is just a special way to quote some text. >I want to enter a couple of line breaks before the routine ends. >I've tried to enter it after the { using <br><br> and "<br><br>"; That hopefully gave you some syntax errors. As I mentioned, it is just plain text and not valid Perl code. >I've tried to use it using print "<br><br>"; with no luck. That should have worked. >I've tried to enter it after the print command in various ways with no >luck. Depening upon what you mean by "after the print command" that should have worked, too. The string ends with the corresponding END. Anything between those two tags is part of the string and should have been printed to whereever print() is set to print to. >Can someone tell me the correct syntax to enter a couple of line >breaks in the above code? Just two ways: if (1) { print "This prints <BR>\n"; print <<END; As does this <BR> END } Output: C:\Users\jue\tmp>t.pl This prints <BR> As does this <BR> jue
From: J�rgen Exner on 13 Nov 2009 21:41 sreservoir <sreservoir(a)gmail.com> wrote: >bagman wrote: >> I've tried to enter it after the print command in various ways with no >> luck. Can someone tell me the correct syntax to enter a couple of line >> breaks in the above code? Thanks. > >print "\n\n"; > >perhaps? Neat! Or maybe just open the source in your favourite editor and hitting the <ENTER> key a couple times. Really highlights how not being aware of the different levels causes confusion. My suggestion above adds line breaks in the Perl source code, but otherwise has (usually) no effect. Your suggestion adds line breaks in the Perl output which probably also happens to be the HTML source for some browser somewhere but will not have any other effect.. What he is looking for however is probably to modify the generated HTML code to so that it will produce some line break when viewed in a browser, i.e. one more level of redirection. jue
From: J�rgen Exner on 13 Nov 2009 21:48 bagman <elopppoer(a)yughi.net> wrote: >On Fri, 13 Nov 2009 18:00:32 -0800, Jim Gibson <jimsgibson(a)gmail.com> >wrote: > >>In article <aj1sf59htl6b9tnv5opvoqo5c03jkg51uc(a)4ax.com>, bagman >><elopppoer(a)yughi.net> wrote: >> >>> I'm not that familiar with Perl but am trying to enter a couple of >>> <br> into a perl script. It needs to go where this appears. >>> >>> if ($arg eq 'only') { >>> print <<END; >>> >>> I want to enter a couple of line breaks before the routine ends. >>> I've tried to enter it after the { using <br><br> and "<br><br>"; >>> I've tried to use it using print "<br><br>"; with no luck. >>> >>> I've tried to enter it after the print command in various ways with no >>> luck. Can someone tell me the correct syntax to enter a couple of line >>> breaks in the above code? Thanks. >> >>The '<<END;' is a "here" document that generates a string starting with >>the next line and continuing until an 'END' token appearing by itself >>at the beginning of a line. It would have helped if you had shown us >>the entire string or, better still, a complete program demonstrating >>the problem. >> >>You should be able to add anything to be printed verbatim anywhere >>between the 'print <<END'; line and the terminating 'END' line: >> >> if ($arg eq 'only') { >> print <<END; >><br><br> >>...whatever else needs to be printed... >>END >> >> } > >Thanks, sresovoir, but the --- print "\n\n"; --- didn't work.It didn't >generate an error though as all my other attempts have done. ??? There is no mentioning of print "\n\n"; anywhere in the text you quoted above. In any case, that does produce 2 line breaks in the generated Perl output. Did you check it? >Jim, I need the line breaks in the' if' section. Because if that >argument is not true it falls through to another section before the >END command. There is no END command! The <<END and END tokens are just enclosing a here document. Think of them as fancy quote characters. >I only want the line breaks if the 'if' argument is true. >Here's the rest of the code. Thanks for the reply. > > if ($arg eq 'only') { > print <<END; > ><br><div align="center"><a class="white" You already got one <br> there. What is stopping you from adding two more? >href="javascript:history.back()"> >Return to Vote</a></div> > > >END > } > print table_bottom(); > exit; >} >
From: bagman on 13 Nov 2009 22:04 On Fri, 13 Nov 2009 18:48:13 -0800, J�rgen Exner <jurgenex(a)hotmail.com> wrote: >>I only want the line breaks if the 'if' argument is true. >>Here's the rest of the code. Thanks for the reply. >> >> if ($arg eq 'only') { >> print <<END; >> >><br><div align="center"><a class="white" > >You already got one <br> there. What is stopping you from adding two >more? > >>href="javascript:history.back()"> >>Return to Vote</a></div> >> >> >>END >> } >> print table_bottom(); >> exit; >>} >> Jurgen, adding a line break there doesn't work because I'm working in a limited space. If I add the <br> there it pushes 'Return to vote' down and out of sight in the iframe it is in. The 'if arg' is the place to put it because at that point (if true) it doesn't fall through to the next line of code, it just ends the routine there and I have my 2 line breaks. If it falls through the 2 line breaks aren't added and the 'Return to vote' is OK (or that's the way I'm reading the code). Nothing is working so I need to recheck and make sure I'm at the correct location in the code. Thanks to all that replied and for all your help. I may be back.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Please help with processing flat file Next: FAQ 1.14 What is a JAPH? |