[6607] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 232 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 4 06:07:29 1997

Date: Fri, 4 Apr 97 03:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 Apr 1997     Volume: 8 Number: 232

Today's topics:
     Re: Arithmetic expressions?? <tom@eiscat.uit.no>
     Re: Do I need to lock a text file to append a line? (Lutz Albers)
     Re: Does perl have constants? <Konstantin.Avdeev@p474.f474.n5030.z2.fidonet.org>
     Re: Does perl have constants? (Malcolm Beattie)
     Re: Email forger Works for MindSpring (Steve Lumos)
     Re: File Locking & dbmopen (Lutz Albers)
     Help desperately needed.  Perl errors need decyphering. <robert@ctllc.com>
     Re: Help Doing a chomp type function (Mark Mills)
     Re: Help Doing a chomp type function <tom@eiscat.uit.no>
     How to check what filesystem of file <allison@nas.nasa.gov>
     How to get key from value in a %VAR (basj)
     Is function interpolation possible in RE? <walter@wbriscoe.demon.co.uk>
     Re: Is function interpolation possible in RE? (Eric Bohlman)
     Last modified on files: HELP NEEDED URGENTLY (Donovan Janus)
     Re: Ousterhout and Tcl lost the plot with latest paper (Paul Prescod)
     Re: Perl vs. C/C++ (Mark Mills)
     perl-based vrml builder <detman@berlin.snafu.de>
     Perl5 dbm routines not compatible with perl4? (Steve Foley)
     Re: PERLscript with URL redirection (Donovan Janus)
     print a hash with 2 columns <chauve@info.univ-angers.fr>
     Re: print a hash with 2 columns (Eric Bohlman)
     Re: print a hash with 2 columns <jwilson@ic.ac.uk>
     Re: Q: tr <Konstantin.Avdeev@p474.f474.n5030.z2.fidonet.org>
     Radom Generator (Joshua Davis)
     Re: Redirection command from condition Statement (Eric Bohlman)
     Re: Unix and ease of use (WAS: Who makes more ...) <dan.kang@nuri.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 04 Apr 1997 10:21:43 +0200
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: Arithmetic expressions??
Message-Id: <trk9mjxko8.fsf@eiscat.uit.no>

Vladimir Alexiev <vladimir@cs.ualberta.ca> writes:

[original discussion deleted]

> Unless you want to use abominations such as "file@{[$n+2]}" which creates a
> [in-line reference] to a singleton array, then @{dereferences it}.

Well, since this is a simple scalar, you could use

"file${\($n-1)}", "file$n", "file${\($n+1)}"

but I don't know if that looks any prettier... :-)

-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address
                The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: Fri, 04 Apr 1997 11:05:50 +0200
From: lutz@muc.de (Lutz Albers)
Subject: Re: Do I need to lock a text file to append a line?
Message-Id: <lutz-ya023480000404971105500001@news>

In article <33430c7e.144798557@news.primenet.com>, mmathis@primenet.com wrote:

>I'm buildiing various forms where the submitted data is going to be
>appended to delimited ASCII files, one line per entry.
>Do I need to be concerned that two users might try to write at the
>very same moment thus overwriting each other? Or does Perl4/UNIX
>somehow serialize those writes? The write is a simple open
>HANDLE/print HANDLE/close HANDLE. I tried some simple tests by
>starting several dozen instances of the script simultaneously but
>everything looked fine. Or was I just lucky?

You were just lucky.

>Would flock work to make sure, just in case? Just a flock after the
>open, then the close will automatically unflock?

Yup, the sequence should be:
open
flock
 ... do something ....
close (will release the lock).

DO NOT RELEASE THE flock BEFORE THE CLOSE. The current implementation in
perl5 will not handle this correctly (unless you use unbuffered FILE I/O).

ciao
  lutz
--
Lutz Albers, lutz@muc.de
Do not take life too seriously, you will never get out of it alive.


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

Date: Tue, 01 Apr 97 10:08:06 +0400
From: Konstantin Avdeev <Konstantin.Avdeev@p474.f474.n5030.z2.fidonet.org>
Subject: Re: Does perl have constants?
Message-Id: <859893104@p474.f474.n5030.z2.ftn>

Hello Russ!

