or, || not working with next LABEL

Discussion in 'Perl Misc' started by usaims, Aug 9, 2007.

  1. usaims

    usaims Guest

    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 "
    GET /Accurin/HealthCareProviderSearch, from "
    GET /Accurin/HealthCareProviderSearch, from "
    GET /Accurin/HealthCareProviderSearch, from "
    SOAP <PersonSearch> from "
    SOAP <IDRequest> from "
    SOAP <WirelessSearch> from "

    ###########################
    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 "
    GET /Accurin/HealthCareProviderSearch, from "
    GET /Accurin/HealthCareProviderSearch, from "
    GET /Accurin/HealthCareProviderSearch, from "
    SOAP <PersonSearch> from "
    SOAP <IDRequest> from "
    SOAP <WirelessSearch> from "
    usaims, Aug 9, 2007
    #1
    1. Advertising

  2. On Thu, 09 Aug 2007 15:38:31 -0700, usaims wrote:

    > 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
    Martijn Lievaart, Aug 10, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deniz Bahar
    Replies:
    2
    Views:
    443
    Andrey Tarasevich
    Mar 9, 2005
  2. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Reading of file by next of map file and by next of file descriptor.

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 10, 2007, in forum: C++
    Replies:
    1
    Views:
    768
    Alf P. Steinbach
    Jul 10, 2007
  3. Tad McClellan
    Replies:
    3
    Views:
    126
    Edward Wijaya
    May 13, 2004
  4. Liora
    Replies:
    5
    Views:
    600
    Tad McClellan
    Jan 12, 2007
  5. Knut Krueger
    Replies:
    8
    Views:
    236
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page