[9116] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2734 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 27 11:12:28 1998

Date: Wed, 27 May 98 08:00:33 -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, 27 May 1998     Volume: 8 Number: 2734

Today's topics:
    Re: [HELP] perl and databases for dummies? (Charlie Stross)
    Re: About libnet.so.092 (Jonathan Stowe)
    Re: alternation, grouping, and backreferences (Mark-Jason Dominus)
    Re: ASP vs CGI <bjs@iti-oh.com>
    Re: ASP vs CGI <msergeant@ndirect.co.uk_NOSPAM_PLEASE>
        Benchmark: unpack slower than /(..)(...)/ (Jari Aalto+mail.perl)
    Re: Can I interpolate Perl variables in POD output? <quentin@remington.amd.com>
        Checking success of functions (was: Re: list context: | <rootbeer@teleport.com>
    Re: Checking success of functions (was: Re: list contex <rootbeer@teleport.com>
    Re: Checking success of functions (was: Re: list contex <tchrist@mox.perl.com>
    Re: Clearly define "free software" (Chris Nandor)
        dead URL ? <wweng@attila.stevens-tech.edu>
    Re: dead URL ? <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: dead URL ? <qdtcall@esb.ericsson.se>
    Re: dead URL ? (Greg Bacon)
        DG/UX & PERL & DBI & Oracle 7.x (Craig Nelson)
    Re: Don't Know how to decrypt using PERL (Mark-Jason Dominus)
    Re: file size with perl and win NT scott@softbase.com
        HELP! - Perl Query String Encoding <jaeguy@hotmail.com>
    Re: HELP! - Perl Query String Encoding (brian d foy)
        HOWTO : UDP ping ? <gay@aspentech.com>
    Re: list context: || vs or (Charlie Stross)
    Re: list context: || vs or (John Porter)
    Re: list context: || vs or (John Porter)
    Re: list context: || vs or <tchrist@mox.perl.com>
    Re: list context: || vs or <tchrist@mox.perl.com>
    Re: list context: || vs or <rootbeer@teleport.com>
    Re: Need a "word-count" (Charlie Stross)
    Re: Need a "word-count" (brian d foy)
    Re: Need a "word-count" (Charlie Stross)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 27 May 1998 13:41:59 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: [HELP] perl and databases for dummies?
Message-Id: <slrn6mo637.scr.charlie@cs.ed.datacash.com>

On Tue, 26 May 1998 11:59:20 -0500, Marty Blase 
<mblase@yahoo.com> wrote:
>                                            .... Is there a good "dummies
>guide" for using perl to control databases anywhere, either on the web or in
>print?

See http://www.hermetica.com/technologia/perl/DBI/index.html
for an intro (and resources on) using the DBI::DBD modules 
available for perl 5.

For specific questions, there's a DBI-users mailing list. Or you
could try here (if you don't mind the poor s/n ratio).



-- Charlie


"Given two unrelated technical terms, an internet search engine
 will retrieve only resumes." -- Schachter's Hypothesis   


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

Date: Wed, 27 May 1998 12:38:19 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: About libnet.so.092
Message-Id: <356c04d8.4117672@news.btinternet.com>

On 27 May 1998 10:17:21 GMT, Chia-Hao Chang wrote :

>As Title!
>when I run my perl program,there is an error message! 
>message is as follow:
>ld.so failed: Can't find shared library "libnet.so.0.92"
>Operating System: FreeBSD 3.0
>Perl Version : 5.00404

Hmm,

Either (at least):

A)  Your perl was compiled on another system
B)  someone has removed the library file.
C)  The system has been upgraded and the links to the library files
have been changed.

Your best bet is to recompile your perl which should fix A or C .  If
B then you will either need to go to a backup or reinstall the
necessary parts of your system.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 27 May 1998 10:15:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: alternation, grouping, and backreferences
Message-Id: <6kh75o$6rk$1@monet.op.net>
Keywords: glut interpolant razor toilet

In article <356B5F9A.3BE080D7@fmr.com>,
David Boyce  <David.Boyce@fmr.com> wrote:
>	% perl -we '"Y" =~ /^(X)$|^(Y)$/ && print "$1\n"'
>
>After some time trying to figure out why the (Y) didn't match I realized
>that in fact it *was* being matched but assigned to $2, not $1.

>Apparently the ()-counting for purposes of backreferences takes
>precedence over the | alternation,

No, there's no precedence issue here.  The backref pairs count from
left to right; that's all.

>(a) where this behavior is documented (did I miss it?)

In perlre, of course.  Where else?
# Subpatterns are numbered based on the left to right order of their
# opening parenthesis.

But I suspect that you knew this, and that you outsmarted yourself
into thinking that it meant something other than what it said.

>Because it seems more intuitive to me that whichever
>pattern matches in this case would assign to $1.

If I were King, there would be a moratorium on the word `intuitive' in
these discussions.  No offense, and nothing personal, but as far as I
can tell, ``I think it would be more intuitive'' seems to mean ``I
made an assumption about how it would work, and I guessed wrong.''
That would be OK, except that when people use this phrase, they seem
to imply the continuation ``...and therefore Perl is broken because I
should have been able to guess right.''

People sometimes guess wrong.  The duty of the language designer is
primarily to make it usable, and only sencondarily to make it
guessable.  In this case, all I can say is, maybe your way might be
more intuitive, but it sure would suck.  Consider:

	$string =~ /((a*)(b*)|(c*))(d*)(e*)/

Now where's the string of d's?  Well, it might be in $4, or it might
be in $3, and there is no way to find out where it is.  You can't find
it.  That would make it pretty useless, wouldn't it?

You know, if Henry had done it this way, someone would have come along
and said ``Gosh, it's impossible to find the d's.  I think it would
have been more intuitive for the backets to always be numbered the
same no matter which alternative matches.''  Fortunately Henry is
one of those people who is always right.

The way it is now, you can always use  simple logic like

	$2 || $3 || $7

to get the one that holds the data you want, even when you don't know
which alternative matched.  In your example, the apporopriate
expression is ($1 || $2).

Hope this helps.







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

Date: Wed, 27 May 1998 08:55:20 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: Re: ASP vs CGI
Message-Id: <6kh2ng$4vd$1@malgudi.oar.net>

Neil,

    You can do both on a single server.  However, in order to run ASP, you
must have a Windows NT server running IIS (Internet Information Server).  If
you have Windows NT Server 4.0, you can download the latest IIS 4.0 for
free.

    ASP, or active server pages, is simply a script that is processed server
side before a page is sent out.  By default, the language used in ASP pages
is VBScript (visual basic script.)  It also includes some objects for doing
things such as accessing a database, etc.  However, you can change the
language of ASP.  You can even change it on a per-file basis, I believe.
The other language readily available is JScript (Microsoft's version of
JavaScript -- they're rudimentarily compatible.)  Even better, you can set
it up to use any ISAPI (a Microsoft started, but not exclusive API)
compatible language interpreter.  Now, the Perl for Win32 package comes with
PerlIS (Perl for the IS API).  Hence, you can use Perl as the ASP language.

    You seem to have amde a false assumption that ASP and CGI are exclusive.
CGI is the Common Gateway Interface, a way for programs and computers to
exchange information, while ASP is a page that is rendered by the server
before it is sent.  One is a data exchange interface and the other is a
programming interface.  In fact, ASP pages can access information passed in
the CGI form from the client to the server.

    Typically, when people refer to CGI programming, this is all they
mean -- a program which runs on theserver which has access to CGI
information passed from the client to server.  You can do this in any
language, though.  You can write a program and compile it into an executable
to do this (there are CGI libraries in every language -- and they're not to
difficult to do without libraries), an ASP page, a perl script, a shell
script (on UNIX), or even a lousy ol' batch file.

    Personally, I plan to switch to PerlIS as soon as I have the time
because I feel that perl is a bit more powerful with its ability to have
references, nested structures, and OO-like techniques.  I fyou already know
Perl, I'd suggest using PerlIS with ASP, or otherwise, just learn the
default VBScript language -- its not hard at all.

    Still, if you can see advantages to both in some cases, you can use
both.

Brian.

Neil Marshall wrote in message
<01bd88c9$13892140$65d01eac@111964.tmi.telus.com>...
>Hello!  I am asked to do an investigation in server-side programming
>language.  I read articles and get an impression that ASP is a more
>powerful tool and a less learning curve than CGI.  Is that true?  Fairy
>story?  However, what I want from you PERL experts are Pro's and Con's of
>PERL programming.  It would refect a decision making to choose the right
>programming language to suit with user and system requirements.
>
>Thanks,
>
>Neil




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

Date: Wed, 27 May 1998 15:44:05 +0200
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM_PLEASE>
Subject: Re: ASP vs CGI
Message-Id: <356C18A5.2DC9A4C@ndirect.co.uk_NOSPAM_PLEASE>

Neil Marshall wrote:
> 
> Hello!  I am asked to do an investigation in server-side programming
> language.  I read articles and get an impression that ASP is a more
> powerful tool and a less learning curve than CGI.  Is that true?  Fairy
> story?  However, what I want from you PERL experts are Pro's and Con's of
> PERL programming.  It would refect a decision making to choose the right
> programming language to suit with user and system requirements.
> 

You can use perl for ASP programming, see the Activestate website:
http://www.activestate.com (get yourself plw32i316 and plsei316)
and then see my FAQ:
http://www.geocities.com/SiliconValley/Way/6278/

The FAQ contains a brief suggestion of why use ASP and why use Perl in
ASP.

-- 
<Matt/>


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

Date: 27 May 1998 16:36:56 +0300
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Benchmark: unpack slower than /(..)(...)/
Message-Id: <tbzpg3esxz.fsf@blue.sea.net>


    Camel 2nd p.66 suggests that unpack is more efficient for getting out
    contant width string, but I was suprised that it is not true.
    Would anyone know in whichg situation unpack would be faster?

    jari

Benchmark test

    2.8 Deriving constant length matches

        If we pick two constant lenght strings, how would you do that?

            $_ = "11222";
            timethese 500_000,
            {
                  a => '@a = /^(..)(...)/'
                , b => '@a = ( substr($_,0,2) , substr($_,2,3) )'
                , c => '@a = unpack "A2A3", $_'
            };

            a:  9 secs ( 8.86 usr  0.01 sys =  8.87 cpu)
            b: 19 secs (18.39 usr  0.02 sys = 18.41 cpu)
            c: 26 secs (24.92 usr  0.02 sys = 24.94 cpu)

        Hm, maybe unpack is faster if we retrieve more records?

            $_      = "11223344556677";
            $format = "A2" x 7;
            timethese 500_000,
            {
                  a => '@a = /^(..){7}/'
                , c => '@a = unpack $format, $_'
            };

            a: 11 secs (10.74 usr  0.01 sys = 10.75 cpu)
            c: 82 secs (80.42 usr  0.06 sys = 80.48 cpu)


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

Date: 27 May 1998 08:26:54 -0500
From: Quentin  Fennessy <quentin@remington.amd.com>
Subject: Re: Can I interpolate Perl variables in POD output?
Message-Id: <ximwwb7lu8x.fsf@remington.amd.com>

>>>>> "Charlie" == Charlie Stross <charlie@antipope.org> writes:

    Charlie> There's a possible way of achieving what you want.  What
    Charlie> you could do is run your pipeline like this:

    Charlie>   bunyan --preprocess | pod2man | nroff -man|col -b |cat -s

I may do that.  Thanks, Charlie.  I already have a `-s' option
to print the source code...

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Wed, 27 May 1998 14:22:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Checking success of functions (was: Re: list context: || vs or)
Message-Id: <Pine.GSO.3.96.980527070643.13639I-100000@user2.teleport.com>

On Wed, 27 May 1998, Matt Knecht wrote:

> So, in summation, the handy-dandy method of
> checking things by saying:
> 
> open(FILE, $path) || die "Fooey: $!\n";
> 
> only works for a very select few system calls?

How a system call (or any other function) signals failure depends entirely
upon the whim of the programmer who implemented it. :-)  open() in a
scalar context returns a true/false value, but some system calls will
return something else. The only way to know how a system call signals
failure is (you guessed it) to check the manpage. 

Speaking of which, perlfunc sez:

    For functions that can be used in either a scalar or list context,
    nonabortive failure is generally indicated in a scalar context by
    returning the undefined value, and in a list context by returning the
    null list.

So, _generally_, you can use either of these techniques to check the
results of a Perl function which may return a list or scalar:

    defined( $user_id = getpwuid $user_name ) 
	or die "No user '$user_name' found: $!"; 
    @pwent = getpwuid $user_name
	or die "No user '$user_name' found: $!"; 

(Of course, anything using 'or' may be written with '||', and vice versa,
give or take a few parentheses. :-) 

Note that in the first case we needed to use defined(), since zero is a
valid return value from getpwuid. For even more fun, check out the return
values from ioctl. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 May 1998 14:50:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Checking success of functions (was: Re: list context: || vs or)
Message-Id: <Pine.GSO.3.96.980527075009.13639L-100000@user2.teleport.com>

On Wed, 27 May 1998, I wrote:

>     defined( $user_id = getpwuid $user_name ) 
> 	or die "No user '$user_name' found: $!"; 
>     @pwent = getpwuid $user_name
> 	or die "No user '$user_name' found: $!"; 

Oops! Of course, both of those should be getpwnam, as the variable names
imply. Oops!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 27 May 1998 14:44:18 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Checking success of functions (was: Re: list context: || vs or)
Message-Id: <6kh8s2$ib4$4@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Tom Phoenix <rootbeer@teleport.com> writes:
:    defined( $user_id = getpwuid $user_name ) 
:	or die "No user '$user_name' found: $!"; 

