Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: scoping problem?

by Corion (Pope)
on Dec 06, 2011 at 17:27 UTC ( #942066=note: print w/replies, xml ) Need Help??

in reply to scoping problem?

Are you sure you're modifying / running the same Perl script? Because for me, the following works:

use strict; my $username; my $color; while(<DATA>){ chomp; s/"//g; ($username,$color) = (split /,/,$_)[2,3]; if ("agag" =~ m/($username)/){ print STDOUT "here is the username: $username\n" } } __DATA__ "ADELMAN","John","adad","Ray" "AGAN","John","agag","Aditya" "AHMED","John","ahah","Conor"

... and outputs:

here is the username: agag

Replies are listed 'Best First'.
Re^2: scoping problem?
by ww (Bishop) on Dec 06, 2011 at 19:55 UTC
    And are you sure you're getting the contents of the text file to <>? Bad path to text file? Wrong name of text file? Failure to test open ($FH, "<  $text_file") or die "Can't open $text_file, $! ? or something similar?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942066]
[Corion]: Discipulus: Windows isn't that complicated, at least if you look at it from the perspective of getting input via wndproc and answering to each message ;)
[Corion]: Of course, what you get put into your wndproc needs a lot of documentation ;))

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-01-17 10:01 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (154 votes). Check out past polls.