[7591] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1217 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 23 02:07:12 1997

Date: Wed, 22 Oct 97 23:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 22 Oct 1997     Volume: 8 Number: 1217

Today's topics:
     Re: [Reposted due to Enlow UCE cancel]: Perl interface  (Martien Verbruggen)
     Auto-Run a Perl Script on start-up <jrcruto@bechtel.com>
     Re: Data driven code...? (Ilya Zakharevich)
     Re: E-Mail by perl... <sysop@scbbs.com>
     Re: help: perl and SMTP <sysop@scbbs.com>
     Re: Is there/will there be a decent way to do constants <rootbeer@teleport.com>
     LOOKING FOR PERL GIF CODE <73053.2400@CompuServe.COM>
     OR v. Randal: Employees have no 1st Amendment Rights (Jeffrey Kegler)
     Re: OR v. Randal: Employees have no 1st Amendment Right <nenglish@geo.Arizona.EDU>
     Perl for Windows 95 (Cheerio)
     Re: Perl for Windows 95 (Jon Wright)
     Re: Precompiling PERL Scripts..... <rootbeer@teleport.com>
     Scalar Variable Help (Vinny)
     Re: Scalar Variable Help (brian d foy)
     Re: select($rout,undef,undef,undef) not working (always <rootbeer@teleport.com>
     Re: sorting on primary and secondary key (Mike Heins)
     URL Encoding (Ravi Agarwal)
     Re: URL Encoding (brian d foy)
     Re: variable checking (Martien Verbruggen)
     Re: Why wont it work on the Web ? <rootbeer@teleport.com>
     Re: XS question:  string parameter (allocation) <owt1@cornell.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 23 Oct 1997 02:31:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: [Reposted due to Enlow UCE cancel]: Perl interface to Sun NIS+?
Message-Id: <62mcu4$8rj$1@comdyn.comdyn.com.au>

In article <REPOST-10700.673431396484.62gvd4$pud$1@enyo.uwa.edu.au>,
	tim.villa@uwa.edu.au (Tim Villa) writes:

> Not sure if such a beast exists but are there any Perl libraries around for 
> accessing Solaris NIS+ tables without having to use system() or ``?  I'm 
> trying to speed up some routines that talk to the NIS+ a lot.

http://www.perl.com/CPAN/modules/00modlist.long.html

look for Net::NISPlus

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Thu, 23 Oct 1997 02:26:25 GMT
From: "Jay Cruto" <jrcruto@bechtel.com>
Subject: Auto-Run a Perl Script on start-up
Message-Id: <01bcdf59$50001f80$5c100193@sinw0191.bechtel.com>

I want to run a perl script when I initially load up a page.  How do I do
that? Do I need to setup SSI?  anybody has some info how to setup SSI on
Microsoft's Personal Web Server?

Thanks for your help...

Jay Cruto
jrcruto@bechtel.com


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

Date: 23 Oct 1997 02:16:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Data driven code...?
Message-Id: <62mc1f$j4f$1@agate.berkeley.edu>

In article <344E7A31.1EE2@ozemail.com.au>,
Ron Savage  <rpsavage@ozemail.com.au> wrote:
> Pierre Fortin wrote:
> > 
> > Hi,
> > 
> > I'm trying to write code to read lines from a file and invoke specific
> > subroutines based on the input data (i.e., $data = "foo", so invoke:[snip]
> 
> Alternately, use a Perl Finite State Machine module. Basically you specify a regular expression and a sub 
> name, and when your input matches the RE, the sub is called.

Note that the updated RE engine (hopefully, soon to be available to
uneducated masses as well ;-) allows to call an arbitrary code *from*
a RE.  Thus one does not need to write any module, you just do

	/foo (?{ seen_foo($_) }) | bar (?{ $bar_count++  }) /x

Ilya


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

Date: Wed, 22 Oct 1997 19:28:00 -0700
From: Ron Parker <sysop@scbbs.com>
Subject: Re: E-Mail by perl...
Message-Id: <344EB62F.CD4EE91B@scbbs.com>

I don't know the answer to this, but I have an add-on question I think is
related:  I am trying to code a program to send an e-mail with a gif which will
display as soon as the e-mail is read as part of the email  (assuming the e-mail
reader supports html coding).  I've tried a simple <img src...>  with Netscape 4
mail and it doesn't work.  Can this be done?  If so, how.

Also interested in attachment question.

Sribatsa Das wrote:

> Folks,
>
> I am in the process of writing a perl program to send mails through my SMPT.
> I'm able to send the message with subject and attachment with subject.  I
> refered to RFC 2183.  I'm not able to send a message with a subject, body
> and attachment.
>
> Have any of you attempted this?  If you have any hints, I would appreciate
> to have that.
>
> Thanks.
>
> ---Sri



--

 Ron Parker
 TradePort LA / Tradewinds / SCBBS

 www.intl-trade.com
 www.tradepointla.org
 www.scbbs.com




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

Date: Wed, 22 Oct 1997 19:30:13 -0700
From: Ron Parker <sysop@scbbs.com>
To: Russ Allbery <rra@stanford.edu>
Subject: Re: help: perl and SMTP
Message-Id: <344EB6B4.D512E779@scbbs.com>

Yep, thats simple:  But can you include an attachment at the command line, or
using perl?  If so, can you point me to a document where I can figure out how
to do this?  Thanks.

Russ Allbery wrote:

> dan vinnola <dvinnola@wolonline.net> writes:
>
> > I am trying to create a script that will read a file and build an email
> > to send to an SMTP host.  Has anyone done that?
>
> What's hard about this?
>
> open (SENDMAIL, '| /usr/lib/sendmail -t -oi -oem')
>     or die "can't fork sendmail: $!\n";
> open (FILE, 'some.file') or die "can't open file: $!\n";
> print SENDMAIL $_ while (<FILE>);
> close SENDMAIL;
> die "sendmail exited with status $?\n" unless ($? == 0);
> close FILE;
>
> If you're using a non-Unix OS, you'll probably want to get a sendmail
> replacement, or you can look at libnet which has a Net::SMTP module.
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print



--

 Ron Parker
 TradePort LA / Tradewinds / SCBBS

 www.intl-trade.com
 www.tradepointla.org
 www.scbbs.com




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

Date: Wed, 22 Oct 1997 19:00:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gerben Wierda <G.C.Th.Wierda@AWT.nl>
Subject: Re: Is there/will there be a decent way to do constants in perl?
Message-Id: <Pine.GSO.3.96.971022185831.7008K-100000@usertest.teleport.com>

On Wed, 22 Oct 1997, Gerben Wierda wrote:

> as the use constant pragma gets me into all kinds of trouble with strict
> subs,

It shouldn't. But have you sent a bug report to the author of constant.pm
about your troubles? :-)

> Why cannot perl get a constant reserved word in the syntax with the 
> expected effect?

Not everybody expects the same effects. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 22 Oct 1997 22:10:36 -0400
From: Bryce R Hall <73053.2400@CompuServe.COM>
Subject: LOOKING FOR PERL GIF CODE
Message-Id: <#812aj138GA.313@nih2naac.prod2.compuserve.com>

Hi I am looking for a PERL routine to translate a bit map into a 
GIF file.   Can someone give me a clue on where to look?

Bryce

-- 
MainTour - Travel / Recreation / Entertainment	
http://www.maintour.com	
Your ticket to explore the real world!



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

Date: 23 Oct 1997 02:58:43 GMT
From: cybersalem@algorists.com (Jeffrey Kegler)
Subject: OR v. Randal: Employees have no 1st Amendment Rights
Message-Id: <62meh3$ogg$1@samba.rahul.net>


                    Letter from Cybersalem 11
         Oregon Employees have No First Amendment Rights
                        by Jeffrey Kegler


Say "Take this job and shove it!" to your boss and go to jail?
So says Washington County Circuit Court Judge Gayle Nachtigal's
ruling in Oregon v. Randal Schwartz:

  "First Amendment is a personal right.  It has nothing to do
  with my communication on business.  I have no First Amendment
  right to communicate beyond what my employer wants me to
  communicate, as far as my job is concerned.  That's not a
  First Amendment right.  First Amendment is personal to me or
  my company if it were an entity.  It's that company may have
  some kind of a First Amendment right.  But the First
  Amendment right is personal." [1]

Let's be clear -- what is at issue is not right of Intel
(Randal's accuser), or any other employer, to dismiss.  These
remarks come from a hearing on criminal charges brought by the
State of Oregon against Randal Schwartz.  The question is "Is it
a crime to speak your mind?"  Nachtigal's answer is: At the
workplace, yes.

By a personal right, Judge Nachtigal means one valid only outside
work, not an inalienable right.  Indeed, Judge Nachtigal holds
First Amendment rights to be so easily alienable they disappear
silently when you walk in the workplace door [2].  After that, "I
have no First Amendment right to communicate beyond what my
employer wants me to communicate".  Telling the boss off, or
saying anything else he does not want you to say can be a crime.
If done by computer, it is.

Let's witness a pair of crimes.  David Allen Coe:

  The Foreman is a regular S.O.B.
  And the night boss, he's a fool
  He got himself a brand new flattop haircut
  Lord, he really thinks that's cool
  One of these days I'm gonna blow my top
  And there's gonna be hell to pay
  I can't wait to see their faces
  When I get the nerve to say
  Take this job and shove it
  I ain't workin' here no more [3]

And Bob Dylan:

  He hands you a nickel
  He hands you a dime
  He asks with a grin
  If you're havin' a good time
  Then he fines you every time you slam the door
  No, I ain't gonna work for Maggie's brother no more [4]

A major part of the appeal of lyrics like Coe's and Dylan's is
their celebration of our system of individual rights and limited
authority, where the subordinate at work is equal as a citizen.
The subordinate enjoys the right to tell the boss exactly what he
thinks of him, if he is willing to live without the job.  It's a
system that gives legitimacy to authority and dignity to service,
and one in which both take deserved pride.

With Nachtigal's decision, that pride must fall.  Now rights in
Oregon end at the workplace door, but the employer's ability to
punish you for exercising them follows you back out.

To deal with employees who tell the boss to go to hell (or that
his haircut is not particularly flattering), a company can quite
reasonably have a policy which demands civil and respectful
communication through all media, including email.  Indeed, to
preserve a sane and productive atmosphere for other employees,
the employer needs to respond to these who use the workplace to
vent spleen.  Firing is a very legitimate measure in this regard.

Similarly, the boss can curb your attempts to convert your co-
workers to your religion.  If you violate his policy, he can fire
you.  But, under the First Amendment, the D.A. cannot send you to
jail for practicing your religion.

Telling the boss off, using the workplace as a pulpit, or writing
a report that implies the Security Department does not know what
it is doing are all activities that an employer can and needs to
limit.  They are also all protected against criminal prosecution
by the First Amendment.  And when done on a computer in violation
of workplace rules, they are all criminalized by the Oregon
Computer Crime Statute.

Laws so broad that they criminalize the exercise of First
Amendment rights have long been recognized by the courts as
overbroad and overturned for that reason [5].  So the First
Amendment was a fatal threat to Randal's prosecution, until Judge
Nachtigal neatly disposed of the problem.  People at the
workplace have no First Amendment rights.  Hence the law cannot
infringe any.  It definitely solves the problem.

It reminds one of the neat solution Justice Taney came up with
when he saw that the Supreme Court was going to be the
battleground for one dangerous, bitter, divisive dispute after
another over slavery.  He wrote a clear cut opinion for the court
which disposed of all future such difficulty, basing that opinion
on tradition that blacks "had no rights which a white man was
bound to recognize [6]."  Randal and anyone else at the workplace
have no rights that Intel or Oregon feel they need recognize.

The repeal of Randal's rights here is no technicality [7].  He
did not cause or intend harm.  Others committed worse security
infractions and were not only not charged with a crime, but not
punished or reprimanded by Intel.  The distinction between Randal
and those others is that Randal found problems in Intel's network
security and was working on a report that said things that Intel
Security did not want to hear or have heard.

An Oregon appeals court might overturn this repeal of the First
Amendment, but so far the first priority in the Oregon justice
system has been to please Intel, Randal's accuser and Oregon's
largest employer.  Judges, police and D.A.'s have done what they
thought Intel would want with monotonous reliability.  For the
the Appeals Court to do any different would be a judicial 180 on
a dime.  Nonetheless, it remains possible.

For Randal, the practical effect of a reversal would be limited.
Neither his "restitution" to Intel nor any other part of his
punishment was stayed pending appeal, so all in all Randal's
expenses now reach nearly $250,000.  Doing what it takes to get
to the first level of appeal is a severe punishment in itself.

And what of someone who does not have a quarter million to buy a
chance that the Appeals Court will make the academic point that
he has First Amendment rights?  This has to be the majority of
us.  Especially after being branded as a triple felon in the eyes
of prospective clients and employers, a quick quarter million is
hard to lay your hands on [8].  An appeals court reversal would
just put an asterisk on the basic legal truth.  Nobody working in
Oregon can expect any benefit from a claim to have First
Amendment rights.

To say Oregon employees have no First Amendment rights
understates the situation.  Nothing in Nachtigal's logic
differentiates First Amendment rights from others [9].  Nor is
her ruling limited to employees -- Randal was a contractor, so
her ruling clearly applies in other situations.  Also, nothing in
her ruling depends on law unique to Oregon.

===========================================================

The Letters from Cybersalem are among the material at the "Intel
v. Randal Schwartz" Web site:
<URL:http://www.rahul.net/jeffrey/ovs/>.  The "Friends of Randal
Schwartz Web" site archives the material on all sides of this
issue, including the trial transcripts:
<URL:http://www.lightlink.com/fors>.

Of the many opportunities to do something, two head the list:

1.) To sign a letter objecting to Intel's role in this sorry
matter, see <URL:http://www.rahul.net/jeffrey/ovs/#todo>.

2.) To get an auto-reply giving Randal's own statement, and
discussing how you can contribute to his Legal Defense Fund, send
an empty message to <URL:mailto:fund@stonehenge.com>

