Hello Ekanvitha9 and welcome to the Monastery
The x modifier can help make matches readable in code. With this modifier any whitespace is not compiled into the pattern, unless escaped using the \s class.
#!/usr/bin/perl -T; use strict; use warnings; my $password = 'a!1"a$234]5%}&<AcdEf^&B*#$")'; $password =~ /\A # start of string ( # start capture [ # start character class A-Z a-z _ # alpha letters (\w) 0-9 # numbers (\d) > & { } < \$ [ # specials \] ! " % ) ^ * # ] # end character class {28} # match exactly 28 characters ) # end capture \z # end of string /x; # match flags $password = $1 or die send_log('password_reset'); print "$password\n"; sub send_log{ my $log_type = shift; $log_type =~ s/\A([A-Za-z][A-Za-z0-9_]{7,20})\z/$1/ or die; if($log_type eq 'password_reset'){ print "The first part of a new password has been sent to\n", "your inbox. Call facilities on the internal line\n", "to recieve the next part. You will also recieve\n", "instructions for locating the pigeon wearing the\n", "last part.\n"; # exit( release_pigeon( ++$pc ) ); } exit; }
Hope this helps. To go back and see your earlier posts, with lots of good advice about this kind of thing, just click on the write ups number on your home node.
In reply to Re: validations in perl
by Don Coyote
in thread validations in perl
by Ekanvitha9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |