Match Operator Example With Assignments

Match Operator Example With Assignments

open (INFILTER, "ls -lg | tail +2 |") ||

die "couldn't run ls ";

die "will not overwrite $outfilename" if -e logfile;

open(OUTPUT,">logfile") || die "cannot create logfile";

while (){

($perms, $linkcnt, $user, $group, $file) =

/(^[d-][rwx-]{9})\s*(\d+)\s*(\w+)\s*(\w+).*\d+\s([A-Za-z0-9._]+)$/;

printf OUTPUT "%s:\n\t%s\t%s\t%s\n\n", $file, $user, $group, $perms;

}

Previous slide Next slide Back to the first slide View Graphic Version