in reply to Regular Exp. in foreach loop Help!
foreach my $checked (@chk_acc) { chomp();
chomp() is short for chomp( $_ ) but you don't assign any value to $_ so the use of chomp there is superfluous.
if($checked=~/^(\w{3})(\d{4,7})/ig) { # it should print the accounts starting with letters here
The \w character class matches all upper case letters and all lower case letters and all digits and the '_' character so the use of the /i option is superfluous and the comment is wrong because \w will also match digits and '_'. The regular expression is anchored at the beginning of the string in $checked so it will only match once so the use of the /g is also superfluous. You are also capturing two strings which you aren't using so the capturing parentheses are also superfluous. So, to sum up, you probably want something like:
if ( $checked =~ /^[[:alpha:]]{3}\d{4,7}/ ) { # it should print the accounts starting with letters here
|
|---|