Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Using grep in a scalar context

by choroba (Abbot)
on Feb 06, 2013 at 12:52 UTC ( #1017414=note: print w/ replies, xml ) Need Help??


in reply to Using grep in a scalar context

Works for me:

perl -E '@dipept = qw/XX AA BB CC DDAAD AAAAAAA/; $FMat[0][0] = grep(/ +AA/, @dipept); say $FMat[0][0]' 3
The documentation of grep clearly states:
In scalar context, returns the number of times the expression was true.
What input do you have? What output do you expect?
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Using grep in a scalar context
Download Code
Re^2: Using grep in a scalar context
by newbie1991 (Acolyte) on Feb 06, 2013 at 13:37 UTC
    My input is a string of amino acid bases, essentially it looks like MHDLKNDHASDRWT and I am counting pair occurrences throughout. MH HD DL LK KN ND are all accepted and should be counted.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-08-01 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls