[15905] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3318 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 11 03:15:33 2000

Date: Sun, 11 Jun 2000 00:15:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960707714-v9-i3318@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 11 Jun 2000     Volume: 9 Number: 3318

Today's topics:
    Re: cgi-problem: internet explorer displays web-page -  <junk@nkadesign.com>
    Re: excluding certain domains in e-mails <dzapped@theramp.net>
    Re: Extracting hash elements based on an array <abe@ztreet.demon.nl>
        Finding repeated words -- e.g. the the <dot@dot.dot>
    Re: Finding repeated words -- e.g. the the (jason)
        form sensitive chars <junk@niftygear.com>
    Re: Larry Rosler interview on perl.com! (Craig Berry)
    Re: Larry Rosler interview on perl.com! <htp@mac.com>
    Re: Larry Rosler interview on perl.com! <htp@mac.com>
    Re: modifying/updating CSV fields <bwalton@rochester.rr.com>
    Re: No offense but Larry Wall should do the maths !! <htp@mac.com>
        rmdir in NT 4... <Mark@virtual-space-ltd.com>
    Re: Time-Date Question ?? <uri@sysarch.com>
        Write to file via CGI script? xenite9@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 11 Jun 2000 10:34:42 +0800
From: "Renaud Bompuis" <junk@nkadesign.com>
Subject: Re: cgi-problem: internet explorer displays web-page - netscape displays source code
Message-Id: <E5A67D3A8CE368D7.0F738EDF1AD97FFF.419F72AE44B74574@lp.airnews.net>

The header returned by your server when getting the page contains extra
information:

HTTP/1.1 200 OK
Date: Sun, 11 Jun 2000 01:50:14 GMT
Server: Apache/1.3.9 (Unix)
bitte suchwort eingeben: Content-type: text/html
Connection: close
Content-Type: text/plain

The last line is why Opera, Mozilla, Navigator display the page as text.
Normally, HTTP headers are not case sensitive, but it wouldn't hurt to use a
capital 'T' in 'Content-Type' in your actual CGI script, Apache could be
expecting a case sensitive header from CGI scripts.
A possible source for the problem could also be the use of a 'print' in your
script prior to outputting your HTML page?
There could be a hidden 'print' in a subroutine you're using.
I unfortunately don't understand German, so I don't know what the extra
message in your header says.
If you can't find anything wrong with your script, then the problem might
come from your server configuration.
Probably better to ask your server hosting provider.

If you or anyone fixes the problem, let me know, I'll be interested to learn
what could cause this type of error.

Good luck,


Renaud BOMPUIS





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

Date: Sat, 10 Jun 2000 20:33:25 -0500
From: Z-man <dzapped@theramp.net>
Subject: Re: excluding certain domains in e-mails
Message-Id: <3942EC65.B878B264@theramp.net>

So using that logic would this be the corerct statement to use:
&error("missing email address") if (!$in{'email'});
 &error("invalid email address") if ($in{'email'} !~ /\@/|| $in{'email'} !~
/hotmail.com/);
because I tried that but it doesn't produce an error..
Denis

Dave Brondsema wrote:

>   Z-man <dzapped@theramp.net> wrote:
> > Hi all,
> > I have a registration script that requires an e-mail address what i'd
> > like to do is exclude certain domains from registering i.e.
> > someone@hotmail .com  is this possable and if so how currently the
> > e-mail part reads this
> > &error("missing email address") if (!$in{'email'});
> >  &error("invalid email address") if ($in{'email'} !~ /\@/);
>
> Use the same logic as the check for @
> if ($in{'email'} !~ /\@/ || $in{'email'} !~ /anytextyouwant/);
> || means or
>
> > any help appreciated
> >
> > Denis
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Sun, 11 Jun 2000 03:14:16 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Extracting hash elements based on an array
Message-Id: <mso5kso2t4r1urfh8cd3atod4h01rfuhin@4ax.com>

On Sat, 10 Jun 2000 23:55:09 GMT, phil.taylor@bigfoot.com (Philip
Taylor) wrote:

