Name : perl-Acme-CPANModules-ReadingFilesBackward
| |
Version : 0.001
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.1
| Date : 2020-03-01 07:06:39
|
Group : Development/Libraries/Perl
| Source RPM : perl-Acme-CPANModules-ReadingFilesBackward-0.001-1.1.src.rpm
|
Size : 0.03 MB
| |
Packager : (none)
| |
Summary : Reading files backward (in reverse)
|
Description :
Reading files backward (in reverse).
Probably the fastest way, if you are on a Unix system, is to use the *tac* command, which can read a file line by line in reverse order, or paragraph by paragraph, or character by character, or word by word, or by a custom separator string or regular expression. Example for using it from Perl:
open my $fh, \"tac /etc/passwd |\"; print while < $fh>
Another convenient way is to use the Perl I/O layer PerlIO::reverse. It only does line-by-line reversing, but you can use the regular Perl API. You don\'t even have to \'use\' the module explicitly (but of course you have to get it installed first):
open my $fh, \"< :reverse\", \"/etc/passwd\"; print while < $fh>
If your file is small (fits in your system\'s memory), you can also slurp the file contents first into an array (either line by line, or paragraph by paragraph, or what have you) and then simply \'reverse\' the array:
open my $fh, \"< \", \"/etc/passwd\"; my AATTlines = < $fh> print for reverse AATTlines;
If the above solutions do not fit your needs, there are also these modules which can help: File::ReadBackward, File::Bidirectional. File::ReadBackward is slightly faster than File::Bidirectional, but File::Bidirectional can read forward as well as backward. I now simply prefer PerlIO::reverse because I don\'t have to use a custom API for reading files.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-A/openSUSE_Tumbleweed/noarch |