[25897] in Perl-Users-Digest
Perl-Users Digest, Issue: 8125 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 29 00:05:47 2005
Date: Sat, 28 May 2005 21:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 28 May 2005 Volume: 10 Number: 8125
Today's topics:
(Ilya?) cperl-mode.el and *unescaped* "/" within char-c (David Combs)
(Ilya?) cperl-mode.el and strings like ||""$foo""|| *wi (David Combs)
Re: Force interpolation of single quoted character <usenet739_yahoo_com_au>
Re: Force interpolation of single quoted character <usenet739_yahoo_com_au>
Re: FormMail Problem <noreply@gunnar.cc>
Re: How to clear all html tag in document? <pilkowsk@informatik.uni-marburg.de>
Re: output question <tadmc@augustmail.com>
Re: output question <vdotniekerkatfreelerdotnl>
Re: output question <tintin@invalid.invalid>
Re: Scanning @array elements for similair content <tadmc@augustmail.com>
yet another possibility to add to a syntax-err msg? (David Combs)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 May 2005 22:55:45 -0400
From: dkcombs@panix.com (David Combs)
Subject: (Ilya?) cperl-mode.el and *unescaped* "/" within char-classes?
Message-Id: <d7bavh$3v1$1@panix3.panix.com>
Subject: (Ilya?) cperl-mode.el and *unescaped* "/" within char-classes?
(Oh, I'm using emacs 22.0.50.1 (cvs version).
QUESTION -- with your very most up-to-date version, what happens
when you try this:
In either of the following two lines of perl, remove the backslash
before the fwd-slashs, and cperl-mode.el gets confused.
(eg colors change, won't indent correctly, etc).
next if ( $line !~ qr!^([a-zA-Z\/.0-9]+)$! ); #debug
next if ( $line !~ qr!^([a-zA-Z\/.0-9]+):([0-9]+):(.*)$! ); #debug
# |||foo.bar:1234:now is the time.|||
If, instead, everything works ok, please let me know, and also
tell me how to get the cperl-mode.el that you just used.
Thanks!
David
------------------------------
Date: 28 May 2005 22:53:27 -0400
From: dkcombs@panix.com (David Combs)
Subject: (Ilya?) cperl-mode.el and strings like ||""$foo""|| *within a string*?
Message-Id: <d7bar7$kko$1@panix3.panix.com>
subject: (Ilya?) cperl-mode.el and strings like ||"\"$foo\""|| *within a string*?
The following lines, to me, seem absolutely identical.
But stick them into a file foo.pl, with cperl-mode, and I find
here on my computer that although when you put the cursor
on the right-paren just before the semicolon, it will
(a) (properly) turn both it and the matching left-paren green,
(b) except not on the sixth one (and beyond).
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
| print("\$aryOfAliasObjRefs[\$numAliases]->{name} is \"");
But what's different between the 5th and 6th line? I say nothing is
different between them.
Likewise, ediff-buffers agrees (when I take the two lines and put them
into two files, one line each).
I HAVE NO CLUE AS TO WHAT IS HAPPENING!
Does anyone?
Thanks!
David
PS: Anyone knonw how to find out what version of eg cperl-mode
a buffer is using? Or where the .el-file was actually found?
(No, I don't mean to just look at .../lisp/cperl-mode.el --
suppose you've also done a M-x load-file for one located in eg your
own directory -- and you aren't sure just where the one
actually being used came from, and want to find out precisely.)
------------------------------
Date: Sun, 29 May 2005 11:16:50 +1000
From: "Scott Bass" <usenet739_yahoo_com_au>
Subject: Re: Force interpolation of single quoted character
Message-Id: <42991803$0$24303$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
"Brian McCauley" <nobull@mail.com> wrote in message
news:d77pkf$473$1@slavica.ukpost.com...
> Scott Bass wrote:
>
>> "Tad McClellan" <tadmc@augustmail.com> wrote in message
>> news:slrnd9edoo.ci8.tadmc@magna.augustmail.com...
>
> [snip Tad ]
>
> [snip Brian]
>
> The question you are asking _is_ frequently asked, but I think I'd
> confused myself and then in turn you too.
>
> The FAQ "How do I unescape a string?" does _not_ answer your question. Nor
> does the FAQ "How can I expand variables in text strings?".
>
> Both of these _should_ IMNSHO mention the chop-eval-heredoc solution if
> only so that they can explain when it is unsafe to use. I have in the
> past battled with FAQ maintainers on this issue but never got very far.
>
> I have to confess that I mis-remebered the FAQ "How do I unescape a
> string?" as giving Tad's solution. May I be placed in virtual stocks and
> pelted with virtual rotten fruit for not checking my facts before I
> posted.
Hey, happens to the best of us ;-) I've even been known to do it on rare
occasions.
Summary of Brian's previous posts:
> The better version of that is...
>
> chop( $sep = eval "<<__EOD__\n$sep\n__EOD__");
> do_something if $@;
>
> That only breaks if $sep contains the sequence "\n__EOD__\n" which is much
> less likely to occur in the normal course of events.
and
> BTW: here's a slightly safer eval based solution
I assume that should be "non eval based solution"?
>
> s/(\\[^"\$\@]+)/qq("$1")/eeg;
>
> Note that's not 100% infalible but AFAIK it's not a security problem and
> copes with all reasonable strings. It does have the interesting side
> effect of stripping \$ \" and \@ - but those have no buisness being in the
> strings you are talking about.
Thanks for the help Brian. In my final test program:
use Getopt::Long;
GetOptions (
"sep:s" => \$sep
);
#chop($sep = eval "<<__$$__\n$sep\n__$$__");
$sep =~ s/(\\[^"\$\@]+)/qq("$1")/eeg;
print join $sep, ("line1","line2");
both solutions work a treat. I'll go with the here doc solution; it's an
internal, departmental script, and the end user's won't be putting cruft in
the command line option.
Regards,
Scott
------------------------------
Date: Sun, 29 May 2005 12:54:01 +1000
From: "Scott Bass" <usenet739_yahoo_com_au>
Subject: Re: Force interpolation of single quoted character
Message-Id: <42992eca$0$24281$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
"Scott Bass" <usenet739_yahoo_com_au> wrote in message
news:42991803$0$24303$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
[snip]
> Thanks for the help Brian. In my final test program:
>
> use Getopt::Long;
> GetOptions (
> "sep:s" => \$sep
> );
> #chop($sep = eval "<<__$$__\n$sep\n__$$__");
> $sep =~ s/(\\[^"\$\@]+)/qq("$1")/eeg;
> print join $sep, ("line1","line2");
Make that
chop($sep = eval "<<__$$\__\n$sep\n__$$\__");
------------------------------
Date: Sun, 29 May 2005 01:10:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FormMail Problem
Message-Id: <3fscjaF9f880U1@individual.net>
Tad McClellan wrote:
> Gunnar Hjalmarsson wrote:
>> It's obvious from Christopher's follow-up that he doesn't know enough
>> Perl to express such a depreciatory opinion on someone else's code, and
>> that his opinion is merely hearsay.
>
> I didn't see anything in his followup that indicated a skill level.
>
> I must have missed the obvious, what was it that you saw?
Unlike what Christopher stated
1) pipes to other programs can be opened also when taint mode is
enabled, and
2) the /e modifier in the expressions for unescaping URI escaped strings
s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
isn't dangerous.
To me, that indicates a limited skill level (which isn't a 'crime' in
itself...). Anyway, considering that, and since Christopher's other
comments are far from supporting his depreciatory opinion on FormMail,
the logical conclusion is that the opinion is merely hearsay.
It's funny. Normally, such incorrect statements on Perl would have
resulted in several correcting follow-ups. Now, since they were made
with the aim of discrediting FormMail, that did not happen.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 28 May 2005 17:53:51 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: How to clear all html tag in document?
Message-Id: <3frifsF8ti74U1@individual.net>
* max schrieb:
> How to clear all html tag in line (or document) ?
> All tags have "<" on start, and ">" at the end of tag. Eg <table>, </table>,
> <div align="left">, <td align="left" bgcolor="#000099"> ....
> I make program that work character by character, and control if is start is
> "<", and end ">".
> Please help me I now those Perl programmers do that on easier way! How?
I suggest to use the module HTML::Strip, it is doing exactly what you
want. Have a look at
http://search.cpan.org/~kilinrax/HTML-Strip-1.04/Strip.pm
With that all you have to do is something like
my $html = "<div><b>foo</b> bar</div> baz";
my $text = HTML::Strip->new->parse( $html );
print $text;
__END__
foo bar baz
regards,
fabian
------------------------------
Date: Sat, 28 May 2005 10:30:58 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: output question
Message-Id: <slrnd9h3li.fvu.tadmc@magna.augustmail.com>
Huub <> wrote:
> Tad McClellan wrote:
>> Which tutorial are you studying?
>
> Introduction to Perl & CGI Programming
> A complete course of study at free?ed.net
^^^^^^^
> Copyright © 1999, Free?Ed, Ltd.
> All rights reserved.
Do you mean free-ed.net instead?
I find no titles there for "CGI", and a different one from what you've
quoted for "Perl".
I would like to assess the quality of the tutorial that you are
using. To do that, I need something that will allow me to find
exactly what you are using so that I can review it.
Is it available online? If so, at what URL?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 28 May 2005 18:32:42 +0200
From: Huub <vdotniekerkatfreelerdotnl>
Subject: Re: output question
Message-Id: <42989cff$0$146$3a628fcd@reader1.nntp.hccnet.nl>
Tad McClellan wrote:
> Huub <> wrote:
>
>>Tad McClellan wrote:
>
>
>>>Which tutorial are you studying?
>>
>>Introduction to Perl & CGI Programming
>>A complete course of study at free?ed.net
>
> ^^^^^^^
>
>>Copyright © 1999, Free?Ed, Ltd.
>>All rights reserved.
>
>
>
> Do you mean free-ed.net instead?
>
Yes..apparently the copy-paste didn't work out 100%.
> I find no titles there for "CGI", and a different one from what you've
> quoted for "Perl".
It's a pdf file I got from someone. I don't know if it's available online.
>
> I would like to assess the quality of the tutorial that you are
> using. To do that, I need something that will allow me to find
> exactly what you are using so that I can review it.
>
>
> Is it available online? If so, at what URL?
>
>
If you like, I can send it to you.
Huub
------------------------------
Date: Sun, 29 May 2005 13:04:35 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: output question
Message-Id: <dG8me.3721$U4.526824@news.xtra.co.nz>
"Huub" <vdotniekerkatfreelerdotnl> wrote in message
news:429835de$0$151$3a628fcd@reader2.nntp.hccnet.nl...
>> Which tutorial are you studying?
>>
>>
>
> Introduction to Perl & CGI Programming
> A complete course of study at free?ed.net
> Copyright © 1999, Free?Ed, Ltd.
> All rights reserved.
Given that it has a copyright of 1999, it is almost likely to be totally out
of date with current Perl/CGI practices.
------------------------------
Date: Sat, 28 May 2005 10:22:17 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Scanning @array elements for similair content
Message-Id: <slrnd9h358.fvu.tadmc@magna.augustmail.com>
Randy <rbutcher.nospam@hotmail.com> wrote:
[snip stuff already answered in other followups]
> P.S. Your going to laugh at this
No I'm not.
I used to program without it myself (because it did not yet exist :-)
> but until recent I have never used the
> command 'use strict'.
^^^^^^^
^^^^^^^
It is more properly called a "pragma", which is fancy college-talk
for a "compiler directive".
> To be honest, I'm not 100% certain what exactly this
> does,
You can read its docs with
perldoc strict
> or how it is benefiting me or the script.
It finds common mistakes.
"strict vars" in particular, finds typos, which is a very common
mistake made by all of us.
> All I know for certain is
> that without adding "my" to variable definitions, the script doesn't
> work/run.
When you put "use strict" in your program, you are making a
promise to perl.
I promise to declare all of my variables before I use them
(or I will use their fully qualified package name).
If you break your promise, perl will refuse to run your program.
> Most articles I have read online highly recommend using this
> command but don't go into great detail why.
It finds bugs in microseconds rather than in a bazillion- microsecond
debugging session.
> I ask you this because I wish to
> better my understanding of Perl and to ensure I write proper scripts in the
> future.
strict and warnings will save you time by finding common
mistakes *for you*.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 May 2005 22:57:40 -0400
From: dkcombs@panix.com (David Combs)
Subject: yet another possibility to add to a syntax-err msg?
Message-Id: <d7bb34$j6a$1@panix3.panix.com>
Subject: yet another possibility to add to a syntax-err msg?
| 698 ==/dkcjunk==> /me-FIRST-in-PATH-bin/perl-5.8.6/bin/perl5.8.6 -c -w traverse-via-SOURCE-stmts.pl .myalias
| syntax error at traverse-via-SOURCE-stmts.pl line 112, near "aryOfAliasObjRefs["
| traverse-via-SOURCE-stmts.pl had compilation errors (#1)
| (F) Probably means you had a syntax error. Common reasons include:
|
| A keyword is misspelled.
| A semicolon is missing.
| A comma is missing.
| An opening or closing parenthesis is missing.
| An opening or closing brace is missing.
| A closing quote is missing.
|
| Often there will be another error message associated with the syntax
| error giving more information. (Sometimes it helps to turn on -w.)
| The error message itself often tells you where it was in the line when
| it decided to give up. Sometimes the actual error is several tokens
| before this, because Perl is good at understanding random input.
| Occasionally the line number may be misleading, and once in a blue moon
| the only way to figure out what's triggering the error is to call
| perl -c repeatedly, chopping away half the program each time to see
| if the error went away. Sort of the cybernetic version of S<20
| questions>.
|
| Uncaught exception from user code:
| syntax error at traverse-via-SOURCE-stmts.pl line 112, near "aryOfAliasObjRefs["
| traverse-via-SOURCE-stmts.pl had compilation errors.
| at traverse-via-SOURCE-stmts.pl line 165
| 699 ==/dkcjunk==>
But, here's what's actually at line 112:
aryOfAliasObjRefs[$numAliases++] = $aliasObjRef;
, the error being the missing sigil.
Please add this possiblity to the other six.
Thanks,
David
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8125
***************************************