Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Is there a way to compare strings without using an array? (say)

by jeffa (Bishop)
on Oct 18, 2011 at 21:44 UTC ( #932248=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Is there a way to compare strings without using an array? (say)
in thread Is there a way to compare strings without using an array?

The reason is because say is not (yet) a built-in function. You have to import the function into your namespace first, hence use feature 'say';

Alternatively, you can just use print, which does not implicitly add the new line for you like say does.

print "$_\n" for $line1 =~ /[$line2]/g;
You can also add the -l (dash elle) modifier to your "shebang" line which essentially makes print behave like say:
#!/path/to/perl -l ... print for $line1 =~ /[$line2]/g;
Hope this helps!

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re^5: Is there a way to compare strings without using an array? (say)
Select or Download Code
Replies are listed 'Best First'.
Re^6: Is there a way to compare strings without using an array? (say)
by ikegami (Pope) on Oct 18, 2011 at 22:45 UTC

    say is a builtin function since 5.010. feature has never exported say. feature tells the parser that say should use the builtin say instead of the sub say.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932248]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2015-07-31 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (280 votes), past polls