Text::Sequence - spot one-dimensional sequences in patterns of text
use Text::Sequence; my @list = get_files_in_dir(); my ($sequences, $singletons) = Text::Sequence::find($somedir); my $sequence = $sequences->[0]; print $sequence->template(); my $num = 0; foreach my ($element) ($sequence->members()) { ++$num; print "$num) $filename\n"; }
A sequence could be a list of files like
00001.jpg 00002.jpg 00003.jpg ... 05000.jpg
or
raw.0001.txt ... raw.0093.txt
foo3a.html foo3b.html foo3c.html
or even
1.mp3 100.mp3
in which case their templates would be
%.5d.tif raw.%.4d.txt foo3%s.html %d.mp3
respectively.
This library will attempt to
It does not spot multi-dimensional sequences, e.g. foo-%d-%d.jpg.
foo-%d-%d.jpg
my ($sequences, $singletons) = Text::Sequence::find($somedir);
A static method to find all the sequences in a list of elements. Both are returned as arrayrefs.
Creates a new sequence object.
Tell you the template of the sequence, in printf-like formats.
printf
If you pass in a number or letter then it will substitute it in to return an actual sequence element.
Returns a list describing the members of the sequence. Each item in the list is a letter or (non-padded) number which can be substituted into the template to obtain the original element
For members of the same width, order is preserved from the original call to find().
find()
Tells you whether a particular string is in this sequence.
Returns the regular expression used to determine whether something is in the sequence or not.
Simon Wistow <simon@thegestalt.org> Adam Spiers <cpan@adamspiers.org>
Copyright (c) 2004 - Simon Wistow
Can't insist on sequences being contiguous (yet).
To install Text::Sequence, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Sequence
CPAN shell
perl -MCPAN -e shell install Text::Sequence
For more information on module installation, please visit the detailed CPAN module installation guide.