Very nice to know about CPAN.
got a syntax error though with your script
syntax error at ./getACLinfo.pl line 51, near "say join"
Execution of ./getACLinfo.pl aborted due to compilation errors.
[code]
#!/usr/bin/perl
use strict;
use SVN::Access;
my $acl = SVN::Access->new( acl_file => 'data' );
# Walk through the resources in the ACL file:
for my $repopath ($acl->resources) {
# For this resource, find out what authorisations exist:
for my $auth ($repopath->authorized) {
# $repopath->authorized gives us hashrefs of group => perms
# TODO: I don't know if it might also give individual users, if
# had per-user grants.
my ($group, $perms) = each %$auth;
if ($group =~ s/^@//) {
# For each group, list out the members, along with the repo
# permissions
for my $user ($acl->group($group)->members) {
say join '~', $user, $repopath->name, $group, $perms;
}
} else {
die "Can't handle individual user permissions!";
}
}
}
[/code]
On Jul 3, 2012, at 11:25 AM, David Precious wrote:
> On Tue, 3 Jul 2012 09:47:00 -0400
> Phil Pinkerton <[email protected]> wrote:
>
>> I was given a project that seems to require Perl
>>
>> I could use a sample just to extract a list of names associated with
>> a group or repo and print them.
>>
>> 1) Assigned a task to extract data fron a text file.
>> 2) Output file needs to be very specific, and created monthly
>> 3) tried doing in korn shell too complex
>> 4) Figured Perl my best option, but don't know Perl
>> 5) Got the Modern Perl in PDF format
>> 6) Installed Strawberry Perl
>>
>> Output format is simple ??, but extracting the data and printing it
>> I haven't a clue where to start. ( I am not trying to get someone to
>> write this for me, just a simple extract and print example and point
>> me in the right direction )
>
> First pointer - a lot of things you want to do in Perl will be a lot
> easier if you consult CPAN to see if someone has done this before and
> shared reusable code which will make your life easier.
>
> In this case, you've not described what the input data is, but to me it
> looks very much like a Subversion access control file. So, with that
> in mind, I searched CPAN, and found SVN::Access:
>
> https://metacpan.org/module/SVN::Access
>
> Ahah - looks like it takes all the hard work out of things for you -
> it'll take care of the parsing, and let you just get at the data.
>
> So, glancing at its docs and whipping something up:
>
> [code]
> #!/usr/bin/perl
>
> use strict;
> use SVN::Access;
> my $acl = SVN::Access->new( acl_file => 'data' );
>
> # Walk through the resources in the ACL file:
> for my $repopath ($acl->resources) {
> # For this resource, find out what authorisations exist:
> for my $auth ($repopath->authorized) {
>
> # $repopath->authorized gives us hashrefs of group => perms
> # TODO: I don't know if it might also give individual users, if
> # had per-user grants.
> my ($group, $perms) = each %$auth;
>
> if ($group =~ s/^@//) {
> # For each group, list out the members, along with the repo
> # permissions
>
> for my $user ($acl->group($group)->members) {
> say join '~', $user, $repopath->name, $group, $perms;
> }
> } else {
> die "Can't handle individual user permissions!";
> }
> }
> }
> [/code]
>
> If you install SVN::Access, the above should work for you, and should
> produce mostly what you need, e.g.:
>
> ritched2~repo1:/~repo1_devs~r
> appalas~repo1:/~repo1_devs~r
>
> Handing the _admn groups as a special case is left as an exercise to
> you, but should be reasonably easy given the above as a starting point.
>
>
>
> --
> David Precious ("bigpresh") <[email protected]>
> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
> www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook
> www.preshweb.co.uk/cpan www.preshweb.co.uk/github
>
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/