> On Sat, 10 Jun 2000 15:13:38 -0700, Tom Phoenix <rootbeer@redcat.com>
> wrote:
> 
> >Inside the braces is a list expression whose value is the list of indices.
> >If the list is qw/ code name age / , then the resulting value from the
> >slice is the same as ($player{code}, $player{name}, $player{age}) .
> 
> I understand slices now (I think), but iy doesn't solve my problem
> completely. The test program below does not produce any o/p because my
> available list of indices (@playerCodes) are not keys to the
> PlayerList hash.
 ...
> $playerList{'player1'} = \%player1;
              ^^^^^^^^^
That is where you want your player code (as an index to the record). If
you need to find the records by name as well, then you could keep a
second hash of references to the records that has the names as indices.

This is what I make of your example + question. The init part is
basically the same as yours (but I'm lazy).

#!/usr/bin/perl -w
use strict;

my @playerCodes = ('001', '003');

my %playerList = (
	'001' => {code => '001', name => 'player1'},
	'002' => {code => '002', name => 'player2'},
	'003' => {code => '003', name => 'player3'},
	'004' => {code => '004', name => 'player4'},
	'005' => {code => '005', name => 'player5'},
	'006' => {code => '006', name => 'player6'},
);

my @result = @playerList{@playerCodes};
#print their names
foreach (@result) {
	print "$_->{name}\n";
}

__END__

A good place to start reading about 'data structures' in Perl is:
	perldoc perldsc

For the hash slices look at (I still haven't bookmarked it :-( but easy
to find on):
	http://www.sysarch.com/

-- 
Good luck,
Abe


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

Date: Sun, 11 Jun 2000 14:08:17 +0800
From: "OBrien-Malone" <dot@dot.dot>
Subject: Finding repeated words -- e.g. the the
Message-Id: <01bfd369$fc4880a0$4c067386@slirp.murdoch.edu.au>

I'm new to Perl, but I would like to use it (or perhaps AWK with which
I am much more familiar) to find
repeated words in a TeX document. I mean the simple typing errors where
I would have typed "See the the figure on ..."
Of course the repeated words might be split over lines.

Can anyone see an easy (Reg Exp) way of doing this?
-- 
Cheers

Mark R Diamond
--------------------------------------------------------------------------
Mark R Diamond
Vision Research Laboratory
Department of Psychology
The University of Western Australia

no spam email: markd at psy dot uwa dot edu dot au

Disclaimers: The opinions expressed herein are those of
the author, and are not intended to reflect on any 
official positon held by The University of Western
Australia generally, the Department of Psychology 
specifically, or any other individual




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

Date: Sun, 11 Jun 2000 07:02:49 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Finding repeated words -- e.g. the the
Message-Id: <MPG.13add6c2e727088989720@news>

OBrien-Malone writes ..
>I'm new to Perl, but I would like to use it (or perhaps AWK with which
>I am much more familiar) to find
>repeated words in a TeX document. I mean the simple typing errors where
>I would have typed "See the the figure on ..."
>Of course the repeated words might be split over lines.
>
>Can anyone see an easy (Reg Exp) way of doing this?

  s/(\w+\s+)\1/$1/g;

however .. I should warn you that this will remove valid english as well 
 .. I can't think of any exciting examples where the removal of the 
duplicate creates a confusing sentence - but it certainly can happen

here's a sentence at least with a valid duplicate

  "There's nothing to say that that will be correct."

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sat, 10 Jun 2000 21:01:18 -0700
From: "Junk" <junk@niftygear.com>
Subject: form sensitive chars
Message-Id: <8hv2p8$l5k$1@slb1.atl.mindspring.net>

I'm working on a perl/cgi script that processes form data,
in some cases I'm creating a link like:
<a href="/download/somefile.zip"></a>
but on some circumstances this file is named something like:
somefile&that.zip

How do I convert that to something the server understands,
I've seen that an & gets converted to %26 but I dont understand
how.

I'm guessing I need to do the oposite of this?
$key =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;




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

