I have problem with regular expression on this line:
if ( $systypeopt !~ /[adri]{0,1}/ )
I want valid input like a or a d or a d i or d r i, etc
each option should be appear once in input
if any of the option are out of these four also should be failed and then redo.
Thanks!
#!/usr/bin/perl
%SELOPT_HASH = ( a => "APP", d => "DBS", r => "RDBX", i => "IDBX" );
print "\n";
print "[a] APP\n";
print "[d] DBS\n";
print "[r] RDBX\n";
print " IDBX\n";
print "\n";
{
print "Select System Type: ";
chomp ($systypeopt = <STDIN>);
if ( $systypeopt !~ /[adri]{0,1}/ ) {
print "\t===>Msg: Wrong option in [$systypeopt]. Please try again\n";
redo;
}
}
@systypevalues = split(' ', $systypeopt);
@newsystypevalues="";
foreach my $val (@systypevalues) {
push( @newsystypevalues,$SELOPT_HASH{$val} );
}
print "\t@newsystypevalues\n";
if ( $systypeopt !~ /[adri]{0,1}/ )
I want valid input like a or a d or a d i or d r i, etc
each option should be appear once in input
if any of the option are out of these four also should be failed and then redo.
Thanks!
#!/usr/bin/perl
%SELOPT_HASH = ( a => "APP", d => "DBS", r => "RDBX", i => "IDBX" );
print "\n";
print "[a] APP\n";
print "[d] DBS\n";
print "[r] RDBX\n";
print " IDBX\n";
print "\n";
{
print "Select System Type: ";
chomp ($systypeopt = <STDIN>);
if ( $systypeopt !~ /[adri]{0,1}/ ) {
print "\t===>Msg: Wrong option in [$systypeopt]. Please try again\n";
redo;
}
}
@systypevalues = split(' ', $systypeopt);
@newsystypevalues="";
foreach my $val (@systypevalues) {
push( @newsystypevalues,$SELOPT_HASH{$val} );
}
print "\t@newsystypevalues\n";