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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.