Geez, ok, round #n

The use of comma in your print statement works exactly the same.
Consider:

#!/usr/bin/perl use strict; use warnings; my $i = 3; # $i is not modified in this print statement: print sqrt($i), $i, $i**2; # 1.7320508075688839 ## 1.73205080756888 3 9 # $i is modified and new value of $i is used: print sqrt($i), --$i, $i**2; # 1.7320508075688824 ## 1.73205080756888 2 4
I like the comma statement when it simplifies a loop, an example is a loop that prompts for an input:
#!/usr/bin/perl use strict; use warnings; my $line; while ( (print "Prompt: "), $line=<STDIN>, $line !~ /^\s*Q(uit)\s*$/i +) { $line =~ s/^\s*//; $line =~ s/\s*$//; print"xyzzy \"$line\" and nothing happens\n"; } print "Some version of QUIT, QuIt, quit entered\n"; __END__ C:\Projects_Perl\testing>perl simplecommandline.pl Prompt: 123 xyzzy "123" and nothing happens Prompt: abc xyzzy "abc" and nothing happens Prompt: 123 abc xyzzy "123 abc" and nothing happens Prompt: qui xyzzy "qui" and nothing happens Prompt: quit doing that! xyzzy "quit doing that!" and nothing happens Prompt: QUiT Some version of QUIT, QuIt, quit entered
Without the use of the comma statement in the while() statement, there has to be a "prompt" printed before the loop starts and a "prompt" must also be printed within the loop to "keep the loop going". The comma statement allows: a)ask for input, b)get input, c)test input all in one syntactically correct single statement. The "truthfulness" of a comma statement only rests upon the very last clause. This comma statement idea should be used sparingly. Very sparingly. I think we agree upon that.

In reply to Re^8: writing two files (different in length) to one output by Marshall
in thread writing two files (different in length) to one output by ic23oluk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.