That's pure superstition.  Are you trying to tell us you have a user on
your system whose login name in the passwd file is "0"?  Really? Maybe
you meant to call getpwnam instead.  Definednesss is way overused. (And
"0 but true" may be underused.)  And checking $! implies that getpw sets
errno meaningfully.  I disbelieve.

    $user_name = getpwuid($user_id) || die "No user '$user_name' found";

--tom
-- 
Anyone can be taught to sculpt.
Michaelangleo would have had to have been taught how not to.
The same is true of great programmers


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

Date: Wed, 27 May 1998 12:22:39 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Clearly define "free software"
Message-Id: <pudge-2705980817030001@dynamic265.ply.adelphia.net>

In article <u1hd8d0o46f.fsf@biohazard-cafe.MIT.EDU>, tb@mit.edu (Thomas
Bushnell, n/BSG) wrote:

# Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels) writes:
# 
# > In article <356b2889.0@news.ivm.net>,
# >       Klaus.Schilling@home.ivm.de writes:
# > > Ideas are preexistant and rememorized.
# > This probably explains why the flies in my house
# > get so many brilliant ideas ;-)
# 
# I believe that Klaus Schilling is referring to the opinion attributed
# to Socrates in Plato's _Meno_.  I don't personally believe the theory,
# but it's got something in its credit--especially with regard to
# mathematical constructs--like, say, computer programs.  (Something, of
# course, is a lot less than everything; don't expect me to start
# defending the _Meno_.)

