begin quoting Paul G. Allen as of Sun, Nov 20, 2005 at 12:33:08AM -0800: > It's been 4 years since I've written in Perl. I'm having a bit of > trouble with pattern matching. > > I have a set of strings that are parsed from a file created by > extracting data from a database. Because some of the fields in the data > are empty and some are not, some strings are empty, some not. I want the > code to process all strings that aren't empty. All strings are NULL > terminated. > > So far I've managed to have the code either ignore all strings, or none > of them. > > What's the correct pattern match for an empty string (the string is > stored in a scalar)?
/^$/ The ^ anchors the pattern to the start of the string, and the $ anchors the pattern to the end. You can also use ? to indicate "zero or one" if you're trying to match substrings. -Stewart "Not a perl hacker, but like using perl for text processing" Stremler -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
