regex - Can't figure out the format this file is expecting to read -
i've got block of perl supposed read static file irc hostmask, privilege level , comment. between perl (which i'm certified novice in) , regex i'm having trouble creating file.
sub read_users { @users = (); open config, "<", "users"; while (my $line = <config>) { next if $line =~ /^\s*#/; ($mask, $level, $comment) = split /\s+/, $line, 3; push @users, [$mask, $level]; } close config; }
the file reads:
<config> irc.hostmask.goes.here 500 comment
that isn't working. see mentions word users , regex omits whitespace. i've grumbled on enough , tried various formulations no luck. ideas?
each line of file must either:
- a comment (which ignored), consisting of optional whitespace,
#
, , arbitrary text - a "mask", "level", , "comment", separated whitespace, no leading whitespace before mask. mask , level cannot contain whitespace, though comment can.
<config>
not valid line; expression my $line = <config>
merely reads 1 line config
filehandle , stores in $line
, , while
causes repeat until <config>
returns false value (usually undef
@ end-of-file).
Comments
Post a Comment