Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with my program (2 short lines!!) ?

Status
Not open for further replies.

moroshko

Programmer
May 24, 2008
14
IL
Hello experts !

When I run the program below I get the following:

print (...) interpreted as function at C:\perlscripts\hello.pl line 6.

1

Why is this warning appears and what is the meaning of it ?

Thanks !

#!/usr/bin/perl
use warnings;
use strict;

my $s = 'func(a,b)';
print ($s =~ m{\Qfunc(});

 
Hi Kevin,

Thank you for the advice !
From now I will not use () in print.

But still, I want to understand why the warning appears.
I saw the link above but still don't understand.

All I'm trying to check is if "func(" can be found in $s.

I have noticed that if remove ( after "func" (even with () around all), the warning goes away:

print ($s =~ m{\Qfunc});

Why ???
Please explain.
 
Hi,

Wouldn't this do what you want?

if ($s =~ m|\Qfunc(|) { print "it exists"; }

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top