Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^3: comments and qw

by rnahi (Curate)
on Feb 12, 2006 at 20:32 UTC ( #529685=note: print w/replies, xml ) Need Help??

in reply to Re^2: comments and qw
in thread comments and qw

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' ];

Replies are listed 'Best First'.
Re^4: comments and qw
by ikegami (Pope) on Feb 13, 2006 at 03:08 UTC
    ah yes, I forgot.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://529685]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-06-25 05:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.