Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: not able to get the output using split function

by philiprbrenan (Monk)
on Sep 01, 2012 at 21:35 UTC ( #991196=note: print w/ replies, xml ) Need Help??


in reply to not able to get the output using split function

Your code is fine, but $sentence has no value.

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); my $sentence = 'aaaa bbb ccc'; my @words = split(/\s+/, $sentence); my $i; for($i=0;$i<scalar (@words);$i++) { print "$i: " . $words[$i] . "\n"; }

Produces

0: aaaa 1: bbb 2: ccc


Comment on Re: not able to get the output using split function
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-11-28 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (197 votes), past polls