Reputation: 313
How can I find out the number of disks in this string?
$str='disk 0_1 0_2 0_3';
In this $str
, the number of disks is 3.
How can Perl output how many disks there are in this string?
Thank you!
Upvotes: 0
Views: 132
Reputation: 26940
my @result = $str=~ m/\d_\d/g;
print "Number of disks found : ", scalar(@result), "\n";
Upvotes: 1