A computer program is not a mathematical construct, it USES mathematical
constructs (usually).  I can accept that 2+2=4 is preexistant.  I cannot
accept that perl is, nor can I accept that learning perl was an act of
rememorization.  That forces me to accept a set of beliefs about life,
death, and existence that I have already examined and rejected.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: 27 May 1998 14:00:58 GMT
From: Wei Weng <wweng@attila.stevens-tech.edu>
Subject: dead URL ?
Message-Id: <6kh6aq$udt$2@apocalypse.dmi.stevens-tech.edu>

How do I test a URL is deadlink or not?

thanks

wei


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

Date: 27 May 1998 16:15:56 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: dead URL ?
Message-Id: <7xyavnpzoj.fsf@beavis.vcpc.univie.ac.at>

Re: dead URL ?, Wei <wweng@attila.stevens-tech.edu> said:

Wei> How do I test a URL is deadlink or not?  thanks

perldoc LWP::UserAgent
perldoc HTTP::Request

would be a good start.

-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.


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

Date: 27 May 1998 16:37:20 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: dead URL ?
Message-Id: <isvhqr7pb3.fsf@godzilla.kiere.ericsson.se>

Wei Weng <wweng@attila.stevens-tech.edu> writes:

> How do I test a URL is deadlink or not?

Try to fetch it and see if it works.
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 27 May 1998 14:41:10 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: dead URL ?
Message-Id: <6kh8m6$9bu$1@info.uah.edu>

