isnt something like:
$data eq "8000" or $data eq "0080" the same as: $data eq "8000" || $data eq "0080";

A little experimentation should reveal that Perl thinks it is:

c:\@Work\Perl>perl -wMstrict -MO=Deparse,-p -le "my $data = '8000'; ;; if ($data eq '8000' or $data eq '0080') { print 'yes 1'; }; if ($data eq '8000' || $data eq '0080') { print 'yes 2'; }; " BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } use strict 'refs'; (my $data = '8000'); if ((($data eq '8000') or ($data eq '0080'))) { print('yes 1'); } if ((($data eq '8000') or ($data eq '0080'))) { print('yes 2'); } -e syntax OK

... i have ... tried ... swapping the 8A-8F/A0 with eq to no avail.

Again with the experimentation:

c:\@Work\Perl>perl -wMstrict -le "my $data = '8000'; ;; if ($data eq '8000' or $data eq '0080') { print 'yes 1'; }; if ($data eq '8000' || $data eq '0080') { print 'yes 2'; }; " yes 1 yes 2
I don't know what code you tried when you used  eq (the proper comparator for strings), but clearly it should work. At the same time, I would also agree with other respondents that a re-organization of the code to avoid an eye- and mind-bezoggling onslaught of if-statements would be very valuable just for the great increase in readability and maintainability I would expect it to yield.

i thought i read somewhere that its was better to use "||" instead of "or" and use "&&" instead of "and".

The problem with  and and  or is that these logical operators have such low precedence: their precedence is lower than  , (comma), i.e., lower than whale dung. This was done so that a statement like
    open my $fh, '<', $filename or die "opening '$filename': $!";
would work as expected. Unfortunately, such low precedence has some surprising side-effects, hence  && and  || are recommended for 'normal' usage, a recommendation I would endorse since I've stumbled over these odd side-effects myself.
Update: Here's an example of a precedence-induced difference between  ! and  not. This code produces warnings, but you may not be so lucky.

c:\@Work\Perl>perl -wMstrict -MData::Dump -le "my ($x, $y) = (4, 5); ;; my @ra = (1, 2, ! 3, $x, $y); dd \@ra; ;; my @rb = (1, 2, not 3, $x, $y); dd \@rb; ;; print qq{but \$x and \$y are still $x and $y}; " Useless use of a constant (3) in void context at -e line 1. Useless use of private variable in void context at -e line 1. [1, 2, "", 4, 5] [1, 2, ""] but $x and $y are still 4 and 5


In reply to Re^3: perl unpack and matching the unpacked data by AnomalousMonk
in thread perl unpack and matching the unpacked data by james28909

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.