Friday March 28 1997 03:40, Russ Allbery wrote to All:

 RA> The standard way to do constants in Perl is with a sub that returns the
 RA> value of the constant.  Perl is capable of internally optimizing these
 RA> subs away.

 RA> For example:

 RA>   sub pi { 3.14159265358979323846 }

    in perl 5 you can declare const 'pi':
    *pi=\3.1415 and refer 'pi' as $pi

    With best wishes...
Konstantin
E-Mail: akc@mdmbank.spb.ru



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

Date: 4 Apr 1997 09:27:30 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Does perl have constants?
Message-Id: <5i2hi2$6ca@news.ox.ac.uk>

In article <859893104@p474.f474.n5030.z2.ftn>,
Konstantin Avdeev  <Konstantin.Avdeev@p474.f474.n5030.z2.fidonet.org> wrote:
>Hello Russ!
>
>Friday March 28 1997 03:40, Russ Allbery wrote to All:
>
> RA> The standard way to do constants in Perl is with a sub that returns the
> RA> value of the constant.  Perl is capable of internally optimizing these
> RA> subs away.
>
> RA> For example:
>
> RA>   sub pi { 3.14159265358979323846 }
>
>    in perl 5 you can declare const 'pi':
>    *pi=\3.1415 and refer 'pi' as $pi

There have been a few misleading/incorrect claims in this thread.
To clarify:
    sub PI { 3.14159265358979323846 }
will not make PI be optimised to a constant in any perl.
    sub PI () { 3.14159265358979323846 }
*will* make PI be optimised to a constant in 5.004 and later
5.003_xx versions (note the explicit null prototype which means
that the lexer knows that it doesn't have to look for any arguments).

Using
    *PI = \3.1415;
will make the variable $PI have the given value and it will be
constant in the sense that $PI can't be used as a lvalue without
eliciting a "Modification of a read-only value" error. However,
$PI is still a variable meaning that it's slightly slower than
putting 3.1415 in the source itself and, more importantly, that
    4 * $PI
and similiar expressions don't get folded to constants. Each time
the program has 4 * $PI, Perl has to get the value of the variable
$PI, get the value of 4, multiple the two together and give the
result. With PI declared as sub PI () { ... }, the expression
    4 * PI
is calculated at *compile-time* and is precisely as fast at
runtime as writing out the appropriate constant value in the
program source.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


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

Date: 4 Apr 1997 10:26:28 GMT
From: slumos@nevada.edu (Steve Lumos)
Subject: Re: Email forger Works for MindSpring
Message-Id: <5i2l0k$8sm@news.nevada.edu>

K. Healy (kevlar@ns.net) wrote:
> the one and only real true kibo wrote:
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > 
> > > On Thu, 27 Mar 1997 20:42:31 -0500 in article
> > > > <333B2207.1FDB@chrysler.com> posted to news.admin.censorship, 
> > > > Kevin Darcy <kcd@chrysler.com> wrote:
> > > > :the one and only real true kibo wrote:
> > > > : HUMANS. Deceiving programs is not illegal -- if it were, I know
> > > > : a helluva lot of sysadmins who would be in the slammer right now
> > > > : :-)
> > > >
> > > >  Big fucking deal - lots of people know Randall Schwartz.
> > >
> > > Care to address my point?
> > 
> > Yes - Randall Schwartz, a former sysadmincontractor at Intel, served
> > time in a slammer for the kind of shit you're  talking about.
> 
> If you are going to smear Randal's name while misspelling it with your
> gutter dialect, at least get the f**king facts straight.  Randal did
> *not* spend *any* time in the slammer.  Goto: 
> 
> http://www.lightlink.com/fors
> 
> for the _facts_.
> 
> Kevin
> <kevlar@ns.net>

I agree with the setiment, but get the facts right yourself.  Randal has
not gone to prison *yet*.  See his signature for the countdown.  Now go
sign the letters to Oregon.

Steve
-- 
         Promote Responsible Net Commerce: Help Stamp Out Spam!
                       <http://www.vix.com/spam/>
 


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

Date: Fri, 04 Apr 1997 11:08:37 +0200
From: lutz@muc.de (Lutz Albers)
Subject: Re: File Locking & dbmopen
Message-Id: <lutz-ya023480000404971108370001@news>