Permission is granted to freely copy the Cybersalem Letters in
electronic form, or to print them for personal use.

===========================================================

Note 1:  Judge Nachtigal speaking in the demurrer.  Tr. 7-1-94,
<URL:http://www.lightlink.com/fors/court/demur.txt>, page 22,
line 5 to 14.  The "demurrer", in this context, is the defense
motion challenging the validity of the indictment on purely legal
grounds, and the term also is used to mean the hearing on that
motion.

Note 2:  My references to the "workplace door" are figurative.
Nachtigal's ruling applies to persons who are engaged in
providing services, whether at home or elsewhere.

Note 3:  Lyrics to "Take this Job and Shove It" by David Allen
Coe.

Note 4:  Lyrics to "Maggie's Farm" by Bob Dylan.

Note 5:  A law can also be overturned for vagueness, which is
different from overbreadth.  In this letter I do not deal with
the issue of the law's vagueness.

"An 'overbroad' law, as that term has been developed by the
United States Supreme Court, is not vague, or need not be.  Its
vice is not failure to communicate.  Its vice may be clarity.
For a law is overbroad to the extent that it announces a
prohibition that reaches conduct which may not be prohibited.  A
legislature can make a law as 'broad' and inclusive as it chooses
unless it reaches into constitutionally protected ground.  The
clearer an 'overbroad' statute is, the harder it is to confine it
by interpretation within its constitutionally permissible
borders."  State v. Blocker, 291 Or 255, 261, 630 P2d 824 (1981)
and ibid, at 293 Or 410, cited from Defendant's Memorandum of Law
supporting Demurrer in Oregon v. Schwartz.

