Debian...encies(3pm)
π Debian::Dependencies π
hii bestie, pull up a chair because today's manpage is Debian::Dependencies(3pm), straight outta the User Contributed Perl Documentation collection. it's giving utility class, it's giving "i parse dependency strings for fun", and honestly? we're obsessed. π
β¨ NAME β¨
Debian::Dependencies β literally just a list of Debian::Dependency objects. that's it. that's the whole job. π
β¨ SYNOPSIS β¨
okay so here's the vibe in code, no words needed:
my $dl = Debian::Dependencies->new('perl, libfoo-perl (>= 3.4)');
print $dl->[1]->ver; # 3.4
print $dl->[1]; # libfoo-perl (>= 3.4)
print $dl; # perl, libfoo-perl (>= 3.4)
$dl += 'libbar-perl';
print $dl; # perl, libfoo-perl (>= 3.4), libbar-perl
print Debian::Dependencies->new('perl') + 'libfoo-bar-perl';
# simple 'sum'
print Debian::Dependencies->new('perl')
+ Debian::Dependencies->new('libfoo, libbar');
# add (concatenate) two lists
print Debian::Dependencies->new('perl')
+ Debian::Dependency->new('foo');
# add dependency to a list
not me getting emotional over a += operator doing exactly what you'd hope π₯Ή
β¨ DESCRIPTION β¨
so Debian::Dependencies is a list of Debian::Dependency objects, and it comes with automatic construction and automatic stringification. self-sufficient king behavior. π
here's the tea on the internals: objects of this class are blessed array references. you can safely treat them as arrayrefs, no cap β as long as the elements you put in them are instances of the Debian::Dependency class. that's the one condition. respect the boundary. π«Ά
and when you use one in string context? it converts itself into a comma-delimited list of dependencies, which is exactly what you want for the dependency fields of debian/control files. it just knows. iconic. β¨
π§ CLASS METHODS π§
new(dependency-string)
constructs a fresh new Debian::Dependencies object, slay. it takes exactly one scalar argument, which gets parsed and turned into an arrayref of Debian::Dependency objects. every dependency inside that string should be delimited by a comma and an optional space β and the exact regular expression doing that work is:
/\s*,\s*/
character for character, bestie. don't come for me about the regex. π
π¦ OBJECT METHODS π¦
add( dependency[, ... ] )
adds a dependency (or a whole list of them, we love a spread) to the list of dependencies. buuut here's the smart part: if the new dependency is a subset of or overlaps some of the old dependencies, it doesn't get duplicated. the class said "i'm not doing redundancy today." π
watch it work:
my $d = Debian::Dependencies('foo, bar (<=4)');
$d->add('foo (>= 4), bar');
print "$d"; # foo (>= 4), bar (>= 4)
and dependency can be any of these three things:
- a
Debian::Dependencyobject - a
Debian::Deendenciesobject - a string (in which case it gets converted into an instance of the
Debian::Dependenciesclass)
remove( dependency, ... )
remove( dependencies, ... )
removes a dependency from the list of dependencies. both Debian::Dependency instances and Debian::Dependencies instances are supported as arguments. π
any non-reference arguments get coerced into instances of the Debian::Dependencies class β no manual conversion needed, it's got you.
and the precision here?? only dependencies that are a subset of the given dependencies actually get removed. nothing else. don't try it.
my $deps = Debian::Dependencies->new('foo (>= 1.2), bar');
$deps->remove('foo, bar (>= 2.0)');
print $deps; # bar
it also returns the list of the dependencies removed, so you can see exactly what got the boot. very transparent of it. β¨
has( dep )
returns true if the dependency list contains the given dependency. in other words (and this is the part that matters): this returns true if the list of dependencies guarantees that the given dependency will be satisfied.
for example, "foo, bar" satisfies "foo", but not "foo (>= 5)". the version constraint said nope. π
prune()
this method is deprecated. it's not the moment, bestie. if you want to sort the dependency list, either callsortor just use normal perl sorting stuff on the dereferenced array. either way,prune()is not the move. π«
sort()
sorts the dependency list by package name, version and relation. all three. in that order. tidy. πΈ
π SEE ALSO π
Debian::Dependencyβ the whole reason this class exists, go say hi π«Ά
π AUTHOR π
Damyan Ivanov <dmn@debian.org> β legend behavior, honestly.
π COPYRIGHT & LICENSE π
Copyright (C) 2008, 2009, 2010 Damyan Ivanov <dmn@debian.org>
Copyright (C) 2009 gregor herrmann <gregoa@debian.org>
this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. π
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (yes, the all-caps is in the original and yes, it's giving legal drama, but it's real and it means real things.) see the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. π¬
and that's the whole page, bestie!! this was perl v5.40.1, dated 2026-05-08, from the User Contributed Perl Documentation section β that's a 3pm page for anyone keeping score. now go forth and concatenate your dependency lists responsibly. mwah. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libdebian-source-perl 0.133 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms