On Wed, Sep 04, 2013 at 02:31:30AM +0100, Rob Dixon wrote: > Matt <matt.mailingli...@gmail.com> wrote: > >I have this: > > > >while (<IN>) { > > chomp; > > next if /^#/; > > # do stuff > > } > > > > > >It skips to the next item in the while loop of the string begins with > ># and works fine. I would also like to skip to the next item in the > >loop if the string contains anything other then lowercase, > >underscores, numbers, dashes, periods, and spaces. I do not want > >uppercase characters and any sort of other special characters. How > >would I do that? > > The solution from John Krahn is superior by far, and there is no need for any > other suggestions.
John's solution: next if /[^[:lower:]_\d\-. ]/; Doesn't work in this test environment: michael@bivy:~$ cat tpl && ./tpl #!/usr/bin/perl use strict; use warnings; print "\nJohn's solution\n"; while(<DATA>) { print "Seen line: $_"; next if /[^[:lower:]_\d\-. ]/; print; } __DATA__ a good line Testing John code a #!! should not print line _ Should be OK line finish with a printing line John's solution Seen line: a good line Seen line: Testing John code Seen line: a #!! should not print line Seen line: _ Should be OK line Seen line: finish with a printing line -- Michael Rasmussen, Portland Oregon Be Appropriate && Follow Your Curiosity Other Adventures: http://www.jamhome.us/ or http://gplus.to/MichaelRpdx A special random fortune cookie fortune: When you don't know what to do, do the work in front of you. ~ Calvin Coolidge -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/