Skip to content

Commit

Permalink
added some examples (erm.. 1)
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.jrock.us/cpan_modules/File-Attributes-Recursive@92 01d9642f-1d18-0410-bea3-844bd6f27a17
  • Loading branch information
jon committed Oct 12, 2006
1 parent 722e4b2 commit 0753f43
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for File-Attributes-Recursive

0.02 11 October 2006
- fixed #22041
- moved to path::class (#22042)

0.01 2 July 2006
First version, released on an unsuspecting world.

65 changes: 65 additions & 0 deletions examples/example.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/perl
# example.pl
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>

use File::Attributes qw(set_attribute get_attributes);
use File::Attributes::Recursive qw(:all);
use Directory::Scratch;

use strict;
use warnings;

=for you
First, let's make a directory hierarchy.
=cut

my $tmp = Directory::Scratch->new;
my $quux = $tmp->touch('foo/bar/baz/quux');
print "** Note, this program is literate! View the source for details.\n";

print "Created $quux\n";

=for you
Now we have:
foo
foo/bar
foo/bar/baz
foo/bar/baz/quux
So let's set an attribute on C<foo/bar> and watch it apply automagically
to C<foo/bar/baz/quux>.
=cut

set_attribute($tmp->exists('foo/bar'), 'foo', 'bar');
set_attribute($tmp->exists('foo/bar'), 'bar', 'baz');

print "\nAttributes on foo/bar:\n";
my %attrs = get_attributes($tmp->exists('foo/bar'));
foreach (keys %attrs) {
print " $_ -> $attrs{$_}\n";
}

set_attribute($quux, 'quux', q[that's me]);

print "\nAttributes on foo/bar/baz/quux:\n";
%attrs = get_attributes($quux, $tmp);
foreach (keys %attrs) {
print " $_ -> $attrs{$_}\n";
}

print "\nRecursive attributes on foo/bar/baz/quux:\n";
%attrs = get_attributes_recursively($quux, $tmp);
foreach (keys %attrs) {
print " $_ -> $attrs{$_}\n";
}

=for you
I hope this makes sense. See the docs for more information.
=cut

0 comments on commit 0753f43

Please sign in to comment.