Note 6:  U.S. Supreme Court, Scott v. Sanford.

Note 7:  Whether Randal was actually engaged in conduct protected
by the First Amendment was not relevant to the demurrer.  It is
not Randal's conduct, but the constitutionality of the law that
was at issue.  The law must fall if it could be used to punish
behavior protected by the First Amendment.  What Randal actually
did or was accused of doing was not at issue.  If his behavior
was actually criminal under some constitutionally valid statute,
he could be charged under that statute.

Note 8:  Randal's local newspaper, the _Oregonian_, did not wait
for the verdict to announce his guilt.  See CS10
(<URL:http://www.rahul.net/jeffrey/ovs/cs10.html>).

Note 9:  Indeed, though it hardly seems possible, Judge Nachtigal
disposes of Randal's 14th Amendment rights in an even more
definitive manner.


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

Date: Wed, 22 Oct 1997 22:29:23 -0700
From: "Nathanael T. Brooks-English" <nenglish@geo.Arizona.EDU>
To: Jeffrey Kegler <cybersalem@algorists.com>
Subject: Re: OR v. Randal: Employees have no 1st Amendment Rights
Message-Id: <Pine.SOL.3.96.971022222713.26200A-100000@eqsun.geo.Arizona.EDU>

To whom it may concern,
	I was very interested to read the post concerning Mr. Randall.
Please elaborate on the facts of the case as you know them.  Was he trying
to crack a security network, or did he just write a report listing the
weaknesses of the Intel Security.  

Thank you,
Nathan English

Nathan English, Student
Dept. of Geosciences
University of Arizona
nenglish@geo.arizona.edu




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

Date: Thu, 23 Oct 1997 02:17:01 GMT
From: cheerio@flash.net (Cheerio)
Subject: Perl for Windows 95
Message-Id: <344eb33d.67520527@news.flash.net>

I am a newbie to Perl and i have been attempting to create small
programs that may be useful on a shell account, i use windows 95
as my os and i was wondering if there was a type of perl for win95.
One that can run commands .etc and i dont mean cgi. Well if there
is can someone tell me where to get it .etc and if it is different
from the linux version? well thanks for your time
				-Cheerio


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

Date: Thu, 23 Oct 1997 03:07:20 GMT
From: deadwright@worldnet.att.net (Jon Wright)
Subject: Re: Perl for Windows 95
Message-Id: <62mfon$7gd@bgtnsc01.worldnet.att.net>

On Thu, 23 Oct 1997 02:17:01 GMT, cheerio@flash.net (Cheerio) wrote:

You can find Perl for Win32 (it's free) at  http://www.activeware.com/


And http://www.geocities.com/SiliconValley/Park/8312/  has some good
information on installing and using the Win32 port.

>I am a newbie to Perl and i have been attempting to create small
>programs that may be useful on a shell account, i use windows 95
>as my os and i was wondering if there was a type of perl for win95.




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

Date: Wed, 22 Oct 1997 19:01:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard Secor <rich@imedianet.com>
Subject: Re: Precompiling PERL Scripts.....
Message-Id: <Pine.GSO.3.96.971022190055.7008M-100000@usertest.teleport.com>

On 22 Oct 1997, Richard Secor wrote:

> how do you compile PERL scripts into executables so they run faster

You read the FAQ. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 23 Oct 1997 03:46:52 GMT
From: cvinny@mailexcite.com (Vinny)
Subject: Scalar Variable Help
Message-Id: <cvinny-0101040154400001@cmac02.cause.org>

Help:

I am having trouble finding the syntax for naming a variable using a variable. 
Here is the simple example

$i = '6'
$M6 = "Got It"
Print "$M$i";

How do you combine $M with $i

Thanks

Christopher
cvinall@cause.org


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

Date: Thu, 23 Oct 1997 01:14:46 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Scalar Variable Help
Message-Id: <comdog-ya02408000R2310970114460001@news.panix.com>

In article <cvinny-0101040154400001@cmac02.cause.org>, cvinny@mailexcite.com (Vinny) wrote:

>I am having trouble finding the syntax for naming a variable using a variable. 
>Here is the simple example

your simple example seems to have many syntax errors.  it's best to 
include the actual code rather than typing it in directly :)

>$i = '6'
>$M6 = "Got It"
>Print "$M$i";
>
>How do you combine $M with $i

   #!/usr/bin/perl
   
   $i = '6';
   $M6 = "Got It";
   print qq|${"M$i"}\n|;
   
   __END__

   Got It


for more fun with this sort of thing, see Advanced Perl Programming [1]

[1] 
Advanced Perl Programming
Sriram Srinivasan
ISBN 1-56592-220-4
<http://www.oreilly.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Wed, 22 Oct 1997 18:57:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Turner <jdturner@intrex.net>
Subject: Re: select($rout,undef,undef,undef) not working (always returns)
Message-Id: <Pine.GSO.3.96.971022185541.7008I-100000@usertest.teleport.com>

On Wed, 22 Oct 1997, John Turner wrote:

> I am trying to write a script that tails a files 

Have you seen the discussion in the FAQ about doing this? It's in section
five. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 23 Oct 1997 02:40:26 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: sorting on primary and secondary key
Message-Id: <62mdeq$no7$1@vixen.cso.uiuc.edu>

Kuntal M Daftary (daftary@cisco.com) wrote:
: hi fellas!
: 
: i had a queer problem.
: 
: i have a hash of hashes like this:
: 
: %HOH = {
: 	 name1 => {
: 		     "time" => "9999999999",
: 		     "other" => "whatever",
:                   },
: 	 name1 => {
: 		     "time" => "8888888888",
: 		     "other" => "whatever",
:                   },
: 	 name2 => {
: 		     "time" => "9999999999",
: 		     "other" => "whatever",
:                   },
: 	 name2 => {
: 		     "time" => "8888888888",
: 		     "other" => "whatever",
:                   },
:         }

No, I am afraid you DON'T have an HOH like that. The second instance of
a name overwrites the first -- hash keys must be and are by definition
unique.

: 
: and i need to sort this first on basis of "nameX" and the within that based on
: "time". how can i achieve that?
: 

Check the FAQ questions about sorting -- if you study them, they will
yield the answer.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Thu, 23 Oct 1997 04:35:08 GMT
From: RaviA@CommerceToday.com (Ravi Agarwal)
Subject: URL Encoding
Message-Id: <344ed2c2.36162049@news2.ibm.net>

I can't figure out an easy way to encode URL's - converting non-safe
characters only, such as "<>&*^%#$./" to hex automatically.

For example, I want to convert:
".one?two_three[four" to "%2eone%3ftwo%5fthree%5bfour"

Any help would be greatly appreciated!

-Ravi Agarwal



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

Date: Thu, 23 Oct 1997 01:10:14 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: URL Encoding
Message-Id: <comdog-ya02408000R2310970110140001@news.panix.com>

In article <344ed2c2.36162049@news2.ibm.net>, RaviA@CommerceToday.com wrote:

>I can't figure out an easy way to encode URL's - converting non-safe
>characters only, such as "<>&*^%#$./" to hex automatically.

you could just get the URI::* modules from CPAN [1] if you didn't want
to do any work :)

