/usr/share/perl5/Algorithm/Dependency/Source/File.pm is in libalgorithm-dependency-perl 1.110-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | package Algorithm::Dependency::Source::File;
=pod
=head1 NAME
Algorithm::Dependency::Source::File - File source for dependency heirachys
=head1 DESCRIPTION
Algorithm::Dependency::Source::File implements a
L<source|Algorithm::Dependency::Source> where the items are stored in a flat
file or a relatively simple format.
=head2 File Format
The file should be an ordinary text file, consisting of a series of lines,
with each line completely containing the information for a single item.
Blank lines, or lines beginning with the hash character '#' will be
ignored as comments.
For a single item line, only word characters will be used. A 'word character'
consists of all letters and numbers, and the underscore '_' character.
Anything that is not a word character will be assumed to be a seperator.
The first word will be used as the name or id of the item, and any further
words in the line will be used as other items that this one depends on. For
example, all of the following are legal.
# A single item with no dependencies
Foo
# Another item that depends on the first one
Bar Foo
# Depending on multiple others
Bin Foo Bar
# We can use different seperators
One:Two|Three-Four+Five=Six Seven
# We can also use multiple non-word characters as seperators
This&*&^*&File: is& & & :::REALLY()Neat
From the examples above, it should be easy to create your own files.
=head1 METHODS
This documents the methods differing from the ordinary
L<Algorithm::Dependency::Source> methods.
=cut
use 5.005;
use strict;
use Algorithm::Dependency::Source ();
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.110';
@ISA = 'Algorithm::Dependency::Source';
}
#####################################################################
# Constructor
=pod
=head2 new $filename
When constructing a new Algorithm::Dependency::Source::File object, an
argument should be provided of the name of the file to use. The constructor
will check that the file exists, and is readable, returning C<undef>
otherwise.
=cut
sub new {
my $class = shift;
my $filename = shift or return undef;
return undef unless -r $filename;
# Get the basic source object
my $self = $class->SUPER::new() or return undef;
# Add our arguments
$self->{filename} = $filename;
$self;
}
#####################################################################
# Private Methods
sub _load_item_list {
my $self = shift;
# Load the contents of the file
local $/ = undef;
open( FILE, $self->{filename} ) or return undef;
defined(my $source = <FILE>) or return undef;
close( FILE ) or return undef;
# Split, trim, clean and remove comments
my @content = grep { ! /^\s*(?:\#|$)/ }
split /\s*[\015\012][\s\015\012]*/, $source;
# Parse and build the item list
my @Items = ();
foreach my $line ( @content ) {
# Split the line by non-word characters
my @sections = grep { length $_ } split /\W+/, $line;
return undef unless scalar @sections;
# Create the new item
my $Item = Algorithm::Dependency::Item->new( @sections ) or return undef;
push @Items, $Item;
}
\@Items;
}
1;
=pod
=head1 SUPPORT
To file a bug against this module, use the CPAN bug tracking system
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency>
For other comments, contact the author.
=head1 AUTHOR
Adam Kennedy <adamk@cpan.org>
=head1 SEE ALSO
L<Algorithm::Dependency>
=head1 COPYRIGHT
Copyright 2003 - 2009 Adam Kennedy.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
|