in reply to my script is not giving the result using last function

Please consider using a regular expression to perform the validation as it is much simpler to code and faster to execute:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump); say (/\Aa*\Z/ ? "$_ is all a's" : "$_ is not all a's") for qw(aaaa aaa +ab aaac cccccbbb cccca);

Produces:

aaaa is all a's
aaaab is not all a's
aaac is not all a's
cccccbbb is not all a's
cccca is not all a's

Replies are listed 'Best First'.
Re^2: my script is not giving the result using last function
by Anonymous Monk on Aug 28, 2012 at 12:59 UTC

    Please consider using a regular expression to perform the validation as it is much simpler to code and faster to execute:

    The point of assignment was probably to learn about substr/index/rindex