[1] Comprehensive Perl Archive Network
find one through <URL:http://www.perl.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 23 Oct 1997 03:04:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: variable checking
Message-Id: <62mes1$91o$1@comdyn.comdyn.com.au>

In article <344CC910.7A7635F3@absyss.fr>,
	Doug Seay <seay@absyss.fr> writes:

>> > 2) I don't know how to test the IP.  I don't care what the actually
>> > numbers are, I just want to make sure that it follows the correct
>> > format; i.e. 111.111.111.111 .
> 
> then you need to verify that the four numbers are valid.  The string
> 
> 	999.888.777.666
> 
> will match on your RE, but is not a legal address.  Each of the four
> values should be between 0 and 255 (inclusive).  And even then there are
> special cases, like 0.0.0.0, 111.222.255.0, and so on that may require
> special attention.

That wasn't really the original poster's intention, but ok..

If you want to check for valid IP numbers, something like this always has
served me well.

---SNIP---
#!/usr/local/bin/perl5 -w

use strict;
use Socket;

my @ips = qw(
	111.222.333.444 300 1.1 126.234.344
	255.255.255.0 127.0.0.1 131.94.234.12 0.0.0.0
);

foreach my $ip (@ips)
{
	# You can reject special cases here 
	# (127.0.0.1, 0.0.0.0, 255.255.255.255)

	print STDOUT (CheckIP($ip)?"Valid  ":"Invalid") . ": $ip\n";
}