In article <7xyavnpzoj.fsf@beavis.vcpc.univie.ac.at>,
	Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:
: Re: dead URL ?, Wei <wweng@attila.stevens-tech.edu> said:
: 
: Wei> How do I test a URL is deadlink or not?  thanks
: 
: perldoc LWP::UserAgent
: perldoc HTTP::Request
: 
: would be a good start.

 ...or just LWP::Simple.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 27 May 1998 13:57:34 GMT
From: cnelson@127.0.0.1 (Craig Nelson)
Subject: DG/UX & PERL & DBI & Oracle 7.x
Message-Id: <6kh64e$56e$1@clarknet.clark.net>

Has anyone gotten DBI/Oracle to work on a Data General DG/UX box?  After I
compile all the code, I seem to get the following error from the test.pl
program:

# perl test.pl
Oraperl test application $Revision: 1.30 $
install_driver(Oracle) failed: Can't load 'blib/arch/auto/DBD/Oracle/Oracle.so'
for module DBD::Oracle: dynamic linker: perl: relocation error: symbol not
found: sys_nerr at /usr/local/lib/perl5/AViiON-dgux/5.00404/DynaLoader.pm line
166.

 at (eval 3) line 2
        DBI::install_driver('DBI', 'Oracle') called at blib/lib/Oraperl.pm line 58
        require Oraperl.pm called at (eval 2) line 1
        main::BEGIN() called at blib/lib/Oraperl.pm line 0
        eval {...} called at blib/lib/Oraperl.pm line 0
        eval 'use Oraperl; 1
;' called at test.pl line 38
BEGIN failed--compilation aborted at (eval 2) line 1.

Anyone have any idea? This is driving me crazy!
 -- 
  Craig Nelson
  cnelson[at]clark.net
  Jacksonville, Florida
 


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

Date: 27 May 1998 10:31:45 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <6kh84h$73l$1@monet.op.net>


In article <6kgh05$ifm$1@nswpull.telstra.net>,
Michael Yeung <michaely@hills.alphanet.net.au> wrote:
>Crypt function encrypts a string using DES algorithm, Right ?

Wrong.  Well, it's right, but the way you mean it is wrong.

Here's DES:

			plaintext
			    |
	key --------------->|
			    |
			    V
			ciphertext

With the key, you can turn plaintext into ciphertext, and back again.

But obviously, it's very important that you can't get the key, even if
you have the plaintext and the ciphertext.

Now, `crypt' *does* use DES, but it uses it this way:

		    "\0\0\0\0\0\0\0\0"
			    |
	password ---------->|
			    |
			    V
			scrambled

Actually `crypt' is more complicated than that, but this shows why you
can't get the password from the scrambled version: The scrambled
version is the ciphertext, the password is the key, and DES was
designed to keep you from getting the key from the ciphertext.

>result = crypt(plaintext , salt) ;
>
>I want to know if there is a way to decrypt the result and give back the
>plaintext !

No.

See perlfaq8 for other suggestions.


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

Date: 27 May 1998 11:17:30 GMT
From: scott@softbase.com
Subject: Re: file size with perl and win NT
Message-Id: <6kgsoa$vlj$3@mainsrv.main.nc.us>

> The problem is that I can read only the first 4-5 Mb from the file (total length is 25 Mb).
> print "We have $count unique URLs";

> Hoping you can do something.

I will say I have never enountered this, and I've processed some
monster URL log files with Perl. I don't have a clue what the
problem is.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Wed, 27 May 1998 14:33:52 GMT
From: "J" <jaeguy@hotmail.com>
Subject: HELP! - Perl Query String Encoding
Message-Id: <01bd897c$730fb080$1000000a@iain>

This part of my script doesn't work because it isn't encoded:
How would I get $newurl encoded for the web?

	$newurl = "http://www.domain.com/bin/script.pl?caption=hello
there&file=./noway.jpg";
	print "Location:$newurl\n\n";

Thanks!

J


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

Date: Wed, 27 May 1998 10:49:42 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP! - Perl Query String Encoding
Message-Id: <comdog-ya02408000R2705981049420001@news.panix.com>
Keywords: from just another new york perl hacker

In article <01bd897c$730fb080$1000000a@iain>, "J" <jaeguy@hotmail.com> posted:

