Skip to content

Commit 818671d

Browse files
author
Chris White
committed
Add syntax of capturing to bin/perlpp POD.
Closes #20.
1 parent 31744f0 commit 818671d

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*~
1212
~*
1313
*.swp
14+
*.tmp
1415

1516
# from GitHub's perl .gitignore:
1617
!Build/

bin/perlpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ evaluates that script ("eval time") to produce the output. All Perl code is
140140
run when the script is evaluated, except for commands notes as occuring at
141141
generation time.
142142
143+
For double-quotes adjacent to the delimiters, add whitespace between
144+
the quote and the delimiter. For example, use C<< <? " >> and C<< " ?> >>
145+
instead of C<< <?" >> and C<< "?> >>. The exception is if you want to invoke
146+
L<capturing|"Capturing">, described below.
147+
143148
=head2 Modes
144149
145150
=over
@@ -214,8 +219,21 @@ C<< <?:elsif NAME CONDITION ?> >> (or C<elif> or C<elseif>).
214219
215220
=head2 Capturing
216221
217-
Description coming soon! In short, C<< <? print "?>some string<?" ; ?> >>.
218-
That way you don't have to express long blocks of text as Perl string literals.
222+
Capturing permits you to express single-quoted strings without having to
223+
quote and escape. For example, C<< <? print "?>some $text "string"<?" ; ?> >>
224+
outputs C<some $text "string"> literally, without substituting C<$text> and
225+
without the need to escape the double-quotes. That way you don't have to
226+
express long blocks of text as Perl string literals.
227+
228+
Capturing can be used anywhere a Perl string expression is valid.
229+
230+
PerlPP commands can be nested within captured strings. For example,
231+
running the script
232+
233+
<?= "!" . "?>foo<?= 42 ?><?" . "bar" ?>
234+
235+
will output C<!foo42bar>. The C<42> is generated by the nested
236+
C<< <?= 42 ?> >> expression.
219237
220238
=head1 THE GENERATED SCRIPT
221239
@@ -307,4 +325,4 @@ OTHER DEALINGS IN THE SOFTWARE.
307325
308326
=cut
309327
310-
# vi: set ft=perl: #
328+
# vi: set ft=perl ts=4 sts=0 sw=4 noet ai: #

t/01-readme.t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env perl -W
2-
# Tests from perlpp's README.md
2+
# Tests from perlpp's README.md and bin/perlpp's POD.
33
use strict;
44
use warnings;
55
use Test::More;
@@ -10,6 +10,8 @@ my ($in, $out, $err);
1010

1111
my @testcases=( # In the order they are given in README.md
1212
# [$in, $out, $err (if any)]
13+
14+
# === From README.md =====================
1315
['<?x this tag is passed as is ?> because "x" is not a valid mode',
1416
'<?x this tag is passed as is ?> because "x" is not a valid mode'],
1517
[ <<'SCRIPT',
@@ -86,6 +88,9 @@ RESULT
8688
],
8789
# the blank line before "abcd..." is the \n after the first `?>`
8890

91+
# === From bin/perlpp ====================
92+
93+
[ '<?= "!" . "?>foo<?= 42 ?><?" . "bar" ?>', '!foo42bar' ],
8994
); #@testcases
9095

9196
plan tests => scalar @testcases;

0 commit comments

Comments
 (0)