sub CheckIP
{
	my $ip = shift;

	my ($addr, $rev_ip);
	($addr = inet_aton($ip)) and ($rev_ip = inet_ntoa($addr));

	return (defined($addr) and defined($rev_ip) and $ip eq $rev_ip);
}

--SNIP--
Invalid: 111.222.333.444
Invalid: 300
Invalid: 1.1
Invalid: 126.234.344
Valid  : 255.255.255.0
Valid  : 127.0.0.1
Valid  : 131.94.234.12
Valid  : 0.0.0.0
---SNIP---

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Wed, 22 Oct 1997 19:07:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mic <nishin@bekkoame.or.jp>
Subject: Re: Why wont it work on the Web ?
Message-Id: <Pine.GSO.3.96.971022190256.7008N-100000@usertest.teleport.com>

On Thu, 23 Oct 1997, Mic wrote:

> if ($ENV{'REQUEST_METHOD'} ne "POST") {

> $input = <STDIN>;

You should really use CGI.pm (or a similar module) to help you write your
CGI scripts. It's not only easier...

> chop($input);

 ...but also, it does it right. :-)

> open(TEMP, ">$tn")
> 	|| die "Can't open temp file passwd.$$: $!\n";

It's good to check for errors, but you should know that, in a CGI script,
die may not be the best way to handle them. (But you can put eval {}
around the main body of your code, then check $@ for errors.)

