Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

why doesn't this flip-flop work?

by johnnywang (Priest)
on Jan 27, 2006 at 19:38 UTC ( #526064=perlquestion: print w/replies, xml ) Need Help??
johnnywang has asked for the wisdom of the Perl Monks concerning the following question:

I happen to need the flip-flop after reading Flipin good, or a total flop?. The following behavior puzzles me, why does the first version print "after"? Thanks.
my @data = <DATA>; print "Using lexical varible:\n"; foreach my $line (@data){ if($line =~ /begin/../end/){ print $line; } } print "\nNot using lexical varible:\n"; foreach (@data){ if(/begin/../end/){ print; } } __DATA__ before begin 1 2 3 end after __RESULT__ Using lexical varible: begin 1 2 3 end after Not using lexical varible: begin 1 2 3 end

Replies are listed 'Best First'.
Re: why doesn't this flip-flop work?
by japhy (Canon) on Jan 27, 2006 at 19:42 UTC
    Your first code is ($line =~ /abc/) .. /xyz/. You mean to write ($line =~ /abc/) .. ($line =~ /xyz/). Case closed.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
Re: why doesn't this flip-flop work?
by Roy Johnson (Monsignor) on Jan 27, 2006 at 19:42 UTC
    use warnings; will give you a clue.

    How do you think your first conditional parses?

    Caution: Contents may have been coded under pressure.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://526064]
Approved by kutsu
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-03-30 07:56 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (355 votes). Check out past polls.