>This part of my script doesn't work because it isn't encoded:

how doesn't it work?

>How would I get $newurl encoded for the web?

use URI::Escape;

>        $newurl = "http://www.domain.com/bin/script.pl?caption=hello
>there&file=./noway.jpg";

>        print "Location:$newurl\n\n";

#HTTP prefers a single space to precede field values.  
#see RFC 2068 Section 4.2
print "Location: $newurl\n\n";

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>


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

Date: Wed, 27 May 1998 16:43:20 +0200
From: "Jerome Gay" <gay@aspentech.com>
Subject: HOWTO : UDP ping ?
Message-Id: <6kh90q$rmo$1@spy.aspentec.com>

Folks,

YANQ... Yet Another Newbie Question...

I need some kinda "UDP ping" and I'm pretty sure perl can do it... how ?
Thanks,

Cheers  /jerome




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

Date: Wed, 27 May 1998 12:31:18 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: list context: || vs or
Message-Id: <slrn6mo1ul.scr.charlie@cs.ed.datacash.com>

On Wed, 27 May 1998 01:37:36 GMT, Matt Knecht 
<hex@voicenet.com> wrote:
>
>This quote from the Camel explains everything.  It's hard to get used
>to the idea that the compiler is smarter than the operator.

I think the point is that Perl is a typed language -- although it
doesn't look that way if you think in terms of ints, floats, and chars.
Rather, the types Perl understands are concerned with the plurality of
data, rather than its mere existence: you get singular, set, and
dictionary types (scalars, arrays, hashes). You can no more assign an
array to a scalar in Perl than you can assign a float to a char in C --
at least, not without doing something explicit to tell Perl _how_ you
want to convert it (equivalent to typecasting in lower-level languages).



-- Charlie

"Given two unrelated technical terms, an internet search engine
 will retrieve only resumes." -- Schachter's Hypothesis   


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

Date: Wed, 27 May 1998 13:10:27 GMT
From: jdporter@min.net (John Porter)
Subject: Re: list context: || vs or
Message-Id: <MPG.fd5dc9d55e60c5d9896f0@news.min.net>

On Wed, 27 May 1998 00:34:13 GMT,
in article <9cJa1.256$j4.1145685@news3.voicenet.com>,
hex@voicenet.com (Matt Knecht) wrote:
> 
>     @pwent = getpwnam("fred");
>     if ($#ar == -1) {
> 	failure_code();
>     } else {
> 	success_code();
>     }
> 
>     # Scalars work here... Yay!
>     $uid = getpwnam("fred") or catch_the_error();

Sounds like someone needs to learn to think in Perl...!

This works just fine:
	@pwent = getpwnam("fred") or catch_the_error();

John Porter



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

Date: Wed, 27 May 1998 13:26:19 GMT
From: jdporter@min.net (John Porter)
Subject: Re: list context: || vs or
Message-Id: <MPG.fd5e05447715aef9896f1@news.min.net>

On Wed, 27 May 1998 00:41:06 GMT,
in article <CiJa1.257$j4.1145685@news3.voicenet.com>,
hex@voicenet.com (Matt Knecht) wrote:
> On Tue, 26 May 1998 22:50:00 GMT, Tom Phoenix <rootbeer@teleport.com> wrote:
> >You did this time. :-)
> >
> >    @list = stat($filename) or die "Can't stat '$filename': $!";
> 
> Hmmmm.. so I did.  I didn't realize that 'short circuiting' wasn't
> really happening, it was just precedence.  It's a strange concept to
> get used to.  I always thought the 'short circuiting' was magic that
> happened inside a comparison, not on a whole line.

"Line"?  What's a "line"?

We're talking about expressions.  Expressions are built of other
expressions.  The conjunctions which join expressions can be
comparison operators and logic operators.  And since the logic
operators all have lower precedence than the comparison operators,
the logic operators can never be "inside" a comparison, unless
you use parentheses -- and even that would be strange.

perldoc perlop

John Porter


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

Date: 27 May 1998 14:36:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: list context: || vs or
Message-Id: <6kh8e1$ib4$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    jdporter@min.net (John Porter) writes:
:This works just fine:
:	@pwent = getpwnam("fred") or catch_the_error();