> Which is to change or add new passwords to a file called .htpasswd.

There's a module on CPAN to do that.

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 22 Oct 1997 22:47:08 -0400
From: Owen Taylor <owt1@cornell.edu>
Subject: Re: XS question:  string parameter (allocation)
Message-Id: <lzra9dw5zn.fsf@cu-dialup-0724.cit.cornell.edu>


fishbowl@fotd.netcomi.com (James L. McGill) writes:

> For instance, the C function is:
> 
> 	int foo(char* s);
> 
> The XS code is:
> 
> 	foo(s)
> 		char* s
> 		CODE:
> 			RETVAL = foo(s);
> 		OUTPUT:
> 		s
> 		RETVAL
> 
> 
> the perl to call that would be something like:
> 
> 	$s = 1024x" " #Because I cannot malloc() ?
> 	$i = foo($s); # $s will be /replaced/ in foo()
 
> Now the problem:  I do not want to pre-initialize $s that way,
> if I can avoid it.  I am not even sure that that really does
> what I think it does.

Well, I think the C function is pretty broken - how does it know the
length of your buffer? But leaving that aside, you'll probably have to
get a bit more into Perl internals here. (see the perlguts man page
for details.) One way would be:

int
foo(s)
	SV *s
	CODE:
		SvGROW (s, 1024);
		RETVAL = foo (SvPV(s,na));
	OUTPUT:
	RETVAL


It might be better though to use multiple return values. The perlxs
man page has examples. Hope this helps,

                                        Owen Taylor



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1217
**************************************

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