Date: Sun, 11 Jun 2000 04:59:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <sk675bcnh51128@corp.supernews.com>

Henry (htp@mac.com) wrote:
: PS:  To adapt :^) some of the script from a recent film some of you may 
: have seen...
[Snip]

ROFLMAO!  Okay, point taken. :)

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: Sun, 11 Jun 2000 14:32:49 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-55075D.14324911062000@news.metropolis.net.au>

In article <pKs05.110113$hT2.431098@news1.rdc1.ct.home.com>, Dan 
Sugalski <dan@tuatha.sidhe.org> wrote:

> Right now, when perl converts a float to an integer it truncates,
> but there's no standard for that, and without one there's nothing
> to say that perl 5.8.0 won't round instead.

Except a few hundred thousand livid programmers who could collectively 
destroy the professional career of the idiot who changed such a 
fundamental behaviour.

Much more incentive than a paper-cut from an ANSI draft.


>> Standards don't give programmers something to work with,
>> DOCUMENTATION does!
> 
> Ummm... what do you think a standard is, some magic spell
> woven over the code?

No, but that's a pity because if it were such a spell, it might actually 
do measurable good.


> A standard *is* documentation, very formal documentation, of how
> something should work. 

Agreed.  A standard is very formal, and hence very _unapproachable_ 
documentation that no-one except masochists bother reading.  If no-one 
reads it, why bother writing it?

NetContributionToPerl = 1.0E-27;


>> This attitude has had a pronounced effect on the documentation,
>> which reads like an arcane language reference and is almost
>> INCOMPREHENSIBLE to a newbie.
> 
> Perl's docs are quite good compared to an awful lot of the documentation
> out there, free or pay.

Err, from a proficient user's point of view - perhaps.

Regardless, just because it isn't _as_bad_ doesn't mean it isn't bad.  
Complacency (based on comparisons to bottom feeders in the gene pool) is 
hardly constructive.


> Perl's not targeted at, nor designed for, the newbie. That's just
> fine--lots of things aren't. That doesn't make it bad in general.

My comments are about Perl's documentation, not the language itself.  
Perl is actually a very _easy_ language for a newbie to pick up, 
providing they have documentation which caters to their experience 
level.  That documentation doesn't exist.  That's the problem.


>> Make better (more approachable) documentation, and more people
>> will "use Perl;".
> 
> There's an awful lot,

No, there isn't.

> and folks seem to be doing pretty well with what's provided,

No, they aren't.

$documentation != 'approachable';


> and there's the llama (or gecko, if that floats your boat) book
> for those folks that need a different approach.

None of which ship with the standard distribution.  Approachable 
documentation MUST be included with the standard distribution they 
download from the Net.

The vast majority of new programmers base their decision to persist with 
Perl (or any other language, for that matter) based on first 
impressions.  For most, that will be when they've just downloaded the 
standard distribution from the Net.

If they can't work out how to get started within a few hours, or a day 
or two, they give up.

It's only if they get past that initial hurdle that they would even 
consider shelling $60 for a book.


> You're also assuming that I'm talking ANSI standard because
> Larry did. RFC822 is a formal standard for e-mail. Adobe's red
> book (I think--might be the white one) is a formal standard for
> postscript. ANSI (or ISO, or whoever) doesn't need to get involved.

Well, yes, everyone else is talking ANSI, so I kinda went with the flow.

If you're proposing "a standard that isn't recognised by an official 
body of any kind" - then how about you just write some darned tootin' 
documentation, and we add the word 'standard' on the cover.  Would that 
make you happy?


>> You don't need artificial standards to do that, all you need is 
>> critical mass.  Approachable documentation, shipped with the
>> standard dstribution, will give us critical mass faster, and
>> more efficiently, than any standard could ever hope.
> 
> This is very, *very* wrong. I presume you've never been involved with
> any sort of major project used by other people.

You presume too much.


> Formal definitions of
> language behavior (which is what a standard *is*) is what gets you
> stability. Otherwise you risk breaking things, and perl has definitely
> done that in the past. (I think every point release has broken something
> somewhere)

