-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |