Dave's Brain

Browse - Programming Tips - Is there a shorthand for a non-match?

Date: 2014jul8
Language: Perl

Q.  Is there a shorthand for a non-match?

A.  Yes, use !~

Ugly way:

if (!($filename =~ m/\.ini$/)) { print "non an ini file\n"; }
More compact way:
if ($filename !~ m/\.ini$/) { print "non an ini file\n"; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.