True.  For someone reasons, I never ever write that.
I always write one of these, the reversed one more
often.  This may not be something to brag about.

    die catch_the_error() unless @pwent = getpwnam("fred") 
    (@pwent = getpwnam("fred")) || catch_the_error();

--tom
-- 
 "... the whole documentation is not unreasonably transportable in a
 student's briefcase." - John Lions describing UNIX 6th Edition
 "This has since been fixed in recent versions." - Kernighan & Pike


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

Date: 27 May 1998 14:35:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: list context: || vs or
Message-Id: <6kh8ba$ib4$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, charlie@antipope.org writes:
:you get singular, set, and
:dictionary types (scalars, arrays, hashes). 

Um, one uses hashes for sets, not arrays.

--tom
-- 
I use `batshit' in an idiosyncratic fashion. --Andrew Hume


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

Date: Wed, 27 May 1998 14:49:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: list context: || vs or
Message-Id: <Pine.GSO.3.96.980527072919.13639J-100000@user2.teleport.com>

[ I know that Martien understands this stuff; most of this is for the
benefit of other readers of this newsgroup. ]

On 27 May 1998, Martien Verbruggen wrote:

> The documentation states clearly that stat returns an array. Not a list.

Not once 5.004_05 is released. :-)  This is thanks to some hard-working
documentation patchers who have been at work correcting this oversight in
the docs. Hooray for them!

Of course, the return value from a sub is always a list in list context or
a scalar in scalar context, as obvious as that sounds. :-)  When you say
it that way, it's easy to see why a return value can never be an array in
list context, or a list in scalar context, or a bird's nest in a cat's
ear, for that matter. Some things just can't happen because of the nature
of the universe.

Now, I know that somebody reading this is going to ask "What about a
scalar in a list context?" The rule is that when an expression "tries to"
return a scalar in a list context, the scalar value will be automatically
promoted to a one-element list. 

    @result = 3;		# (3)
    @result = lc("OK") . 'ay';	# ('okay');
    @result = scalar localtime;	# ('Wed May 27 07:42:33 1998')
    @result = undef;		# (undef)    not an empty list!

In other words, it's always returning a list in a list context. And all is
well with the world. Cheers! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: Wed, 27 May 1998 12:44:52 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Need a "word-count"
Message-Id: <slrn6mo2o3.scr.charlie@cs.ed.datacash.com>

On Sun, 24 May 1998 14:17:31 -0500, Andreas 
<andreas@gson.com> wrote:

>I need to figure out a way to search a file for a word and return the
>number of times the word appears in the file. It sounds simple enough to
>me, but I just can't get anything to work. Anybody has any suggestions?

-- snip snip --

#!/bin/perl

while (<>) { map {$words{uc($_)}++} split(/\s+/, $_); }

print join("\n", map { "$_ -> " . $words{$_}} sort keys %words);

-- snip snip --

This programette prints a sorted list of words read from its standard
input, followed by an arrow and the number of occurences of each word.
(NB: its idea of what constitutes a word is a bit simple-minded -- it
picks on anything delimited by whitespace.)



-- Charlie

"Given two unrelated technical terms, an internet search engine
 will retrieve only resumes." -- Schachter's Hypothesis   


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

Date: Wed, 27 May 1998 09:59:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Need a "word-count"
Message-Id: <comdog-ya02408000R2705980959200001@news.panix.com>
Keywords: from just another new york perl hacker

In article <slrn6mo2o3.scr.charlie@cs.ed.datacash.com>, charlie @ nospam . antipope . org posted:

>while (<>) { map {$words{uc($_)}++} split(/\s+/, $_); }

why use the Evil "map in void context" when a foreach will do?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>


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

Date: Wed, 27 May 1998 14:41:55 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Need a "word-count"
Message-Id: <slrn6mo9jl.scr.charlie@cs.ed.datacash.com>

On Wed, 27 May 1998 09:59:20 -0400, brian d foy 
<comdog@computerdog.com> wrote:

>why use the Evil "map in void context" when a foreach will do?

Obfuscation value. I'm practicing for next year :)



-- Charlie "or maybe it's because I'm writing so much insanely
            boring database mangling code that _has_ to be readable
            that I felt like going a little crazy" Stross


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

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

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