Evolution is painful.  That's life.  That's the way it's _supposed_ to 
be.  Standards constrict and confine evolution.  They limit diversity.  
They have a NEGATIVE IMPACT on the survival of the species.

Henry.


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

Date: Sun, 11 Jun 2000 15:12:55 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-C7C097.15125511062000@news.metropolis.net.au>

In article <sk2ou94hh5172@corp.supernews.com>, cberry@cinenet.net 
(Craig Berry) wrote:

> language standardization merely specifies a reliable minimum language
> subset which *must* be implemented and behave in particular ways.  Each
> vendor may offer extensions, so long as they don't interfere with the core
> subset.

Let's take a few lessons from recent history, folks:

Vendor specific extensions ALWAYS interfere with the core subset.  HTML 
and JavaScript and Java (and ...) proved that.

Relenquishing control of Perl to a standards body means that, instead of 
having to win the hearts and minds of (dare I say it) millions of 
intelligent programmers around the world on the basis of _merit_, which 
they have so far utterly failed to do, the Evil Empire (Microsoft) will 
only have to lobby, threaten, bribe, stack, coerce, etc., a tiny number 
of bureaucrats (on a committee), and prevail on the basis of greed.

Henry.


PS:  To adapt :^) some of the script from a recent film some of you may 
have seen...


"I sense much fear in you!"

"You refer to the prophecy of a standard which will bring balance to 
the force.  You believe it's this ANSI?"

"This ANSI is dangerous - they all sense it, why can't you?"

"I will not condone a course of action which will lead us to war."

"There is something else behind all this.  It will destroy Perl if you 
concede."

"Once those droids take control of the standard, they will take control 
of you!"

"A communications disruption can only mean one thing... invasion!"

"Microsoft has gone too far!"

"At last we will reveal ourselves to the PerlMongers.  At last we will 
have revenge!"

"You say Perl gonna die?"

"This is a battle I do not think we can win."

"The death toll is catastrophic!"

"I was not elected to watch my language suffer and die while you discuss 
this invasion in a committee!"

"Our language is dying.  We must do something quickly!"

"I think we are going to have to accept Microsoft control for the time 
being."

"I will sign no treaty!"

"I can only protect you.  I can't fight a war for you."

END { ; }


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

Date: Sun, 11 Jun 2000 04:21:37 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: modifying/updating CSV fields
Message-Id: <394312C5.8FEE4A47@rochester.rr.com>

Brian McDonald wrote:
> 
 ...
> I have a text file that contains many records that look like this:
> 
> jovovich,milla,,,,,1974,,model, singer and actress
> 
> where the last field is marked by the 8th comma.
> 
> What I would like to do is double quote all the string values in the record.
> For example,
> 
> "jovovich","milla","","","","","1974","","model, singer and actress"
> 
> I have written the following code to do the job. The only problem is that I
 ...
> Any ideas?
> 
> Brian

How about something a bit simpler:

while(<DATA>){
	chomp;
	print '"'.join('","',split(/,/,$_,9)).'"'."\n";
}
__END__
jovovich,milla,,,,,1974,,model, singer and actress

-- 
Bob Walton


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

Date: Sun, 11 Jun 2000 12:26:27 +0930
From: Henry <htp@mac.com>
Subject: Re: No offense but Larry Wall should do the maths !!
Message-Id: <htp-6505C5.12262711062000@news.metropolis.net.au>

In article <slrn8k3pce.67o.dha@panix6.panix.com>, dha@panix.com (David 
H. Adler) wrote:

