in reply to New to perl and regex
Neatened up your regular expressions a bit:
print "Enter a string (enter quit or [CTRL]-D to quit): "; while(<>) { $line = $_; last if ($_ =~ /^\s*quit\s*$/i); next if ($_ =~ /^\s~*$/); if($line =~ /\s*[a-zA-Z\s]+\s*-?\d+\s*/) { print $_; } }
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: New to perl and regex
by rovf (Priest) on Nov 19, 2012 at 09:18 UTC |
In Section
Seekers of Perl Wisdom