Gossamer Forum
Home : General : Perl Programming :

wc -w (In Perl Script -Really simple)

Quote Reply
wc -w (In Perl Script -Really simple)
I would really appreciate it if anyone could tell me how to count the number of words in a string. I can do it in unix via

wc -w file.text

but I can't do it on a $string in a perl script. I've been trying to find out how for the past 3 days. I'd be so grateful if anyone could help.

Thank you for listening.

Quote Reply
Re: wc -w (In Perl Script -Really simple) In reply to
if $_ has your string

$numberOfWords = scalar(split);

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: wc -w (In Perl Script -Really simple) In reply to
Thank you so much. You are my eternal God and King. I have been trying to do this for ages. I worship at your alter.

Thank you.