>> Brackets are good.
>>
>> I use brackets.
>>
>> Lots of brackets.
> 
> Yet you used no brackets in your post (of your own (there were some in
> the quoted (i.e. previous poster's) text)).

$reason = noCode();


> Clearly you don't like them enough.

ABBA said it best:

for (1..6) {
  print "I Do\n";
}


> (heck, you didn't even use a smiley :-)

Smileys were designed for the same people that require "No Smoking" 
signs in petrol stations.  I have nothing to say to them.

Henry.


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

Date: Sat, 10 Jun 2000 23:45:27 -0700
From: "Mark S. Blamey" <Mark@virtual-space-ltd.com>
Subject: rmdir in NT 4...
Message-Id: <39433587.A957B7BF@virtual-space-ltd.com>

I've written this code and am finding the directory is not removed by
rmdir.  I'm assuming something is left in the directory so the command
fails.  How can I fix it so that the directory will be deleted as
desired?

   opendir(FILES,"$my_dir/s$name");
   @filelist =  grep(!/^\.|^_/, readdir (FILES));
   closedir(FILES);
   foreach $filelist (@filelist) {
      unlink("$my_dir/s$name/$filelist");
   }
   rmdir("$my_dir/s$name");

Thanks!



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

Date: Sun, 11 Jun 2000 04:23:06 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Time-Date Question ??
Message-Id: <x7itvgalsn.fsf@home.sysarch.com>

>>>>> "PJS" == Peter J Scott <peter@PSDT.com> writes:

  PJS>     'unpack' => q{
  PJS>       my ($year, $m, $d, $h, $min)
  PJS>          = unpack "A2"x5, $line;
  PJS>     }

a small speedup can be done if you expand 'A2' x 5 to A2A2A2A2A2. but it
is still slower than the substr. this is unusual as the perl op dispatch
loop is the biggest bottleneck. so unpack must do more work in decoding
and executing its pattern than perl does in making 5 calls to substr. i
bet with more substr calls a single unpack will win out.

    'unpack2' => q{
      my ($year, $m, $d, $h, $min) = unpack "A2A2A2A2A2", $line;
    }

Benchmark: timing 262144 iterations of regex, substr, unpack, unpack2...
     regex:  4 wallclock secs ( 5.14 usr +  0.00 sys =  5.14 CPU)
    substr:  4 wallclock secs ( 4.00 usr +  0.00 sys =  4.00 CPU)
    unpack:  6 wallclock secs ( 5.42 usr +  0.00 sys =  5.42 CPU)
   unpack2:  4 wallclock secs ( 4.95 usr +  0.00 sys =  4.95 CPU)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 11 Jun 2000 06:57:16 GMT
From: xenite9@my-deja.com
Subject: Write to file via CGI script?
Message-Id: <8hvd8a$vsv$1@nnrp1.deja.com>

Hi,

     I've been trying to build a CGI interface to my firewall on my
*trusted* LAN so I can administer my firewall through my web browser.
It's my way of motivating myself to learn Perl/CGI.  I really don't
know what I'm doing.  This is my test script.  Here goes.  I was able
to figure out how to pass the arguments this script (below) needs to
give the output I want.  If the argument for the "$web" variable equals
on, it prints the first message stating that "Web is enabled", else it
prints the "Web is not enabled" message and so on for the other "$'s".
I'm sure that's clear to all you guys who know what you're doing.
     Then I went to phase 2 of my project.  Since I ultimately need the
code to open the firewall script file (text) and write to it if the
value=on, I inserted some code I got from www.perlmonks.com to do just
that.  Actually I tried a lot of different code samples from their
site.  The cgi script still executes like it did before I added the
file writing code, but fails to write to disk.  It will not write to
disk.  Anyone have any ideas on how I can get the code to write to disk
if the value=on?  Any help would be appreciated.

Thanks.
AC


#!/usr/bin/perl -w

use CGI qw(:standard);

print "Content-type: text/html\n\n";
print "Service Status";

#In step some kicking variables
$web = param("web");
$email = param("email");
$ftp = param("ftp");


if ($web eq "on") {
   print "Web is enabled.";

#Opens text file called fwscript-trys to write to it-fails
$fwscript = "fwscript";

open FH, ">>$fwscript";
	print FH "I will print this to a file\n";

} else {
   print "Web is not enabled.";
}

if ($email eq "on") {
   print "Email is enabled";
} else {
   print "Email is not enabled.";
}

if ($ftp eq "on") {
   print "FTP is enabled";
} else {
   print "FTP is not enabled.";
}



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3318
**************************************


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