[libperl6-slurp-perl] 01/04: Imported Upstream version 0.051003

Salvatore Bonaccorso carnil at debian.org
Sat Aug 10 15:51:32 UTC 2013


This is an automated email from the git hooks/post-receive script.

carnil pushed a commit to annotated tag debian/0.051003-1
in repository libperl6-slurp-perl.

commit 8cfa48ec205b4f3eada9dfb92421f65b3df1ce8c
Author: Salvatore Bonaccorso <carnil at debian.org>
Date:   Sat Aug 10 17:42:25 2013 +0200

    Imported Upstream version 0.051003
---
 Changes            |   19 +++++++++++++++++++
 MANIFEST           |    1 +
 META.yml           |    2 +-
 README             |    2 +-
 lib/Perl6/Slurp.pm |   25 +++++++++++++++++--------
 t/filetemp.t       |   13 +++++++++++++
 6 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/Changes b/Changes
index 2a8a7f5..8331eb6 100644
--- a/Changes
+++ b/Changes
@@ -48,3 +48,22 @@ Revision history for Perl extension Perl6::Slurp.
 0.051000  Thu Jun 14 20:52:15 2012
 
     - Tweaked error.t to placate Windows (thanks mascip)
+
+
+0.051001  Fri Jul 27 07:58:08 2012
+
+    - Doc tweak (thanks John)
+
+
+
+0.051003  Sat Feb  9 11:59:34 2013
+
+    - Documented limitations of C<slurp> on certain platforms
+      (e.g. no piped opens under Windows).
+
+    - Allowed layer options to have parenthesized args
+      (Thanks Kevin)
+
+    - Handle File::Temp filehandles correctly (thanks Kevin)
+
+
diff --git a/MANIFEST b/MANIFEST
index 8e0e389..8eebe6a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -17,4 +17,5 @@ t/layers.t
 t/lexfilehandle.t
 t/string.t
 t/no_source.t
+t/filetemp.t
 META.yml                                 Module meta-data (added by MakeMaker)
diff --git a/META.yml b/META.yml
index a8b37ca..bce6798 100644
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Perl6-Slurp
-version:            0.051000
+version:            0.051003
 abstract:           Implements the Perl 6 'slurp' built-in
 author:
     - Damian Conway <DCONWAY at CPAN.org>
diff --git a/README b/README
index a2c4fb6..c11f17d 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Perl6::Slurp version 0.051000
+Perl6::Slurp version 0.051003
 =======================
 
 Implements the Perl 6 'slurp' function (see Exegesis 7)
diff --git a/lib/Perl6/Slurp.pm b/lib/Perl6/Slurp.pm
index 4fda782..285b69c 100644
--- a/lib/Perl6/Slurp.pm
+++ b/lib/Perl6/Slurp.pm
@@ -4,8 +4,9 @@ use warnings;
 use strict;
 use 5.008;
 use Carp;
+use Scalar::Util 'refaddr';
 
-our $VERSION = '0.051000';
+our $VERSION = '0.051003';
 
 # Exports only the slurp() sub...
 sub import {
@@ -21,7 +22,7 @@ my $mode_pat = qr{
 # Recognize a mode followed by optional layer arguments...
 my $mode_plus_layers = qr{
     (?: $mode_pat | ^ \s* -\| \s* )
-    ( (?: :[^\W\d]\w* \s* )* )
+    ( (?: :[^\W\d]\w* (?: \( .*? \) ?)? \s* )* )
     \s*
     \z
 }x;
@@ -173,7 +174,7 @@ sub slurp {
     }
 
     # Acquire data (working around bug between $/ and in magic ARGV)...
-    my $data = $FH == \*ARGV ? join("",<>) : do { local $/; <$FH> };
+    my $data = refaddr($FH) == \*ARGV ? join("",<>) : do { local $/; <$FH> };
 
     # Prepare input record separator regex...
     my $irs = ref($/)       ? $/
@@ -251,7 +252,7 @@ Perl6::Slurp - Implements the Perl 6 'slurp' built-in
     $str_contents = slurp '<', \$string;
 
 
-    # Slurp a pipe...
+    # Slurp a pipe (not on Windows, alas)...
 
     $str_contents = slurp 'tail -20 $filename |';
     $str_contents = slurp '-|', 'tail', -20, $filename;
@@ -355,8 +356,9 @@ a scalar reference,
 
 =back
 
-converts it to an input stream if necessary, and reads in the entire stream.
-If C<slurp> fails to set up or read the stream, it throws an exception.
+converts it to an input stream (using C<open()> if necessary), and reads
+in the entire stream. If C<slurp> fails to set up or read the stream, it
+throws an exception.
 
 If no data source is specified C<slurp> uses the value of C<$_> as the
 source. If C<$_> is undefined, C<slurp> uses the C<@ARGV> list,
@@ -381,7 +383,8 @@ record separator and returns the resulting list of strings.
 You can set the input record separator (S<< C<< { irs => $your_irs_here}
 >> >>) for the input operation. The separator can be specified as a
 string or a regex. Note that an explicit input record separator has no
-effect in a scalar context, since C<slurp> always reads in everything anyway.
+input-terminating effect in a scalar context; C<slurp> always
+reads in the entire input stream, whatever the C<'irs'> value.
 
 In a list context, changing the separator can change how the input is
 broken up within the list that is returned.
@@ -482,12 +485,18 @@ Use an array instead:
     slurp $filename, [layer1=>1, layer2=>1, etc=>1];
 
 
-=head1 WARNING
+=head1 WARNINGS
 
 The syntax and semantics of Perl 6 is still being finalized
 and consequently is at any time subject to change. That means the
 same caveat applies to this module.
 
+When called with a filename or piped shell command, C<slurp()> uses
+Perl's built- in C<open()> to access the file. This means that it
+is subject to the same platform-specific limitations as C<open()>.
+For example, slurping from piped shell commands may not work 
+under Windows.
+
 
 =head1 DEPENDENCIES
 
diff --git a/t/filetemp.t b/t/filetemp.t
new file mode 100644
index 0000000..84346f2
--- /dev/null
+++ b/t/filetemp.t
@@ -0,0 +1,13 @@
+use Test::More;
+
+plan tests => 1;
+
+$SIG{__WARN__} = sub { die @_ };
+
+use Perl6::Slurp 'slurp';
+use File::Temp;
+my $fh = File::Temp->new;
+
+my $str = slurp $fh;
+
+is $str, q{} => 'Works with File::Temp';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libperl6-slurp-perl.git



More information about the Pkg-perl-cvs-commits mailing list