What do you think about the attached. If you like it I can add docs.
Since parse_dir() accepts 4 positional arguments, a package variable seems like the best approach.
The use of `our` would make things a little cleaner but...
diff -x'*.json' -x'*.yml' -urpN File-Listing-6.04/lib/File/Listing.pm File-Listing-6.04-patch1/lib/File/Listing.pm
--- File-Listing-6.04/lib/File/Listing.pm 2012-02-15 17:01:41.000000000 -0500
+++ File-Listing-6.04-patch1/lib/File/Listing.pm 2014-06-28 00:18:09.000000000 -0400
@@ -7,6 +7,9 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(parse_dir);
+# If true parse '.' and '..'
+$ALL = 0;
+
use strict;
use Carp ();
@@ -32,7 +35,6 @@ sub parse_dir ($;$$$)
sub line { Carp::croak("Not implemented yet"); }
sub init { } # Dummy sub
-
sub file_mode ($)
{
Carp::croak("Input to file_mode() must be a 10 character string.")
@@ -164,7 +166,7 @@ sub line
/x )
{
- return if $name eq '.' || $name eq '..';
+ return if ($name eq '.' || $name eq '..') && !$File::Listing::ALL;
$name = "$curdir/$name" if length $curdir;
my $type = '?';
if ($kind =~ /^l/ && $name =~ /(.*) -> (.*)/ ) {
@@ -258,7 +260,7 @@ sub line
(.+)$ # File name
/x )
{
- return if $name eq '.' || $name eq '..';
+ return if ($name eq '.' || $name eq '..') && !$File::Listing::ALL;
$name = "$curdir/$name" if length $curdir;
my $type = '?';
if ($size_or_dir eq '<DIR>') {
diff -x'*.json' -x'*.yml' -urpN File-Listing-6.04/t/ls-la.t File-Listing-6.04-patch1/t/ls-la.t
--- File-Listing-6.04/t/ls-la.t 1969-12-31 19:00:00.000000000 -0500
+++ File-Listing-6.04-patch1/t/ls-la.t 2014-06-28 00:29:17.000000000 -0400
@@ -0,0 +1,24 @@
+#!perl -w
+
+use Test;
+plan tests => 5;
+
+use File::Listing;
+
+$File::Listing::ALL = 1;
+
+@dir = parse_dir(<<'EOT');
+total 0
+drwxr-xr-x 4 aas users 1024 Mar 16 15:47 .
+drwxr-xr-x 11 aas users 1024 Mar 15 19:22 ..
+drwxr-xr-x 2 aas users 1024 Mar 16 15:47 CVS
+EOT
+
+ok(@dir, 3);
+
+ok($dir[0][0], ".");
+ok($dir[0][1], "d");
+
+ok($dir[1][0], "..");
+ok($dir[1][1], "d");
+