#! /usr/bin/perl use warnings; use strict; my @currentMappings = (); my @newMappings = (); print "Protections:\n"; while (<>) { # trim leading and trailing whitespace chomp; s/^\s+//; s/\s+$//; # skip blank lines and comments next if ($_ eq ""); next if (/^#/); if (/^-?\/\//) { # lines that start with -// or // are mappings push(@newMappings, $_); } else { # handle the mappings changing if (@newMappings) { @currentMappings = @newMappings; @newMappings = (); } # parse the user line my ($permission, $userOrGroup, $name) = split; # output a protection line for each mapping foreach my $mapping (@currentMappings) { print "\t", $permission, " ", $userOrGroup, " ", $name, " * ", $mapping, "\n"; } } }