
miller
User
Jun 15, 2011, 10:37 AM
Post #4 of 7
(516 views)
|
|
Re: [tuxtutorials] Why this wont work
[In reply to]
|
Can't Post
|
|
Thanks Miller for response however, I don't think that was the issue. I am thinking it is something with the @email addresses I have in the file. I replaced the samples in your code with: #!/usr/bin/perl my @users = ("foo@mail.com","bar@mail.com","baz@mail.com"); my @gms = ("notFoo@mail.com","bar@mail.com","notBaz@mail.com"); foreach $user (@users) { if ($user ~~ @gms) { print "$user matched\n"; } else { print "$user not matched\n"; } } No, you simply introduced a NEW problem by not using single quoted strings in your fake data. Either use qw() like I originally demonstrated:
my @users = qw(foo@mail.com bar@mail.com baz@mail.com); my @gms = qw(notFoo@mail.com bar@mail.com notBaz@mail.com); Or use single quoted strings
my @users = ('foo@mail.com','bar@mail.com','baz@mail.com'); my @gms = ('notFoo@mail.com','bar@mail.com','notBaz@mail.com'); Or just escape the @ in the double quoted string so it isn't interpolated as an array:
my @users = ("foo\@mail.com","bar\@mail.com","baz\@mail.com"); my @gms = ("notFoo\@mail.com","bar\@mail.com","notBaz\@mail.com"); Whatever you choose, this won't be an issue when you're pulling raw data from a file. - Miller
|