Can I use a regex to enter an if statement in perl? -
what's going on i'm parsing /etc/passwd file pull out usernames , first/last name of each person in file. can utilize regex in if statement? here's illustration of line i'm trying match:
$parameter = cvwalters:*:14608:140608:chris v. walters,n/a,n/a,n/a:/home/cvwalters:/bin/bash if ($parameter =~ /(.+):(.+):(.+):(.+):(.+),(.+),(.+),(.+):(.+):(.+)/){ $uid =$1; $fname = $5 =~ /^\w+/; $lname = $5 =~ /\w+$/; force (@results, $uid, $fname, $lname); }
does perl homecoming true boolean there if statement , allow rest execute? if not, how can create happen?
yes, in boolean context, match operator boolean operator.
but please take advice of @squiguy, utilize split.
there passwd module on cpan.
http://search.cpan.org/dist/unix-configfile/passwdfile.pm
regex perl
No comments:
Post a Comment