It might be useful to skip blank lines (or lines that just contain comments) like the real qw():That won't be necessary. split with a single space is a special case that splits on any number of whitespace, including newlines.
Try it for yourself:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; sub qwx { my ( $text ) = @_; $text =~ s/\s*[#].*$//mg; return split ' ', $text; } my @items = qwx" this is # possibly a # commented list # with stand-alone comments # and empty lines " ; print Dumper \@items; __END__ $VAR1 = [ 'this', 'is', 'a', 'list' ];
In reply to Re^3: comments and qw
by rnahi
in thread comments and qw
by Tanktalus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |