Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > does any other language even have this feature?

Reply
Thread Tools

does any other language even have this feature?

 
 
valued customer
Guest
Posts: n/a
 
      04-23-2004
my $variable = 'fill in blanks';
my $question = q^
One of the very useful features of perl is the quotelike
operator, because it makes it very easy to create a
"subdocument within a document" ... which brings up
a question, does any other programming language have
anything even close to this functionality?

Python has the triple-quote feature, which is nice, but
still creates minor hassles if you want to want to output
a triple-quote inside your 'subdocument' (use-versus-mention).

XML has CDATA sections, which suck, and suffer from
(use-versus-mention) as well.

Moreover, none of them make it easy to ^.$variable.q^ with
variables.

Is there any other programming environment that has this
feature? Can anyone name even one??

Why doesn't every programming environment have a similar
feature? Adding 'escape sequences' to strings is
error-prone, less readable, and annoying!
^;

print $question;
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      04-23-2004
valued customer wrote:

> Is there any other programming environment that has this
> feature? Can anyone name even one??


Perl borrowed the "here document" idea from UNIX shells like Bash, CSH, etc.
I think it would be a bit of a stretch to refer to that as a "programming
environment," though.

I think Python and Ruby support the idea too.

> Why doesn't every programming environment have a similar
> feature?


It's arguably less useful than one might think at first. When you're dealing
with really large output strings - such as the one in your message - it
often makes more sense to use a template-oriented approach, with the
strings in an external file.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-23-2004
valued customer <> wrote:


> One of the very useful features of perl is the quotelike
> operator,



It's more usual name is "here document".


> Is there any other programming environment that has this
> feature? Can anyone name even one??



Most (all?) of the *nix shells.


> Why doesn't every programming environment have a similar
> feature? Adding 'escape sequences' to strings is
> error-prone, less readable, and annoying!



Because non-Perl languages suck. (heh)


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Ala Qumsieh
Guest
Posts: n/a
 
      04-24-2004
Sherm Pendley wrote:
> valued customer wrote:
>
>
>>Is there any other programming environment that has this
>>feature? Can anyone name even one??

>
>
> Perl borrowed the "here document" idea from UNIX shells like Bash, CSH, etc.
> I think it would be a bit of a stretch to refer to that as a "programming
> environment," though.


I don't think the OP was talking about heredocs. He mentioned
"quote-like operators" which, to me at least, refers to q// and qq//
which are different from heredocs. His remark seems to refer to the fact
that Perl gives you the option to use your favourite delimiter which is
very useful. I don't know of any other languages that offers this.

That's not to say heredocs aren't useful. They are very useful, but
different from q// and qq//.

--Ala

 
Reply With Quote
 
John W. Kennedy
Guest
Posts: n/a
 
      04-24-2004
Ala Qumsieh wrote:

> Sherm Pendley wrote:
>
>> valued customer wrote:
>>
>>
>>> Is there any other programming environment that has this
>>> feature? Can anyone name even one??

>>
>>
>>
>> Perl borrowed the "here document" idea from UNIX shells like Bash,
>> CSH, etc.
>> I think it would be a bit of a stretch to refer to that as a "programming
>> environment," though.

>
>
> I don't think the OP was talking about heredocs. He mentioned
> "quote-like operators" which, to me at least, refers to q// and qq//
> which are different from heredocs. His remark seems to refer to the fact
> that Perl gives you the option to use your favourite delimiter which is
> very useful. I don't know of any other languages that offers this.


Ruby has %q(abc) equal to 'abc' (and %q(a(b)c) equal to 'a(b)c'),
%Q(abc\n) equal to "abc\n" (and %Q(a(b)c\n) equal to "a(b)c\n"),
and %/abc\n/ equal to "abc\n".

--
John W. Kennedy
Read the remains of Shakespeare's lost play, now annotated!
http://pws.prserv.net/jwkennedy/Double%20Falshood.html
 
Reply With Quote
 
David H. Adler
Guest
Posts: n/a
 
      04-25-2004
In article <>, Tad McClellan wrote:
> valued customer <> wrote:
>
>
>> One of the very useful features of perl is the quotelike
>> operator,

>
>
> It's more usual name is "here document".


First, the OP seems to be talking about q{} and friends, rather than
here docs.

Second, here docs weren't even in perlop at all, much less under Quote
and Quote-like Operators until fairly recently, which makes it even less
likely that that's what was meant.

Finally, "It's"?? Oh, Tad, I know you know better than that...

dha

--
David H. Adler - <> - http://www.panix.com/~dha/
Linguists don't know much, but they do know that nobody can succeed in
telling people at large how to speak. - Larry Wall
 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a
 
      04-25-2004
Ala Qumsieh <> said:
>I don't think the OP was talking about heredocs. He mentioned
>"quote-like operators" which, to me at least, refers to q// and qq//
>which are different from heredocs. His remark seems to refer to the fact
>that Perl gives you the option to use your favourite delimiter which is
>very useful. I don't know of any other languages that offers this.


I guess that the freedom to use your delimiter of choice comes from
'sed', the regex-based stream editor in Unix environments. Even
though sed regexes are commonly written with / as the delimiter,
any delimiter can be used (f.ex. ':' is a good choice when the
patterns contain Unix directory paths -- as long as you can be
certain that the paths never contain ':').

s:/usr/bin:/usr/local/bin:g is so much easier to read than
s/\/usr\/bin/\/usr\/local\/bin/g -- esp. if you have a need to
have the above in a context where backslashes must be escaped,
leaving you with
s/\\/usr\\/bin/\\/usr\\/local\\/bin/g .
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:30 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:28 AM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Even older fart, even newer newbie Stan Goodman Java 11 07-04-2003 07:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57