In article <33427161.5C9@ark.ship.edu>, pfdemp@ark.ship.edu wrote:

>I have the same problem, but I think I have a simple solution. Wouldn't
>it work to flock a dummy file before you open the dbm file? Such as:

Assuming that anyone uses this mechanism, no.

>        close(INF);
>        flock(INF,8);    # is this necessary if I close?

It's not even necessary, it's wrong, because INF has IMHO no meaning after
the close. BTW, close will release all locks.

ciao
  lutz
--
Lutz Albers, lutz@muc.de
Do not take life too seriously, you will never get out of it alive.


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

Date: 4 Apr 1997 04:50:17 GMT
From: "Robert Pate" <robert@ctllc.com>
Subject: Help desperately needed.  Perl errors need decyphering.
Message-Id: <01bc40b3$b332b620$2c6802cf@HOSTID.ctllc.com>

Hello there.  I am pretty new to Web programming.  I have written many Perl
scripts that run perfectly in the NT world but I have now put them on my
new ISP's server which is Linux and they don't work right.  I get the error
"errno is 2" and "Premature end of script header".  Can anybody give me a
hand at figuring out what this means and a way to fix it???  I would be
very appreciative.  Thanks



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

Date: Fri, 04 Apr 1997 07:28:02 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: Help Doing a chomp type function
Message-Id: <3345a9b3.13146059@news.ntr.net>

On Thu, 03 Apr 1997 12:54:10 -0500, Allen May <allenm@lexis-nexis.com>
wrote:

>I want to find where each users home account is.. I am doing
>a:
>
>	#!/serve/bin/perl -w 
>  	open(USERS, "user_list") || die "could not open file ($!)";
>  	while(<USERS>) {
>    	  $person="$_";	
>    	  $local = `ypcat passwd | grep $person`;
>    	  print $local;
>  	}    
>I want to remove the exta info that the ypcat gives me.  I tried doing
>a $local =~ s/^$person//g; to start widdling away at the output of
>$person
>but it doesn't work.

Maybe I'm just goofy here but how come you aren't using getpwent?
Or maybe even getpwnam (no e, watch that).

This is modified from the Old Camel Book (v.2 is at work durn it.)

	#!/where/is/perl -w
	while (($login, $pass, $uid, $gid, $quota, $comment, $gcos,
	        $dir, $shell)=getpwent)
	  {
	  print "User: $login\t\tDir: $dir\n";
	  }

Above is for the whole passwd file.  To do what you need...

	#!/where/is/perl -w
  	open(USERS, "user_list") || die "could not open file ($!)";
  	while(<USERS>) 
	  {
	  ($login, $pass, $uid, $gid, $quota, $comment, $gcos, $dir,
	   $shell)=getpwnam(chomp($_));
	  
	  print "User: $login\t\tDir: $dir\n";
	  }

Hope it helps.

If it don't work for some system specific reason, please mention the
system next time so we'd know :>

--
Mark <mark@ntr.net>
Please don't sue my boss because you don't 
understand the concept of free speech.
*Pain is something funny that happens to YOU*


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

Date: 04 Apr 1997 10:10:31 +0200
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: Help Doing a chomp type function
Message-Id: <trlo6zxl6w.fsf@eiscat.uit.no>

Allen May <allenm@lexis-nexis.com> writes:

> 
> I want to find where each users home account is.. I am doing
> a:
> 
> 	#!/serve/bin/perl -w 
>   	open(USERS, "user_list") || die "could not open file ($!)";
>   	while(<USERS>) {
>     	  $person="$_";	
>     	  $local = `ypcat passwd | grep $person`;
>     	  print $local;
>   	}    

So you *really* want to do an invocation of ypcat for every user in your
list?  Have you looked at ([gs]et|end)pwent?

#!/usr/bin/perl -w

# First, make hash of name -> dir mappings
# Only $name and $dir are interesting
while (($name,$u,$u,$u,$u,$u,$u,$dir,$u)=getpwent) {
	$home{$name} = $dir;
}

# Look up every user in "user_list" file in the hash
open USERS, "user_list"		or die "Couldn't open file: $!";
while (<USERS>) {
	chomp;
	print "$_: $home{$_}\n";
}

__END__

