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
|
|---|