[19319] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1514 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 13 21:10:47 2001

Date: Mon, 13 Aug 2001 18:10:16 -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: <997751416-v10-i1514@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 13 Aug 2001     Volume: 10 Number: 1514

Today's topics:
        perl comments <eric@mizuhocap.com>
    Re: perl comments <Tassilo.Parseval@post.rwth-aachen.de>
    Re: perl comments <dan@nospam_dtbakerprojects.com>
    Re: perl comments (Tad McClellan)
    Re: perl comments <bart.lateur@skynet.be>
    Re: perldoc is like Greek to a beginner?? <iltzu@sci.invalid>
        regular expression people. <mwinter@nrel.nrel.gov>
    Re: regular expression people. <tony_curtis32@yahoo.com>
    Re: regular expression people. <Tassilo.Parseval@post.rwth-aachen.de>
    Re: regular expression people. <tony_curtis32@yahoo.com>
    Re: regular expression people. <Tassilo.Parseval@post.rwth-aachen.de>
    Re: regular expression people. <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Search Engine Matching Problem (Tad McClellan)
    Re: Sending  back a GIF ? (Joe Smith)
    Re: Statement modifiers?? (Eric Bohlman)
    Re: Uh Oh: URL Encode <comdog@panix.com>
    Re: Uh Oh: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: Uh Oh: URL Encode <jtjohnston@courrier.usherb.ca>
    Re: Uh Oh: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Uh Oh: URL Encode <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Uh Oh: URL Encode <tinamue@zedat.fu-berlin.de>
    Re: URL Encode <gnarinn@hotmail.com>
    Re: validate IP address <bop@mypad.com>
    Re: VIER/NEUN problem <cberry@cinenet.net>
    Re: VIER/NEUN problem <cberry@cinenet.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 13 Aug 2001 19:42:42 -0400
From: Eric <eric@mizuhocap.com>
Subject: perl comments
Message-Id: <3B7865F2.81F7FBC@mizuhocap.com>

does anyone know of a way to comment out a large area of perl code other
than placing # marks before each line?
Something akin to the C/C++
/* blah
    blah
    blah */
//would be perfect.






------------------------------

Date: Tue, 14 Aug 2001 01:48:19 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: perl comments
Message-Id: <3B786743.8050200@post.rwth-aachen.de>

Eric wrote:
> does anyone know of a way to comment out a large area of perl code other
> than placing # marks before each line?
> Something akin to the C/C++
> /* blah
>     blah
>     blah */
> //would be perfect.

'perldoc -q comment', second entry


Yet, I remember, it did not work when I tried it.
You can always write:

If (0) {

	commented out stuff

}

Yet this will not work if there are syntax errors etc. within the if-block.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 23:56:21 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: perl comments
Message-Id: <3B78695A.56FF2F65@nospam_dtbakerprojects.com>



Eric wrote:
> 
> does anyone know of a way to comment out a large area of perl code other
> than placing # marks before each line?
> Something akin to the C/C++


=pod
 blah
 blah
 blah 
=cut

will work...

D


------------------------------

Date: Mon, 13 Aug 2001 19:12:47 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl comments
Message-Id: <slrn9ngnnf.6h6.tadmc@tadmc26.august.net>

Eric <eric@mizuhocap.com> wrote:

>does anyone know of a way to comment out a large area of perl code 


Your Question is Asked Frequently.


>other
>than placing # marks before each line?


A programmer's editor should be able to insert/remove those
easily. What editor are you using?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 14 Aug 2001 00:23:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl comments
Message-Id: <6rrgnt4c2p2p9kttai6s5jngko3t5ocffa@4ax.com>

Eric wrote:

>does anyone know of a way to comment out a large area of perl code other
>than placing # marks before each line?
>Something akin to the C/C++
>/* blah
>    blah
>    blah */
>//would be perfect.

POD. See "perldoc perlpod".

=for comment

This is ignored.

=end

Or, use a text editor that is capable of inserting a "#"  in front of
every line in a selected block.

-- 
	Bart.


------------------------------

Date: 13 Aug 2001 23:33:30 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <997744111.3169@itz.pp.sci.fi>

In article <MPG.15db2624813ad68989719@news.edmonton.telusplanet.net>, Carlos C. Gonzalez wrote:
>In article <GHr7IM.43I@presby.edu>, Jon Bell at jtbell@presby.edu says...
>
>> Perldoc is a _reference_, not a textbook or a tutorial.  Using perldoc as 
>> your primary source for learning Perl is like using a dictionary and a 
>> grammar as primary references for learning English.
>
>I agree.  I guess it's tough when I am directed to a reference work as 
>such when I need to be tutored in how to do something that would best be 
>discovered in a tutorial or textbook.  

Indeed.  But we tend to assume that people posting here know enough
about Perl and programming in general to understand the reference
material -- and in any case, just saying "Read a book about Perl."
doesn't sound very helpful unless it's clear that this is really just
what is needed.

Actually, the perldocs do contain even the introductory material that
teaches the basics of Perl in newbie-understandable language.  Those
include perlsyn, perlop (at least the beginning), perlfunc, perlrun,
perlref, perlobj and all the various perl*tut documentation pages.

The problem is simply finding the right starting place.  For example,
the book "Programming Perl" shares much of its content with the docs.
What makes it useful as an introduction to Perl is that the content is
presented in a sensible order, and with extra glue material to make it
all fit more or less seamlessly together.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



------------------------------

Date: Mon, 13 Aug 2001 16:35:03 -0600
From: Mark Winter <mwinter@nrel.nrel.gov>
Subject: regular expression people.
Message-Id: <3B785617.27295645@nrel.nrel.gov>

Hello

I have a script in perl that I want to send the sudo command a password.

like:

  $out = ` sudo chown me file_name` ;

In unix the sudo comand takes a password  so I try thing like:

 $out  = ` sudo chown me file_name < ./pwd  ` ;

where pwd is the password. or

 $out = ' sudo chown me file_name |  cat ./pwd ' ;

but neither work.  How do I do this in a script.

Thank you very much.






------------------------------

Date: 13 Aug 2001 17:58:56 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: regular expression people.
Message-Id: <87snevo9cf.fsf@limey.hpcc.uh.edu>

>> On Mon, 13 Aug 2001 16:35:03 -0600,
>> Mark Winter <mwinter@nrel.nrel.gov> said:

> Hello I have a script in perl that I want to send the
> sudo command a password.

> like:

>  $out = ` sudo chown me file_name < ./pwd ` ;

> but neither work.  How do I do this in a script.

It doesn't read from stdin.  You can use "expect" to do
this sort of thing.

  http://search.cpan.org/doc/RGIERSIG/Expect-1.11/Expect.pod

(Also "sudo" can be told not to require a password)

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


------------------------------

Date: Tue, 14 Aug 2001 01:03:01 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: regular expression people.
Message-Id: <3B785CA5.5010505@post.rwth-aachen.de>

Tony Curtis wrote:
>>>On Mon, 13 Aug 2001 16:35:03 -0600,
>>>Mark Winter <mwinter@nrel.nrel.gov> said:
>>>
> 
>>Hello I have a script in perl that I want to send the
>>sudo command a password.
>>
> 
>>like:
>>
> 
>> $out = ` sudo chown me file_name < ./pwd ` ;
>>
> 
>>but neither work.  How do I do this in a script.
>>
> 
> It doesn't read from stdin.  You can use "expect" to do
> this sort of thing.

Are you sure?  According to the manpage:

-S  The -S (stdin) option causes sudo to read the password
     from standard input instead of the terminal device.

Unfortunately I can't try it within the next four or so minutes. Just 
invoked a sudo a few seconds ago and now wait for timeout. ;-)

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: 13 Aug 2001 18:07:49 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: regular expression people.
Message-Id: <87ofpjo8xm.fsf@limey.hpcc.uh.edu>

>> On Tue, 14 Aug 2001 01:03:01 +0200,
>> Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> said:

> Tony Curtis wrote:
>> It doesn't read from stdin.  You can use "expect" to do
>> this sort of thing.

> Are you sure?  According to the manpage:

> -S The -S (stdin) option causes sudo to read the
> password from standard input instead of the terminal
> device.

Well, that'll teach me to post while still recovering from
jetlag won't it? :-)  I was thinking of the standard
"passwd" program.

To the OP: terrible subject line.

t
-- 
Beep beep!  Out of my way, I'm a motorist!


------------------------------

Date: Tue, 14 Aug 2001 01:12:41 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: regular expression people.
Message-Id: <3B785EE9.1050604@post.rwth-aachen.de>

Tony Curtis wrote:

> Well, that'll teach me to post while still recovering from
> jetlag won't it? :-)  I was thinking of the standard
> "passwd" program.
> 
> To the OP: terrible subject line.

Indeed. And a good way of distracting from your jetlag-posting. ;-)
Ah, don't worry...my fingers itched to write the same as you did...but 
then I remembered that it is hard to get away with mistakes in this 
group so I reassured myself in the docs.-

:-D


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Tue, 14 Aug 2001 01:38:29 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: regular expression people.
Message-Id: <3B7864F5.1030103@post.rwth-aachen.de>

Mark Winter wrote:
> Hello
> 
> I have a script in perl that I want to send the sudo command a password.
> 
> like:
> 
>   $out = ` sudo chown me file_name` ;
> 
> In unix the sudo comand takes a password  so I try thing like:
> 
>  $out  = ` sudo chown me file_name < ./pwd  ` ;
> 
> where pwd is the password. or
> 
>  $out = ' sudo chown me file_name |  cat ./pwd ' ;
> 
> but neither work.  How do I do this in a script.

Now, that my timeout has finally happened:

$out = `yes pwd | sudo -S chown me file_name`;

In case you wonder: 'yes ARG' will infinitely print ARG to stdout. It is 
useful for these kind of things.

Tassilo




-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Mon, 13 Aug 2001 18:15:50 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Search Engine Matching Problem
Message-Id: <slrn9ngkcm.6cb.tadmc@tadmc26.august.net>

Stearnsie <ccstearns@ucsd.edu> wrote:

>OK, I really have no idea how to use Perl programming, but I managed
>to find a code on the internet 


It is worth less than you paid for it  :-(


>which I modified and used for my own
>search engine, but my problem is that when I do the search... say for
>an author with a year, it does not search the database for those
>fields together, but rather it prints All the results with that
>author, and then all the results with that year.
>So here is my code, and it may be something small that I have to
>change I'm thinking. But I would be very thankful for any help from
>anyone.
>Thanks.
>
>
>
>#!c:\unzipped\indigoperl-5_6\bin\perl


   #!c:\unzipped\indigoperl-5_6\bin\perl -w
   use strict;


Good programs will enable warnings and strictures. If those are
not there, then you have found Bad Code, keep looking.


>require 'cgi-lib.pl';


That is how it was done 7 years ago!

Windows 3.1 was the popular operating system back then...

If it mentions 'cgi-lib.pl', keep looking.

Nowadays, good code uses the CGI.pm module instead.


># read and parse data file
>$data="address.data";
>
>open(DATA,"$data") || die "Can't open $data: $!\n</BODY></HTML>\n";
>while(<DATA>) {
>	chop;	# delete trailing \n


That is 7-year old style too.

   chomp;

is what folks use in this era.


>	if (/^\s*$/) {
>		# break between records
>		if ($match) {
>			# if anything matched, print the whole record
                             ^^^^^^^^
                             ^^^^^^^^


Looks like you want some different logic right around here 
somewhere (if you weren't going to throw this in the bit
bucket).


>sub printrecord {
>	local($buf) = @_;


You should always prefer my() over local(), except when you can't.

Here you can (now, but you couldn't 7 years ago when this was written...)


>	print "<P>\n$buf<P>\n";
>}


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 14 Aug 2001 00:02:11 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Sending  back a GIF ?
Message-Id: <9l9pq3$2spt$1@nntp1.ba.best.com>

In article <3B6D3DB3.9F6BA487@home.com>, Ian Judge  <ij1968@home.com> wrote:
>
>I have coded the html so it accesses the cgi fine. My problem is when I
>try to send back an image. I get a broken image/image not found symbol.
>
>here is the code i am using:
>
>$file = "a.gif";
>print "Content-Type: image/gif\n\n";
>open(LOGO,"$file");
>print <LOGO>;
>close(LOGO);

I see two problems.
  1) Your CGI program might not be running in the directory you think it is.
  2) You should treat binmode() as being mandatory for binary files.

$file = "/absolute/pathname/to/a.gif";
if (open LOGO,$file) {
  print "Content-type: image/gif\n\n";
} else {
  print "Content-type: text/plain\n\n Program error: $!\n";
  exit;			# Note: $file not in message; need-to-know basis
}
binmode LOGO;		# Always do this for reading binary files
binmode STDOUT;		# Do this for writing binary data
print <LOGO>;		# Read in entire file, send it out all at once
close LOGO;
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


------------------------------

Date: 13 Aug 2001 22:48:25 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Statement modifiers??
Message-Id: <9l9lfp$n9e$1@bob.news.rcn.net>

ctcgag@hotmail.com wrote:
> What's more, always add "or die" to the ends of things that can fail in
> general, even if they can't conceivably fail in the local logic.

> m/Foo(.*)Bar/ or die;
> do_something($1);

> Yes, even if you already made sure that Foo and Bar are there and in
> order, still add the or die.

That's a variant on the technique known as "assertions."  Some languages 
have built-in mechanisms for making assertions and verifying them (often 
allowing you to turn on assertion-checking during development and testing 
and turn it off in production, without having to remove the assertion 
code.

Most regulars here would assert (hehe) that you should *never* use $digit 
variables unless the regex that (should have) set them is part of a 
conditional.



------------------------------

Date: Mon, 13 Aug 2001 18:14:04 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Uh Oh: URL Encode
Message-Id: <comdog-D759F7.18140413082001@news.panix.com>

In article <bafgntkd4fv5pntj7k9j9dqducdtl453h7@4ax.com>, Bart Lateur 
<bart.lateur@skynet.be> wrote:

> It DOES NOT escape the most dangerous characters "=" and "&". It's a
> know bug, or feature, depending on what side you're on.

i think you want to say "it does not, by default, escape all
of the special characters that matter to the CGI".  after all, 
HTTP is only one scheme out of many. :)

-- 
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



------------------------------

Date: Mon, 13 Aug 2001 22:59:33 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B785A04.21A3AAFB@courrier.usherb.ca>

> print <<EOF;
> <html><head>
> etc...
> EOF

Yep, but problem is $in{'blahblah'} and other plain $strings display as typed; won't
display their values. Pain in the ass, but ... :)



------------------------------

Date: Mon, 13 Aug 2001 23:02:06 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B785A9D.66BC1180@courrier.usherb.ca>

> Well, rather a sort of unpleasant feature. But uri_escape takes a second
> argument. It is a character-class which overrides the characters usually
> escaped. So with that, one could force uri_escape to also escape & and =.

Does this include escaping &?%=!+ etc. ?

$in{'P1OC2Q1'} = uri_escape($in{'P1OC2Q1'}, "^A-Za-z");

If not, how so?



------------------------------

Date: Tue, 14 Aug 2001 01:05:11 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B785D27.7050500@post.rwth-aachen.de>

jtjohnston wrote:
>>print <<EOF;
>><html><head>
>>etc...
>>EOF
>>
> 
> Yep, but problem is $in{'blahblah'} and other plain $strings display as typed; won't
> display their values. Pain in the ass, but ... :)
> 
> 

No, variables are being interpolated in HERE-docs.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: Tue, 14 Aug 2001 01:08:03 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <3B785DD3.9070508@post.rwth-aachen.de>

jtjohnston wrote:
>>Well, rather a sort of unpleasant feature. But uri_escape takes a second
>>argument. It is a character-class which overrides the characters usually
>>escaped. So with that, one could force uri_escape to also escape & and =.
>>
> 
> Does this include escaping &?%=!+ etc. ?

Here is my very special Easter-Egg hunt for you:
What happens if you try it? ;-)

But don't worry, they will be escaped. The second argument specifies a 
class of characters that should be escaped. As "^A-Za-z" is the negation 
of all letters, all non-letters will be escaped. I carefully tested it 
before. :-)

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: 13 Aug 2001 23:18:45 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Uh Oh: URL Encode
Message-Id: <9l9n8l$89ie8$1@fu-berlin.de>

jtjohnston <jtjohnston@courrier.usherb.ca> wrote:
>> print <<EOF;
>> <html><head>
>> etc...
>> EOF

> Yep, but problem is $in{'blahblah'} and other plain $strings display as typed; won't
> display their values. Pain in the ass, but ... :)

what do you mean with "won't display their values"?

perl -e'
$in{blahblah}=42;print <<EOF;
<html>$in{blahblah}</html>
EOF
'
<html>42</html>

regards, tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception
---   Warning: content of homepage hopelessly out-dated   ---


------------------------------

Date: Mon, 13 Aug 2001 22:53:44 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: URL Encode
Message-Id: <997743224.65706066833809.gnarinn@hotmail.com>

In article <3B78100C.51D4FCD@courrier.usherb.ca>,
jtjohnston  <jtjohnston@courrier.usherb.ca> wrote:
>> use URI::Escape
>>
>
>Please, do you have an example?

man, you need to learn to use perldoc

