[13786] in Perl-Users-Digest
Perl-Users Digest, Issue: 1196 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 23:07:46 1999
Date: Wed, 27 Oct 1999 20:07:30 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941080050-v9-i1196@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 27 Oct 1999 Volume: 9 Number: 1196
Today's topics:
regex match with empty string <xah@best.com>
Re: regex match with empty string <emschwar@rmi.net>
Re: regex match with empty string (Sam Holden)
regular expressions <sakalauk@ssc.usm.edu>
Re: regular expressions (Abigail)
Re: regular expressions <lr@hpl.hp.com>
Remove C-Comments with perl <kai.wipplinger@de.bosch.com>
Re: Remove C-Comments with perl <cassell@mail.cor.epa.gov>
Re: Remove C-Comments with perl <rhomberg@ife.ee.ethz.ch>
Re: Remove C-Comments with perl <kai.wipplinger@de.bosch.com>
Re: Remove C-Comments with perl <kai.wipplinger@de.bosch.com>
Re: Remove C-Comments with perl <lr@hpl.hp.com>
Re: Remove C-Comments with perl (Abigail)
Re: Remove C-Comments with perl (Damian Conway)
Re: Remove C-Comments with perl (Tad McClellan)
Re: removing newlines from a string. <rootbeer@redcat.com>
Re: removing newlines from a string. <tom@tnunn.demon.co.uk>
Re: removing newlines from a string. (Craig Berry)
Re: replacing special characters to %xx for browsers (Randal L. Schwartz)
Re: replacing special characters to %xx for browsers (Michael Budash)
Re: replacing special characters to %xx for browsers (Randal L. Schwartz)
Re: replacing special characters to %xx for browsers (Michael Budash)
Re: replacing special characters to %xx for browsers <marcel.grunauer@lovely.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Oct 1999 14:19:03 -0500
From: "Xah Lee" <xah@best.com>
Subject: regex match with empty string
Message-Id: <38176c55$0$232@newsreader.alink.net>
Normally an empty regex will match a string.
But not so in the following code that uses File::Find.
I couldn't figure it out. Anyone?
Fucking stupid Perl.
Xah
xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
perl5 -e'print "another f@%#!^& obfuscated perl moron.\n"'
--
#!/usr/local/bin/perl5 -w
use strict;
use File::Find;
my $dir = '/home/xah/';
sub processor() {
if ($_ =~ m//) {print "1$_\n";} else { print "0$_\n";}
}
find(\&processor, $dir);
------------------------------
Date: 27 Oct 1999 16:40:46 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: regex match with empty string
Message-Id: <xkfn1t4h1g1.fsf@valdemar.col.hp.com>
"Xah Lee" <xah@best.com> writes:
> Normally an empty regex will match a string.
Normally? Maybe I'm reading the wrong part of perlop, but I see:
If the PATTERN evaluates to a null string, the last
successfully executed regular expression is used instead.
In this case, you haven't used a regex before the empty one, so I'm not
surprised it doesn't behve the way you want it to.
> But not so in the following code that uses File::Find.
>
> I couldn't figure it out. Anyone?
In the specific case below, I don't honestly see the point. Maybe if we
had some idea of what you were trying to accomplish, we'd have better
suggestions. Are you maybe putting a variable inbetween the //, which
sometimes evaulates to the empty string?
> Fucking stupid Perl.
Seems rude to blame Perl when you don't even know what the problem is.
Especially when it's 90% likely to be programmer error.
<snip example>
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: 27 Oct 1999 22:45:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: regex match with empty string
Message-Id: <slrn81f04t.erh.sholden@pgrad.cs.usyd.edu.au>
On Wed, 27 Oct 1999 14:19:03 -0500, Xah Lee <xah@best.com> wrote:
>Normally an empty regex will match a string.
Did you bother to check the documentation to see if your assumption is
correct...
>But not so in the following code that uses File::Find.
>
>I couldn't figure it out. Anyone?
>
>Fucking stupid Perl.
It's way to early in the morning for me to put up with that.
*plonk*
>
> Xah
> xah@best.com
> http://www.best.com/~xah/PageTwo_dir/more.html
> perl5 -e'print "another f@%#!^& obfuscated perl moron.\n"'
>
>--
>#!/usr/local/bin/perl5 -w
>
>use strict;
>use File::Find;
>
>my $dir = '/home/xah/';
>
>sub processor() {
> if ($_ =~ m//) {print "1$_\n";} else { print "0$_\n";}
Why don't you go and read the documentation that comes with perl about
the m// operator. It has a paragraph that explains what m// does.
You have taken a guess and guessed wrong.
Also that $_ =~ part is a bit strange since $_ is the default anyway...
if (m//) {print "1$_\n";} else { print "0$_\n";}
Or even :
if (//) {print "1$_\n";} else { print "0$_\n";}
--
Sam
Simple rule: include files should never include include files.
--Rob Pike
------------------------------
Date: Tue, 26 Oct 1999 11:55:42 -0500
From: Peter Sakalaukus <sakalauk@ssc.usm.edu>
Subject: regular expressions
Message-Id: <3815DD0E.68BE4F47@ssc.usm.edu>
I need to match and save all occurances of digits found in a string. I
have been able to match and save the first or last occurance only. How
do I match all occurances?
Thanks ...Pete
------------------------------
Date: 27 Oct 1999 01:08:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regular expressions
Message-Id: <slrn81d5lf.bjj.abigail@alexandra.delanet.com>
Peter Sakalaukus (sakalauk@ssc.usm.edu) wrote on MMCCXLVII September
MCMXCIII in <URL:news:3815DD0E.68BE4F47@ssc.usm.edu>:
&&
&& I need to match and save all occurances of digits found in a string. I
&& have been able to match and save the first or last occurance only. How
&& do I match all occurances?
$alldigits = join '' => $string =~ /(\d+)/;
($alldigits = $string) =~ s/\D+//g;
($alldigits = $string) =~ y/0-9//cd;
@alldigits = $string =~ /(d+)/g;
@alldigits = split /\D+/ => $string;
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 26 Oct 1999 13:47:49 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: regular expressions
Message-Id: <MPG.127fb34ce23408ac98a12f@nntp.hpl.hp.com>
In article <3815DD0E.68BE4F47@ssc.usm.edu> on Tue, 26 Oct 1999 11:55:42
-0500, Peter Sakalaukus <sakalauk@ssc.usm.edu> says...
>
> I need to match and save all occurances of digits found in a string. I
> have been able to match and save the first or last occurance only. How
> do I match all occurances?
my @digits = $string =~ /\d+/g;
produces a list of all digit sequences. If you want a list of
individual digits, leave off the '+'.
perldoc perlre
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 25 Oct 1999 16:02:34 +0200
From: Kai Wipplinger <kai.wipplinger@de.bosch.com>
Subject: Remove C-Comments with perl
Message-Id: <381462FA.2C6F7523@de.bosch.com>
Hello together,
I have a problem to remove the comments of a C-File.
Example:
code0
/* comm
comm
comm */
code1
/* comm */
code2
// comm
code3
code4 /* comm * */
code5
/* comm */ code6
code7
code8 // comm
code9
/* comm /* comm */
code10
/* comm /* comm */ code11
code12
/* comm */ code13 /* comm */
code14
/* comm
comm
comm */
code15
/* com // comm */
code16
/* comm
comm */ code17 /* comm */
code18
/* comm */ code19 /* comm
comm */ code20 /* comm */
code21
/* comm */ code22 /* comm
comm */ code23 /* comm */ code24 /* comm
comm */ code25
code26
/* comm
/* comm */
code27
/* comm /* comm */
code28
/* comm /* comm */
code29
//* comm */
code30
First I have tried
# $All contents the whole file
$All =~ /\/\*.*\*\///gs
This will remove everything because of the global context
after that I tried
$All =~ /\/\*([^\*][^\/])*\*\///gs
This has the Problem that between /* and */ must be a even number of
chars.
Next was to replace
/* and */ with unusal chars an replace the string like above. This has
the disadvantage that you cant use all chars in comments.
At last I go through every char and decide if it is a comment or not as
I would do it in C. This is awfully slow.
Do anyone know a better solution for this problem ?
Best Regards
Kai Wipplinger
------------------------------
Date: Tue, 26 Oct 1999 16:36:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Remove C-Comments with perl
Message-Id: <38163AE1.ED5FAEF1@mail.cor.epa.gov>
Kai Wipplinger wrote:
[snip]
> Abigail: // is a C++ Comment which most compilers support also for C-Language ( I know
^^^^
s/most/some/
> thats not real C). Because of this you must prepared for this case when you want to
> strip C-Comments (like the example from Damian, Thanks a lot). The example in the FAQ
> have a problem with this kind of comment. Because i didnt understand it (maybe later
> when i am a crack in PERL :-) ) i cant change it.
Oh, Abigail is more than aware of that. Trust me. But Abigail
also knows that // is something that would make Kernighan and
Ritchie heave. If people think C is merely a subset of C++ ,
then they need to read the FAQ for comp.lang.c , among other
things.
And please,
[1] keep your lines to 72 characters or so; and
[2] post your replies *after* the parts to which you replied.
This way, it is not a major headache for others to read your
words and continue the dialogue.
Thank you,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 26 Oct 1999 17:22:28 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Remove C-Comments with perl
Message-Id: <3815C734.EE23E792@ife.ee.ethz.ch>
Kai Wipplinger wrote:
>
> Hello together,
>
> I have a problem to remove the comments of a C-File.
ccc -E test.c | perl -ne'/^#/||/\S/ && print'
uses perl and removes the comments. It does even a but more, for free
:-)
The perl part is optional, btw
- Alex
------------------------------
Date: Tue, 26 Oct 1999 10:22:17 +0200
From: Kai Wipplinger <kai.wipplinger@de.bosch.com>
Subject: Re: Remove C-Comments with perl
Message-Id: <381564B9.18A903E1@de.bosch.com>
Its installed in the Net (WINNT :-( ). I have found it yet.
Thanks to all for help.
Abigail: // is a C++ Comment which most compilers support also for C-Language ( I know
thats not real C). Because of this you must prepared for this case when you want to
strip C-Comments (like the example from Damian, Thanks a lot). The example in the FAQ
have a problem with this kind of comment. Because i didnt understand it (maybe later
when i am a crack in PERL :-) ) i cant change it.
Kai
Larry Rosler schrieb:
> In article <38154C59.EE144DF2@de.bosch.com> on Tue, 26 Oct 1999 08:38:18
> +0200, Kai Wipplinger <kai.wipplinger@de.bosch.com> says...
> > I have a little problem to access the FAQs. Im on an intranet, which allows me to
> > the only some newsgroups and a few www-Sites. Maybe someone could send me the FAQ
> > per Mail? This would be helpfull I think.
>
> If you have perl installed on your computer (if not, why are you asking
> Perl questions?), the FAQs are on your hard disk. Try these commands:
>
> man perlfaq
> perldoc perlfaq
> perldoc -q comment
>
> <SNIP> of question following response.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Tue, 26 Oct 1999 08:38:18 +0200
From: Kai Wipplinger <kai.wipplinger@de.bosch.com>
Subject: Re: Remove C-Comments with perl
Message-Id: <38154C59.EE144DF2@de.bosch.com>
Hello,
I have a little problem to access the FAQs. Im on an intranet, which allows me to
the only some newsgroups and a few www-Sites. Maybe someone could send me the FAQ
per Mail? This would be helpfull I think.
Greetings
Kai Wipplinger
Abigail schrieb:
> Kai Wipplinger (kai.wipplinger@de.bosch.com) wrote on MMCCXLVI September
> MCMXCIII in <URL:news:381462FA.2C6F7523@de.bosch.com>:
> :: Hello together,
> ::
> :: I have a problem to remove the comments of a C-File.
>
> Did you look in the FAQ? Guess not.
>
> :: Example:
> :: // comm
>
> That's not a C comment.
>
> Abigail
> --
> perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
> 0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
> =>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
> !$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 26 Oct 1999 00:35:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Remove C-Comments with perl
Message-Id: <MPG.127ef9a694595b4d98a12c@nntp.hpl.hp.com>
In article <38154C59.EE144DF2@de.bosch.com> on Tue, 26 Oct 1999 08:38:18
+0200, Kai Wipplinger <kai.wipplinger@de.bosch.com> says...
> I have a little problem to access the FAQs. Im on an intranet, which allows me to
> the only some newsgroups and a few www-Sites. Maybe someone could send me the FAQ
> per Mail? This would be helpfull I think.
If you have perl installed on your computer (if not, why are you asking
Perl questions?), the FAQs are on your hard disk. Try these commands:
man perlfaq
perldoc perlfaq
perldoc -q comment
<SNIP> of question following response.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Oct 1999 22:48:36 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Remove C-Comments with perl
Message-Id: <slrn81a93q.fji.abigail@alexandra.delanet.com>
Kai Wipplinger (kai.wipplinger@de.bosch.com) wrote on MMCCXLVI September
MCMXCIII in <URL:news:381462FA.2C6F7523@de.bosch.com>:
:: Hello together,
::
:: I have a problem to remove the comments of a C-File.
Did you look in the FAQ? Guess not.
:: Example:
:: // comm
That's not a C comment.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 25 Oct 1999 20:08:36 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Remove C-Comments with perl
Message-Id: <7v2dc4$gr5$1@towncrier.cc.monash.edu.au>
Kai Wipplinger <kai.wipplinger@de.bosch.com> writes:
>Do anyone know a better solution for this problem ?
The Parse::RecDescent module has a demo (demo_decomment.pl) that solves
this problem. I've appended it below. You'll need to install the module
if you want to actually run it.
Damian
-----------cut-----------cut-----------cut-----------cut-----------cut----------
#!/usr/local/bin/perl -ws
# REMOVE COMMENTS FROM C++ CODE
# ORIGINAL BY Helmut Jarausch
# EXTENDED BY Damian Conway AND Helmut Jarausch
use strict;
use Parse::RecDescent;
use vars qw/ $Grammar /;
my $parser = new Parse::RecDescent $Grammar or die "invalid grammar";
undef $/;
my $text = @ARGV ? <> : <DATA>;
my $parts = $parser->program($text) or die "malformed C program";
print "Comments\n========\n$parts->{comments}\n";
print "\nCode\n====\n$parts->{code}\n";
print "\nStrings\n=======\n", map(qq{\t"$_"\n}, @{$parts->{strings}});
BEGIN
{ $Grammar=<<'EOF';
program : <rulevar: local $WithinComment=0>
program : <rulevar: local $Comments = "">
program : <rulevar: local $Code = "">
program : <rulevar: local @Strings>
program : <skip:''> part(s)
{ { code=>$Code, comments=>$Comments, strings=>[@Strings]} }
part : comment
| C_code
| string
C_code : m{(
[^"/]+ # one or more non-delimiters
( # then (optionally)...
/ # a potential comment delimiter
[^*/] # which is not an actual delimiter
)? #
)+ # all repeated once or more
}x
{ $Code .= $item[1] }
string : m{" # a leading delimiter
(( # zero or more...
\\. # escaped anything
| # or
[^"] # anything but a delimiter
)*
)
"}x
{ $Code .= $item[1]; push @Strings, $1 }
comment : m{\s* # optional whitespace
// # comment delimiter
[^\n]* # anything except a newline
\n # then a newline
}x
{ $Code .= "\n"; $Comments .= $item[1] }
| m{\s* # optional whitespace
/\* # comment opener
(?:[^*]+|\*(?!/))* # anything except */
\*/ # comment closer
([ \t]*)? # trailing blanks or tabs
}x
{ $Code .= " "; $Comments .= $item[1] }
EOF
}
__DATA__
program test; // for decomment
// using Parse::RecDescent
int main()
{
/* this should
be removed
*/
char *cp1 = "";
char *cp2 = "cp2";
int i; // a counter
// remove this line altogehter
int k;
int more_indented; // keep indentation
int l; /* a loop
variable */
// should be completely removed
char *str = "/* ceci n'est pas un commentaire */";
return 0;
}
------------------------------
Date: Mon, 25 Oct 1999 07:18:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Remove C-Comments with perl
Message-Id: <8ae1v7.nk7.ln@magna.metronet.com>
Kai Wipplinger (kai.wipplinger@de.bosch.com) wrote:
: I have a problem to remove the comments of a C-File.
^^^^^^^
^^^^^^^
You have a problem checking the Perl FAQ before posting
to the Perl newsgroup.
: Do anyone know a better solution for this problem ?
Anybody who checks the FAQ like they're supposed to knows.
perldoc -q comment
Perl FAQ, part 6:
"How do I use a regular expression to strip C style
comments from a file?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 25 Oct 1999 14:29:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: removing newlines from a string.
Message-Id: <Pine.GSO.4.10.9910251428350.29843-100000@user2.teleport.com>
On Mon, 25 Oct 1999, Thomas Nunn wrote:
> So what does the tr/// operator do?
Do you mean, in addition to what the docs say?
> And can I use it in such a way that it leaves only one space as
> opposed to two as all the other methods I've used have?
Really, there is no substitute for looking it up.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 25 Oct 1999 21:44:48 +0100
From: Thomas Nunn <tom@tnunn.demon.co.uk>
Subject: Re: removing newlines from a string.
Message-Id: <nWLCMIAAFMF4EwVC@tnunn.demon.co.uk>
In article <5630v7.ig5.ln@magna.metronet.com>, Tad McClellan
<tadmc@metronet.com> writes
>
> ... here it comes :-)
>
>
>: This is the ideal time to use th s/// operator.
>
>
> This is the ideal time to use the tr/// operator.
>
So what does the tr/// operator do?
And can I use it in such a way that it leaves only one space as opposed
to two as all the other methods I've used have?
--
Thomas Nunn
------------------------------
Date: Mon, 25 Oct 1999 17:30:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: removing newlines from a string.
Message-Id: <s194t4cvgbb27@corp.supernews.com>
Tad McClellan (tadmc@metronet.com) wrote:
: This is the ideal time to use the tr/// operator.
:
: $string =~ tr/\n\r/ /;
Actually, you only need one ' ' in the substitution string.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: 25 Oct 1999 13:07:54 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: replacing special characters to %xx for browsers
Message-Id: <m1puy319wl.fsf@halfdome.holdit.com>
>>>>> "Marcel" == Marcel Grunauer <marcel.grunauer@lovely.net> writes:
Marcel> Says http://stein.cshl.org/WWW/software/CGI/ :
That's not CGI.pm. I don't believe anything on the web... it's
too much of a fad. :-)
Anyway, until it's in CGI.pm, I'd avoid it.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 25 Oct 1999 13:23:04 -0700
From: mbudash@wcws.com (Michael Budash)
Subject: Re: replacing special characters to %xx for browsers
Message-Id: <mbudash-2510991323040001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <m1puy319wl.fsf@halfdome.holdit.com>, merlyn@stonehenge.com
(Randal L. Schwartz) wrote:
> >>>>> "Marcel" == Marcel Grunauer <marcel.grunauer@lovely.net> writes:
>
> Marcel> Says http://stein.cshl.org/WWW/software/CGI/ :
>
> That's not CGI.pm. I don't believe anything on the web... it's
> too much of a fad. :-)
>
> Anyway, until it's in CGI.pm, I'd avoid it.
>
you may be joking (i can't tell - damned newsreaders!) ... are you? why
are stein's own docs not good enough? are they outdated? gosh, none of
mine are ;^)
--
Michael Budash ~~~~~~~~~~ mbudash@wcws.com
------------------------------
Date: 25 Oct 1999 09:11:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: replacing special characters to %xx for browsers
Message-Id: <m1aep74dzw.fsf@halfdome.holdit.com>
>>>>> "Marcel" == Marcel Grunauer <marcel.grunauer@lovely.net> writes:
>> I am wanting to convert special characters in a string to %xx where xx is
>> the ascii hex equivalent
>>
>> e.g ' ' to '%20'
Marcel> perldoc URI::Escape
Marcel> perldoc CGI
Marcel> e.g.
Marcel> use CGI;
Marcel> print CGI::escape($s);
CGI::escape is not documented, therefore it is not for you to use (it
could go away in the next CGI.pm release).
You were on the right track with URI::Escape though.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 25 Oct 1999 09:37:49 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: replacing special characters to %xx for browsers
Message-Id: <mbudash-2510990937500001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <m1aep74dzw.fsf@halfdome.holdit.com>, merlyn@stonehenge.com
(Randal L. Schwartz) wrote:
>>>>>> "Marcel" == Marcel Grunauer <marcel.grunauer@lovely.net> writes:
>
>>> I am wanting to convert special characters in a string to %xx where xx is
>>> the ascii hex equivalent
>>>
>>> e.g ' ' to '%20'
>
>Marcel> perldoc URI::Escape
>Marcel> perldoc CGI
>
>Marcel> e.g.
>
>Marcel> use CGI;
>Marcel> print CGI::escape($s);
>
>CGI::escape is not documented, therefore it is not for you to use (it
>could go away in the next CGI.pm release).
>
that's an interesting statement... it's documented (barely) at:
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
isn't that the "real thing"?
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Mon, 25 Oct 1999 17:58:22 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: replacing special characters to %xx for browsers
Message-Id: <m6cUOB4L5oEfDUwPQ7WOshIabwsN@4ax.com>
On 25 Oct 1999 09:11:15 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:
> CGI::escape is not documented, therefore it is not for you to use (it
> could go away in the next CGI.pm release).
Says http://stein.cshl.org/WWW/software/CGI/ :
Optional Utility Functions
In addition to the standard imported functions, there are a few
optional functions that you must request by name if you want them.
They were originally intended for internal use only, but are now made
available by popular request.
escape(), unescape()
use CGI qw/escape unescape/;
$q = escape('This $string contains ~wonderful~ characters');
$u = unescape($q);
These functions escape and unescape strings according to the URL hex
escape rules. For example, the space character will be converted into
the string "%20".
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 1196
**************************************