This will work whether you use yp, NIS, NIS+ or none of the above.
(Tested on Solaris 2.5, using NIS+)

If you insist on using ypcat, replace the first loop with something
along the lines of

open PASSWD, "ypcat passwd|"		or die "Couldn't run ypcat: $!";
while (<PASSWD>) {
	# parse it yourself
	$home{$name} = $dir;
}

>      |Allen H. May                                   |__\_\_o____/_| |

-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address
                The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: Thu, 03 Apr 1997 16:50:37 -0800
From: "Tyler J. Allison" <allison@nas.nasa.gov>
Subject: How to check what filesystem of file
Message-Id: <3344505D.167E@nas.nasa.gov>

Basicly:

  How do I check to see if a file is on an NFS mounted file system:

And

  if (-x $file && (($d) = stat(_)) && $d < 0) {
	print "$file is executable NFS file\n";
}

from the Perl Programming book does not work on an SGI :)  $dev from the
stat() command returns the "actual" $dev from the other machine.  Anyone
got any ideas? Grocking with "df" or /etc/mtab is not really the "right"
way of doing it.  Something like statvfs() in C would be nice.

-Tyler

-- 
 .--                                                                   
--.
| Tyler Allison      | Sterling Software         | Voice: (415) 604-6629
|
| Network Engineer I | M/S 258-6                 |   Fax: (415) 604-4377
|
| LAN/Security Group | NASA Ames Research Center
+-----------------------+
| NAS Facility       | Moffett Field, CA  94035  | allison@nas.nasa.gov 
|
`--                                                                   
--'


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

Date: 4 Apr 1997 10:39:33 GMT
From: basj@xs1.xs4all.nl (basj)
Subject: How to get key from value in a %VAR
Message-Id: <5i2lp5$67c$1@news0.xs4all.nl>

I need to get the key that belongs to a value in a %VAR. How do I do that ?
I can get the value if I have a key but I need to do the reverse lookup.


--
basj@xs4all.nl
http://www.xs4all.nl/~basj


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

Date: Fri, 4 Apr 1997 08:25:09 +0100
From: Walter Briscoe <walter@wbriscoe.demon.co.uk>
Subject: Is function interpolation possible in RE?
Message-Id: <6o0LCFAVzKRzEw47@wbriscoe.demon.co.uk>

I have an application in which I want to replace characters with values
less than space in the same way as is done in the presentation of such
characters in vi. e.g. I want to replace "\001" with "^A". I can't use
tr because that does a 1 to 1 mapping and I want a 1 to 2. Am I correct
that there is no ability to interpolate functions in perl?

i.e. that one can't do something like:
s/([\000-\007\013-\037])/^$(chr(64+ord($1)))/g
# I use the $() backtick symbolism from the Korn shell for illustration.

Given my inability, I was reduced to using:
  @chars = split //; # split $_ into characters in @chars
  foreach $ch (@chars) {  # For each character in turn
    # replace by ^ . @A-Z... if low value other than \t and \n
    $ch = ('^' . chr( 64+ord($ch) ) ) if $ch =~ /[\000-\007\013-\037]/;
  }
  $_ = join('',$chars); # Put (possibly transformed) $_ together again.

Is there a significantly more succinct coding I have missed?
-- 
Walter Briscoe


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

Date: Fri, 4 Apr 1997 09:15:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Is function interpolation possible in RE?
Message-Id: <ebohlmanE83wDC.7rM@netcom.com>

Walter Briscoe (walter@wbriscoe.demon.co.uk) wrote:
: I have an application in which I want to replace characters with values
: less than space in the same way as is done in the presentation of such
: characters in vi. e.g. I want to replace "\001" with "^A". I can't use
: tr because that does a 1 to 1 mapping and I want a 1 to 2. Am I correct
: that there is no ability to interpolate functions in perl?

No.  If you use the "e" modifier on the s operator, the replacement is 
treated as a Perl expression.

 : i.e. that one can't do something like:
: s/([\000-\007\013-\037])/^$(chr(64+ord($1)))/g
: # I use the $() backtick symbolism from the Korn shell for illustration.

s/([\000-\007\013-\037])/"^".chr(64+ord($1))/ge



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

Date: Fri, 04 Apr 1997 08:22:03 GMT
From: donovan@zaak.nl (Donovan Janus)
Subject: Last modified on files: HELP NEEDED URGENTLY
Message-Id: <3344b90e.86999012@news.xs4all.nl>

Hi.

I need to see whether a file may has become outdated by looking when
it was last modified. Is there any way of doing this?

If not, could someone please e-mail me that aswell.

Thanks,

Donovan Janus	


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

Date: Fri, 4 Apr 1997 05:37:46 GMT
From: papresco@csclub.uwaterloo.ca (Paul Prescod)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <E83MAz.IA1@undergrad.math.uwaterloo.ca>

In article <3343D13C.41C6@acm.org>, Thant Tessman  <thant@acm.org> wrote:
>Chris Bitmead wrote:
>
>> [...]  Remember that Sun is pushing Tcl for some obscure reason, and 
>> Ousterhout is apparently working for Sun now,  [...]
>
>I've been told (by friends who follow this stuff more closely than I do) that 
>Sun has already lost control of Java to the Evil Empire.  This might explain it.

Sun is pushing Java more than ever. The reason for their interest in TCL 
seems to be this dichtomy between systems programming languages and scripting
languages.

 Paul Prescod



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

Date: Fri, 04 Apr 1997 06:59:19 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: Perl vs. C/C++
Message-Id: <33449fe0.10630671@news.ntr.net>

On Wed, 02 Apr 1997 14:38:26 -0800, Dan Corbett <dcorbett@jcaho.org>
wrote:

>I am evaluating languages to use for creating a program to basically
>read in a file, parse out some text, and rewrite the file. Eventually
>this data will be uploaded into a database. Obviously, this can be done
>in C/C++. Perl got thrown into the into the mix (this will be written on
>an HP-9000), and I was wondering if anyone could help me with selling
>points of Perl, such as: 
>
>	1) How easy is it to learn?

If you think parsing the text file will be no problem then you
shouldn't have any problem picking up some perl.  You'll find it quite
comfortable when you start picking out all the c'ish bits.

>	2) How well does it handle files and strings?

Unparalleled.  Better than Cobol *shudder*, Basic (borrowed from
Cobol, BTW), Pascal, even Lisp in my opinion.  Some string stuff in
Lisp is simple but other is simply black-magic.  Perl handles strings
cleanly and with more power than I've seen in any language or library
accross 8 languages.

File handling is neat and simple.  What more do you need? :>

The question you didn't ask is: maintainability.  In my experience
when you are grabbing and manipulating data to put into a DB. The
data's irregularity ALWAYS transcends your first spec. (Oh yeah, on
Thursdays we include a weekly summary at the bottom of the file as an
extra service.)  Tweaking and re-running, debugging, and adding
features is so easy.  For code that needs to be 24/7/365 use C(++).
For code that runs occasionally, and needs regular jiggery-pokery,
Perl.

Even without 'tweaking' added into the equation you'll find the
develop time exceedingly quick for perl.  If you have a really good
basis in C++ and fair knowledge of Un*x shell I'd say you'd only spend
a few days picking up what little perl you'll need to get a first rev
of code out.  You'll likely cut and paste half of it.  1/4 you'll type
in from the CAMEL.

>	3) What about support and documentation?

You'll be amazed if you have any ability to search the web/type
man/have heard of DejaNews/can type perldoc...

Goto www.perl.com/perl  and let Tom lead you to the light.

>	4) What about all this CGI and webserver stuff, etc. 

Are you writing CGI code?  Will You? If so you'll be doubly glad you
invested the time to learn Perl.  Perl's match of easy scripting,
shelling, flexible data (strings and more) handling, and programming
power made it the perfect match for the infant web programming niche.

Don't let that fool you.  Serious programs were written in perl before
anyone ever heard of HTML.

>I have looked quite a bit for this info (so you don't think I'm
>completely lazy), but was hoping to get an opinion from someone who has
>used Perl and C. Any help would be greatly appreciated.

Good Luck.

--
Mark <mark@ntr.net>
Please don't sue my boss because you don't 
understand the concept of free speech.
*Pain is something funny that happens to YOU*


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

Date: Fri, 04 Apr 1997 08:23:12 +0200
From: Detlef Huettemann <detman@berlin.snafu.de>
Subject: perl-based vrml builder
Message-Id: <33449E50.6139@berlin.snafu.de>

hi !

Do there are any modules helping to generate vrml-worlds ?

I would like to have a module to speed up designing 
architectural worlds: Rooms separated by walls, connected
by doors; Lamps with buttons on the wall to turn them on/off;
Knobs opening doors when touched ...

It would be much easier to define such worlds by writing
down a perlscript like

 ...
$kitchen = new Room ( 4.3, 2.3 );            # geometry of kitchen
$lamp    = $kitchen->addLamp( 2.2,3.2,2.3 ); # location of lamp
$bttn    = $lamp->createButton();            # button to switch lamp
$kitchen->addButton( $bttn, 0.0, 1.2, 2.2 )  # location of button      
scene->addRoom ( $kitchen );
$scene->writeCode ( "kitchen.wrl" );
 ...

than designing all the stuff in a visual vrml builder.
( And it would be pure OO-fun ! )

thanx a lot, det.                         
-- 
** Detlef Huettemann ******************************************
*  phone : +49-30-611 36 07              Lausitzer Strasse 36 *
*  email : detman@berlin.snafu.de            10999 Berlin     *
***************************************************************


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

Date: Fri, 04 Apr 97 05:47:31 GMT
From: sfoley@undersea.com (Steve Foley)
Subject: Perl5 dbm routines not compatible with perl4?
Message-Id: <5i2f7c$g8k@taxis.corp.titan.com>

I have been trying to use a perl4 script (which works fine under perl4) with 
perl 5, but I keep getting a nice quiet termination of program.  The only 
thing remotely funny that I am doing is some dbmopen and dbmcloses.  They are 
in line with perl4 spec, but seem to be a slight problem for perl5.  Is there 
a simple trick (maybe adding a few header lines to the top of the script or 
something), or are there some known problems here?  Thanks!

-Steve
sfoley@undersea.com


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

Date: Fri, 04 Apr 1997 08:15:21 GMT
From: donovan@zaak.nl (Donovan Janus)
Subject: Re: PERLscript with URL redirection
Message-Id: <3344b865.86830480@news.xs4all.nl>

On 3 Apr 1997 02:44:29 GMT, nvp@shore.net (Nathan V. Patwardhan)
wrote:

>Anthony John Doyle (strad@mondenet.com) wrote:
>: not sure if this is the best place to ask the question - but
>:   here goes.
>
>Yes, this is definitely the wrong place.  :-)  Please refer all CGI
>questions to comp.infosystems.www.authoring.cgi.  Perl doesn't understand
>a 302 code.  :-)
>
>Hope this helps!
>
>--
>Nathan V. Patwardhan
>nvp@shore.net
>

Perl definitely understand the HTTP/1.0 302 Object Moved code.

You need this code if you are using Microsoft Information Server.
Otherwise you should be just fine with Location: $url




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

Date: Fri, 04 Apr 1997 11:06:46 +0200
From: Candice Chauve <chauve@info.univ-angers.fr>
Subject: print a hash with 2 columns
Message-Id: <3344C4A6.7428@info.univ-angers.fr>

I've got to print a hash composed of students'names and of their best
mark.On the first, column we should see the name of the student and on
the other column,we should see the students'mark.The first problem is
that the second column must begin at the same position for all the marks
and I don't know how to do that!
Secondly, I've got to sort the students by the level of their mark.And
if several students have the same mark ,I should sort them by
alphabetical order.
It would be great to give me an helpfull answer...
sorry for the english mistakes!


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

Date: Fri, 4 Apr 1997 09:18:14 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: print a hash with 2 columns
Message-Id: <ebohlmanE83wIE.7tv@netcom.com>

Candice Chauve (chauve@info.univ-angers.fr) wrote:
: I've got to print a hash composed of students'names and of their best
: mark.On the first, column we should see the name of the student and on
: the other column,we should see the students'mark.The first problem is
: that the second column must begin at the same position for all the marks
: and I don't know how to do that!

Look into output formats, and also look at the printf and sprintf functions.

: Secondly, I've got to sort the students by the level of their mark.And
: if several students have the same mark ,I should sort them by
: alphabetical order.

Look at the Perl FAQ, which contains examples of how to sort on multiple 
fields.


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

Date: 4 Apr 1997 10:12:03 GMT
From: "Jeff Wilson" <jwilson@ic.ac.uk>
Subject: Re: print a hash with 2 columns
Message-Id: <01bc40e0$a3ee80e0$1d34c69b@leicester.cc.ic.ac.uk>

Here is a quick, though rather clumsy, solution to your problem. I'm
sure you'll get better. It assumes that you have an associative array
with the names as the index and the marks as the values. For testing
I've created one called %list. Unfortunately this script will only sort
the marks in incremental order if you want the names in alphabetical
order.

# AA
# perl test script

%list = (
	"tom",		"12",
	"dick",		"1012",
	"harry",		"99",
	"fred",		"100",
	"george",	"100",
	"albert",		"100",
	"charlie",	"49"
	);

foreach $name (keys(%list))	{
	$index=sprintf("%06d %s",$list{$name},$name);
	$result{$index}="";
	}

foreach $entry ( sort keys(%result)) {
	($mark,$name)=split(/ /,$entry);
	printf(stdout "\t%8s %d\n",$name,$mark);
	}
-- 
                                               Jeff Wilson
                                               CCS ~ Imperial College ~
London UK
                                              

Candice Chauve <chauve@info.univ-angers.fr> wrote in article
<3344C4A6.7428@info.univ-angers.fr>...
> I've got to print a hash composed of students'names and of their best
> mark.On the first, column we should see the name of the student and
on
> the other column,we should see the students'mark.The first problem is
> that the second column must begin at the same position for all the
marks
> and I don't know how to do that!
> Secondly, I've got to sort the students by the level of their
mark.And
> if several students have the same mark ,I should sort them by
> alphabetical order.
> It would be great to give me an helpfull answer...
> sorry for the english mistakes!
> 


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

Date: Tue, 01 Apr 97 09:57:21 +0400
From: Konstantin Avdeev <Konstantin.Avdeev@p474.f474.n5030.z2.fidonet.org>
Subject: Re: Q: tr
Message-Id: <859892613@p474.f474.n5030.z2.ftn>

Hello Henry!

Friday March 28 1997 01:06, Henry Chan wrote to All:

 HC> I'm having problems with regular expressions with tr.
 HC> I'm trying to replace the first and last chars with a certain char.
 HC> i.e.
 HC> $old = "HELLO";
 HC> ($new = $old) =~ tr/^.$./ML/;
 HC> I want the result
 HC> MELLT, but it doesn't seem to work.
 HC> What am I doing wrong?

    use s/// instead of tr///
    ($new=$old)=~s/^.(.+).$/M($1)L/;

    With best wishes...
Konstantin
E-Mail: akc@mdmbank.spb.ru



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

Date: 31 Mar 1997 21:56:37 GMT
From: daviso@mcnet.marietta.edu (Joshua Davis)
Subject: Radom Generator
Message-Id: <slrn45k0col.v1.daviso@mcnet.marietta.edu>

Hi I am not on this list so please email me personally...

I need a BETTER random number generator than the builtin one for perl
Does anyone have any ideas?

					In Him,
					  Joshua Davis

-- 
  

                     |           
                   -----
                     |
		     |          JESUS SAVES LIVES!
                    / \-------------------------------------\
                   /   \                                     \
                  /     \                                     \
                 /       \                                     \
                /         \  Visit "Heaven On Earth Ministries" \
               /-----------\-------------------------------------\          
               |           |http://www.marietta.edu/~daviso/HOEM/|
               |  _______  |      ___       ___       ___        |
               |  |  |  |  |     | _ |     | _ |     | _ |       |
               |  |  |  |  |     |___|     |___|     |___|       |
               |  |  |  |  |                                     |
               |-----------|-------------------------------------|
                   The Doors Are Always Open To His Church!!!         





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

Date: Fri, 4 Apr 1997 09:01:14 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Redirection command from condition Statement
Message-Id: <ebohlmanE83vq3.7CJ@netcom.com>

Bala S. Chidambaram (subramani@washington.xtn.net) wrote:
: Could someone please help me. I have wasted too much time on this 
: already. How do I give a command to go to a URL from a condition

: eg: If (.......) { goto http://myserver/index.htm }
: elsif  (.......) { goto http://someotherserver/index.htm }

: The Goto command does not work towards a URL if I am not mistaken. 
: I would appreciate any help. I am a new PERL programmer just learning 
: the magic of PERL.

You've got a conceptual confusion between the flow of control within a
program and the output of the program.  "goto" tells the Perl interpreter
to resume executing Perl code at the statement specified by the label
given after "goto."  It sounds like you're trying to write a CGI script
that will send the person calling it to one of several URLs; sending
someone to a URL is a completely different thing from redirecting the
control flow in a program.

Sending someone to a URL is done by outputting a location header; you 
should look up "location" and "redirection" in whatever resource you're 
using to learn CGI programming, since that will give you a much better 
understanding of what's involved than I could.




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

Date: 4 Apr 1997 03:36:19 GMT
From: "Daniel Kang" <dan.kang@nuri.net>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <01bc4028$7f6f4780$LocalHost@dan>

Eric Bohlman <ebohlman@netcom.com> wrote

> : I am a capitalist becase I am a (more or less) realist.
> : Greed might not be good, but it is present.  Socialism
> : doesn't take this into account.  But remember that
> : everytime someone does some form of freeware (GNU,
> : Perl, Linux, whatever), this is a bit of socialism.
> : The world is a better place because of it.

> I don't really see the relationship between freeware and socialism, since
> the author of freeware makes a free choice to make it publicly available
> at no cost; he's not forced to by any state authority.  This is perfectly
> consistent with capitalism as defined by Adam Smith (who I consider to be
> more of an authority on what capitalism is than Ayn Rand).

I always though of freeware/Public domain as some form of socialism. The
authors of the programs/code, while not being forced by anyone, made a decision
themselves to release their work for nothing. Although there are some
exceptions (Netscape, MS, and other commercial companies), these are evidences
quite against the capitalists theory in that it shows that people will do work
without economic benefit. Try reading some GNU documents.

> Oftentimes
> it's in one's own economic interest to choose to make some of one's
> creations freely available; to name only one such circumstance, doing so
> may make it possible (or at least easier) for someone else to create an
> application or utility that has value to you.  Or it may encourage people
> to come to you for custom work that they'll pay for. 

Almost never, except when you want to raise your market share and that's often
in the form of dumping.

> Capitalism is not, despite what some people think, based on everyone
> trying to maximize their own utility at the expense of others.  Such a
> system can't work for very long, since in a group of N people it means
> that every person has 1 person trying to maximize his utility and N-1
> people trying to minimize it, which usually leads to a decline in the
> total utility present in the group.  

Maybe not necessarily at the expense of others. I think it's a system in which
everyone tries to maximize their own utility with no concern for others
resulting in maximizing the total utility in the group. It doesn't always work
because some people may be able to maximize their own utility at the expense of
others as you just described. Even when it works, there are always problems
with unfair (or unequal) distribution.

> Rather, it's based on the notion of
> everybody trying to maximize the total utility in the group and taking a
> share of the increase proportional to the amount one contributed to the
> increase (not that this is not the same as the total increase in utility
> being divided equally among members of the group). 

Isn't the above exactly what socialism aims for? BTW what does the group mean?
What characteristics in capitalist society make it possible to divide the
increase in utility among the people according to their contribution?

> Many of what some leftists identify as the inherent features of 
> capitalism are actually perversions of capitalism.  It's worth noting 
> that *pure* capitalism suffers from many of the same problems as pure 
> socialism (mostly stemming from the fact that people do not always act 
> rationally), and consequently all "capitalist" societies actually 
> practice a modified form of capitalism. 

Which is not always good enough. European implementations, IMO, are generally
better than US style (US, S Korea, Japan, China(?)).

-- 
><><><><><><><><><><><><><><><><><><><><><><><
Daniel B. Kang - A 10th grader at SIS (Seoul International School)
who's interested in getting into Caltech, MIT or other top-ranking
schools prior to graduation (after the junior year). If you have
any info on it, please e-mail me at d a n k a n g @ n u r i . n e t.
<><><><><><><><><><><><><><><><><><><><><><><>
My return address is intentionally invalid due to an increasing
number of unwanted junk mails. Please take out a period between
dan and kang. Thanks.
><><><><><><><><><><><><><><><><><><><><><><><



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

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

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