$ perldoc URI::Escape

  NAME

  URI::Escape - Escape and unescape unsafe characters

  SYNOPSIS

   use URI::Escape;
   $safe = uri_escape("10% is enough\n");
   $verysafe = uri_escape("foo", "\0-\377");
   $str  = uri_unescape($safe);
    
  DESCRIPTION
    
  This module provides functions to escape and unescape URI strings as
  defined by RFC 2396.  URIs consist of a restricted set of characters,
  ....



the CGI module also provides escaping functionality:

 use CGI;
 $encoded=CGI::escape($plain);
 
 $plain=CGI::unescape($encoded);


gnari


------------------------------

Date: Mon, 13 Aug 2001 20:50:26 -0400
From: "flash" <bop@mypad.com>
Subject: Re: validate IP address
Message-Id: <oy_d7.14788$zg6.1395653@news20.bellglobal.com>

but 324156926 is not an ip address, it is one that has been changed into a
new form.

"John Stanley" <stanley@skyking.OCE.ORST.EDU> wrote in message
news:9l9b25$264$1@news.orst.edu...
> In article <9knjf5$2ns$1@suaar1aa.prod.compuserve.com>,
> Richard A. Evans <EvR@compuserve.com> wrote:
> >> You're missing that the from xxx.xxx.xxx.xx is not the only valid form
for
> >> ip addresses.
> >
> >I was responding to the comments that said:
> >
> >If you mean valid as in "correct number of numbers", a short regular
> >expression will do the trick:
> >
> >  $ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
> >  # make sure you have four digit sequences 1-3 numbers each, separated
by
> >periods,
> >  # and that the IP takes up the entire variable
>
> 127.1 has "the correct number of numbers". 324156926 has "the correct
> number of numbers".  Any test that results in 127.1 being rejected is
> incorrect.
>




------------------------------

Date: Mon, 13 Aug 2001 23:05:55 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: VIER/NEUN problem
Message-Id: <Xns90FCA3C10E077cberrycinenetnet1@207.126.101.92>

gbacon@HiWAAY.net (Greg Bacon) wrote in 
news:tngfjsjdbla9a@corp.supernews.com:

> [Note: this was also posted to fwp.]
> 
>      VIER and NEUN represent 4-digit squares, each letter denoting a
>      distinct digit. You are asked to find the value of each, given
>      the further requirement that each uniquely determines the
>      other.
> 
>      The "further requirement" means that of the numerous pairs of
>      answers, choose the one in which each number only appears once
>      in all of the pairs.

Borrowing a very cool regex from Greg Bacon, and simplifying a great 
deal, how about:

#!/usr/bin/perl -w
# vier - solve VIER/NEUN puzzle
# Craig Berry (20010813)

use strict;

my @squares = map { sprintf '%04d', $_ ** 2 } 1 .. 99;
my $expr = qr/
              ^

              (.)                     # V
              ((?!\1)             .)  # I
              ((?!\1|\2)          .)  # E
              ((?!\1|\2|\3)       .)  # R

              ((?!\1|\2|\3|\4)    .)  # N
              \3                      # E
              ((?!\1|\2|\3|\4|\5) .)  # U
              \5                      # N

              $
             /x;


foreach my $vier (@squares) {
  my @neuns;

  foreach my $neun (@squares) {
    push @neuns, $neun if "$vier$neun" =~ /$expr/o;
  }

  if (@neuns == 1) {
    print "VIER = $vier\nNEUN = $neuns[0]\n";
    exit;
  }
}

warn "Hey, we should never get here!\n";

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



------------------------------

Date: Mon, 13 Aug 2001 23:53:25 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: VIER/NEUN problem
Message-Id: <Xns90FCABCDE2082cberrycinenetnet1@207.126.101.92>

Craig Berry <cberry@cinenet.net> wrote in 
news:Xns90FCA3C10E077cberrycinenetnet1@207.126.101.92:

Actually, the processing loop from my previous post can be further optimized 
like this:

VIER_LOOP:
foreach my $vier (@squares) {
  my $okNeun = 0;

  foreach my $neun (@squares) {
    if ("$vier$neun" =~ /$expr/o) {
      next VIER_LOOP if $okNeun;
      $okNeun = $neun;
    }
  }

  if ($okNeun) {
    print "VIER = $vier\nNEUN = $okNeun\n";
    exit;
  }
}

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



------------------------------

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.  

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 1514
***************************************


home help back first fref pref prev next nref lref last post