or, || not working with next LABEL

U

usaims

Newbie question.
My "or" "||" is not working in my little script, it works if I don't
add an 'or' statement.
Any clue, thanks.
#########################
NOT WORKING
#########################
#!/usr/bin/perl -w
use strict;
use vars qw(@mylist);

CAPTURE:
while ( my $current_line = <DATA> ) {
next CAPTURE if ($current_line !~ m/SOAP <(\S+)>/) || ($current_line !
~ m/GET \/Accurin\/(\S+),/);

push(@mylist,"$1\n");
}
print @mylist;


__DATA__
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
SOAP <PersonSearch> from (e-mail address removed)"
SOAP <IDRequest> from (e-mail address removed)"
SOAP <WirelessSearch> from (e-mail address removed)"

###########################
WORKING
###########################
#!/usr/bin/perl -w
use strict;
use vars qw(@mylist);

CAPTURE:
while ( my $current_line = <DATA> ) {
next CAPTURE if $current_line !~ m/SOAP <(\S+)>/;
push(@mylist,"$1\n");
}
print @mylist;

__DATA__
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
GET /Accurin/HealthCareProviderSearch, from (e-mail address removed)"
SOAP <PersonSearch> from (e-mail address removed)"
SOAP <IDRequest> from (e-mail address removed)"
SOAP <WirelessSearch> from (e-mail address removed)"
 
M

Martijn Lievaart

Newbie question.
My "or" "||" is not working in my little script, it works if I don't
add an 'or' statement.
Any clue, thanks.

Well it does precisely what you tell it to do.

(a !~ re) || (b !~ re) is equivelent to
not ((a =~ re) and (b =~ re))

Does that make it clearer? You need and and there, not an or.

HTH,
M4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top