Closed p5pRT closed 12 years ago
I know this generates error under Perl 5.8\, but if it is possible to change the HERE document parsing routines\, it would be good if it allowed initial qq() and q() operators.
Let me emplain: I would like to include a bit of perl inside sh-script. But the quoting kicks and makes this impossible (or I haven't found a workaround). A stripped example below. Actually I'm trying to including whole POD inside \<\<\, and make perl pretty print it. It's not currently possible to use
my $var = \<\<'POD';
because that clashes with opening quote. However it would be amndatory to be able to include HERE document using '' parsing rules. The double quote rule is not sufficient in my case\, so I cannot use
my $var = \<\<POD;
Or
my $var = \<\<"POD";
Example below\, what I would like to see supported ( allow qq(POD) q(POD) qx(POD ..):
#!/bin/sh
MyHelp ()
{
perl -e '
my $var = \<\< q(POD);
this Help here
POD
print $var '
}
MyHelp # End of file
syntax error at -e line 6\, near "q(POD)" Execution of -e aborted due to compilation errors.
-- http://tiny-tools.sourceforge.net/ Swatch @time http://www.ryanthiessen.com/swatch/resources.htm Convert @time http://www.mir.com.my/iTime/itime.htm
Hello\,
On Sun Aug 17 06:11:24 2003\, jaalto wrote:
I know this generates error under Perl 5.8\, but if it is possible to change the HERE document parsing routines\, it would be good if it allowed initial qq() and q() operators.
Prospects don't look so good\, from perlop:
Additionally\, the quoting rules for the end of string identifier are not related to Perlās quoting rules -- "q()"\, "qq()"\, and the like are not supported in place of '' and ""\, and the only interpolation is for backslashing the quoting character:
print \<\< "abc\"def"; testing... abc"def
Let me explain: I would like to include a bit of perl inside sh-script. But the quoting kicks and makes this impossible (or I haven't found a workaround).
Well you can workaround using the appropriate shell escaping shown below. A seemingly undocumented alternative is to use a leading \ as seen in the "no interpolation" example below (at least with v5.10.0).
#!/bin/sh
MyHelp () { perl -e ' $a=9;
$var = \<\<'\''POD'\''; shell escapes ($a) POD print $var;
$var = \<\<POD; interpolation ($a) POD print $var;
$var = \<\<\POD; no interpolation ($a) POD print $var; '
}
MyHelp # End of file
$ ./rt-23348 shell escapes ($a) interpolation (9) no interpolation ($a)
The RT System itself - Status changed from 'new' to 'open'
Hello p5p\,
While responding to this ticket we found this seemingly undocumented feature and thought it might be worth drawing attention to\, either for documentation or deprecation.
#!/usr/bin/perl
print \<\<\NOINT; no interpolation ($^X) NOINT
print \<\<INT; interpolation ($^X) INT
__END__ # output no interpolation ($^X) interpolation (/usr/bin/perl)
Or on one line:
perl -e 'print \<\<INT\, \<\<\NOINT' -e '$^X' -e 'INT' -e '$^X' -e 'NOINT'
Regards\,
Brad
Hello p5p\,
While responding to this ticket we found this seemingly undocumented feature and thought it might be worth drawing attention to\, either for documentation or deprecation.
#!/usr/bin/perl
print \<\<\NOINT; no interpolation ($^X) NOINT
print \<\<INT; interpolation ($^X) INT
__END__ # output no interpolation ($^X) interpolation (/usr/bin/perl)
Or on one line:
perl -e 'print \<\<INT\, \<\<\NOINT' -e '$^X' -e 'INT' -e '$^X' -e 'NOINT'
Regards\,
Brad
Brad Bowman via RT wrote:
While responding to this ticket we found this seemingly undocumented feature
perlop(1):
# \<\<EOF # A line-oriented form of quoting is based on the shell "here- # document" syntax. Following a "\<\<" you specify a string to # terminate the quoted material\, ... # If the terminating string is quoted\, the type of quotes used # determine the treatment of the text.
-zefram
On Thu\, Nov 12\, 2009 at 11:48:28AM +0000\, Zefram wrote:
Brad Bowman via RT wrote:
While responding to this ticket we found this seemingly undocumented feature
perlop(1):
# \<\<EOF # A line-oriented form of quoting is based on the shell "here- # document" syntax. Following a "\<\<" you specify a string to # terminate the quoted material\, ... # If the terminating string is quoted\, the type of quotes used # determine the treatment of the text.
So does \<\<\EOF count as being quoted? I think Brad is correct\, this is an undocumented feature.
Ronald
On Thu\, Nov 12\, 2009 at 6:48 AM\, Zefram \zefram@​fysh\.org wrote:
Brad Bowman via RT wrote:
While responding to this ticket we found this seemingly undocumented feature
perlop(1):
# \<\<EOF # A line-oriented form of quoting is based on the shell "here- # document" syntax. Following a "\<\<" you specify a string to # terminate the quoted material\, ... # If the terminating string is quoted\, the type of quotes used # determine the treatment of the text.
-zefram
I think you missed something. perlop doesn't document that \<\<\EOF behaves like \<\<'EOF'. In fact\, perlop doesn't document that \<\<\EOF is even allowed.
On Thu\, Nov 12\, 2009 at 10:33 AM\, Eric Brine \ikegami@​adaelis\.com wrote:
I think you missed something. perlop doesn't document that \<\<\EOF behaves like \<\<'EOF'. In fact\, perlop doesn't document that \<\<\EOF is even allowed.
There is a patch including a paragraph describing this feature in the later versions of the heredoc patches I submitted earlier this year.
-- "In the case of an infinite collection\, the question of the existence of a choice function is problematic"
On Thu Nov 12 13:42:25 2009\, davidnicol@gmail.com wrote:
On Thu\, Nov 12\, 2009 at 10:33 AM\, Eric Brine \ikegami@​adaelis\.com wrote:
I think you missed something. perlop doesn't document that \<\<\EOF behaves like \<\<'EOF'. In fact\, perlop doesn't document that \<\<\EOF is even allowed.
There is a patch including a paragraph describing this feature in the later versions of the heredoc patches I submitted earlier this year.
I see this documentation in 'perlop':
##### Just as in the shell\, a backslashed bareword following the C\<\<\< \<\< >>> means the same thing as a single-quoted string does:
$cost = \<\<'VISTA'; # hasta la ... That'll be $10 please\, ma'am. VISTA
$cost = \<\<\VISTA; # Same thing! That'll be $10 please\, ma'am. VISTA #####
c543c01b (Tom Christiansen 2011-05-02 09:25:55 -0400 2376)
Does this suffice to close this ticket?
Thank you very much. Jim Keenan
On Mon Jan 16 19:06:04 2012\, jkeenan wrote:
On Thu Nov 12 13:42:25 2009\, davidnicol@gmail.com wrote:
On Thu\, Nov 12\, 2009 at 10:33 AM\, Eric Brine \ikegami@​adaelis\.com wrote:
I think you missed something. perlop doesn't document that \<\<\EOF behaves like \<\<'EOF'. In fact\, perlop doesn't document that \<\<\EOF is even allowed.
There is a patch including a paragraph describing this feature in the later versions of the heredoc patches I submitted earlier this year.
I see this documentation in 'perlop':
##### Just as in the shell\, a backslashed bareword following the C\<\<\< \<\< >>> means the same thing as a single-quoted string does:
$cost = \<\<'VISTA'; \# hasta la \.\.\. That'll be $10 please\, ma'am\. VISTA $cost = \<\<\\VISTA; \# Same thing\! That'll be $10 please\, ma'am\. VISTA
#####
c543c01b (Tom Christiansen 2011-05-02 09:25:55 -0400 2376)
Does this suffice to close this ticket?
If that is based on the shell\, then it doesnāt solve the original posterās problem.
On the other hand\, I donāt think we should be tweaking Perlās syntax to make it more easily encapsulated in other formats without escaping. Is HTML next? Do we need alternatives to \< and >?
With the shell example given in the original post\, I *think* itās simply a matter of changing \<\< to \<''\<. (Iām not a shell expert.)
I would be in favour of marking this ticket as rejected.
--
Father Chrysostomos
On Mon\, Jan 16\, 2012 at 10:11:47PM -0800\, Father Chrysostomos via RT wrote:
I would be in favour of marking this ticket as rejected.
+1
-- Lear: Dost thou call me fool\, boy? Fool: All thy other titles thou hast given away; that thou wast born with.
On Tue\, Jan 17\, 2012 at 1:11 AM\, Father Chrysostomos via RT \< perlbug-followup@perl.org> wrote:
I would be in favour of marking this ticket as rejected.
Why? The petitioner's request was resolved by c543c01b after it was requested\, so that would make the ticket resolved.
On Tue\, Jan 17\, 2012 at 7:08 PM\, Eric Brine \ikegami@​adaelis\.com wrote:
On Tue\, Jan 17\, 2012 at 1:11 AM\, Father Chrysostomos via RT \< perlbug-followup@perl.org> wrote:
I would be in favour of marking this ticket as rejected.
Why? The petitioner's request was resolved by c543c01b after it was requested\, so that would make the ticket resolved.
Ignore this\, I thought Brad Bowman's 2009-11-11 was the first post of the ticket.
On Sun Aug 17 06:11:24 2003\, jaalto wrote:
what I would like to see supported ( allow qq(POD) q(POD) qx(POD ..):
\#\!/bin/sh MyHelp \(\) \{ perl \-e ' my $var = \<\< q\(POD\); this Help here POD print $var ' \} MyHelp
This feature is not necessary:
perl -e'...\<\<\POD...'
and
perl -e'...\<\<'\''POD'\''...'
And it breaks existing syntax:
print \<\<q."bar"; foo q
Marking as rejected as per Father Chrysostomos's and Dave Mitchell's opinions.
@ikegami - Status changed from 'open' to 'rejected'
Migrated from rt.perl.org#23348 (status was 'rejected')
Searchable as RT23348$