# this program reads through a file # line by line and prints "PRINTING" # for every line between $START & $STOP # i'm intersted in improving my function &flip(\$flop) $START = 'START'; $STOP = 'STOP'; $flop = 0; while(<>) { my @record = split /,/; chomp($record[0]); if (($flop) && ($record[0] ne $STOP)){ print "PRINTING"; } else { print "not printing"; } if (($record[0] eq $START) || ($record[0] eq $STOP)) { &flip(\$flop); } } sub flip {$ref = @_[0]; $$ref = !($$ref)}
as you can see, the function &flip(\$flop)
is doing alright and working ... there's 
absolutly no reason to improve it... 

in fact, if i just wrote 
$flop = !($flop)
i wouldn't need a function at all 
(i also wouldn't get to have the word 
'flipflop' actually working in my code
  ... i think on some level it's like the 
 poetry to me)

for some reason i'd really like to optimize 
the function a step further to only ONE 
statement
 
i tried 
sub flip { $@_[0] = !($@_[0] };
figuring that it would be like saying:
"de-reference the variable in position
 zero of the 'magic' array and toggle it"

unfortunately it's more like saying: 
"don't compile"

why is that?

In reply to something about improving code... by Buckaroo Buddha

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.