Perl: pattern matching in a conditional

In this snippet of code:
printf("<email preferred=\"true\">\n") if ( $Campi[0] ne "");

Open in new window

I should add another condition:
if $Campi[0]  does not begin with ">>"
I've tried something like
printf("<email preferred=\"true\">\n") if (( $Campi[0] ne "") OR ( $Campi[0] !~ m/^>>/=true));

Open in new window

but without luck
fabiano petroneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:

Shouldn't OR be AND?
printf("<email preferred=\"true\">\n") if (( $Campi[0] ne "") and ( $Campi[0] !~ m/^>>/));

Open in new window

fabiano petroneAuthor Commented:
Hi, Norie
no: I want to override the print of
<email preferred=\"true\">\n

Open in new window

in both cases:
  • a) if $Campi[0] is null
  • b) if $Campi[0] begins with ">>"
NorieAnalyst Assistant Commented:
Try using lower case || or lower case or.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

fabiano petroneAuthor Commented:
printf("<email preferred=\"true\">\n") if (( $Campi[0] ne "") or ( $Campi[0] !~ m/^>>/=true));

Open in new window

but I obtain the following error:

Can't modify not in scalar assignment at line 114, near "true)"
Execution of aborted due to compilation errors.

Open in new window

NorieAnalyst Assistant Commented:

Sorry, my fault.

You also need to remove '=true'.

printf("<email preferred=\"true\">\n") if (( $Campi[0] ne "") or ( $Campi[0] !~ m/^>>/));

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fabiano petroneAuthor Commented:
all OK: thanks :=)
Hi Norie,

> "Try using lower case || or lower case or."
What does "lower case ||" mean?  I didn't know "||" had case.
NorieAnalyst Assistant Commented:
Oops, didn't notice the typo.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PERL Regular Expressions (regex)

From novice to tech pro — start learning today.