[18160] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 328 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 21 14:10:41 2001

Date: Wed, 21 Feb 2001 11:10:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982782619-v10-i328@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 21 Feb 2001     Volume: 10 Number: 328

Today's topics:
    Re: PROPOSAL: Graphics::ColorNames <bmb@ginger.libs.uga.edu>
    Re: PROPOSAL: Graphics::ColorNames <bmb@ginger.libs.uga.edu>
        Quickest way to convert all keys in a hash from upperca <pobbard@hotresponse.com>
    Re: Re: PERL Request <mindfield@badgers.emulationnet.com>
    Re: Re: PERL Request <mindfield@badgers.emulationnet.com>
    Re: Specifying the length of regular expression (Greg Bacon)
        Thank you! It works. But..... <fabian@markisspecialisten.com>
    Re: Thank you! It works. But..... <jfeuerst@eecs.tufts.edu>
    Re: Thank you! It works. But..... <godzilla@stomp.stomp.tokyo>
        version of Unix operation system <yhu@mail.nih.gov>
    Re: version of Unix operation system (Peter L. Berghold)
    Re: version of Unix operation system nobull@mail.com
    Re: Well, looks like ANOTHER bug in perl-5.6.0 <morozov@novosoft.ru>
    Re: Whats wrong with this???? <godzilla@stomp.stomp.tokyo>
    Re: Whats wrong with this???? <bart.lateur@skynet.be>
    Re: Whats wrong with this???? <infinityzone@hotmail.com>
        Write to a text file works, but not to an html file. <fabian@markisspecialisten.com>
    Re: Write to a text file works, but not to an html file <peter.s@tjgroup.dk>
    Re: Write to a text file works, but not to an html file <fabian@markisspecialisten.com>
    Re: Write to a text file works, but not to an html file <mpapesch@gmx.de>
    Re: Write to a text file works, but not to an html file <fabian@markisspecialisten.com>
    Re: Write to a text file works, but not to an html file <godzilla@stomp.stomp.tokyo>
    Re: Write to a text file works, but not to an html file <crowj@aol.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Feb 2001 10:20:41 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <Pine.A41.4.21.0102211006310.11852-100000@ginger.libs.uga.edu>

On 21 Feb 2001, Abigail wrote:

> Robert Rothenburg (wlkngowl@unix.asb.com) wrote on MMDCCXXXI September
> MCMXCIII in <URL:news:3A934CD8.758BA96F@unix.asb.com>:
> :} 
> :} 
> :} Brad Baxter wrote:
> :} > Personally, I'm fond of data files I can edit with vi.  Since the colors
> :} 
> :} Good idea! And more portable.
> :} 
> :} In fact "duh" is a better answer. My current implementation dyanmically
> :} loads simple modules with one function which returns a hash. A text file
> :} may be a lot faster.
> 
> *shrug* dbm files were suggested to avoid the overhead of loading an
> entire text file. Don't forget, this is supposed to run on a system
> that has problems finding the memory to hold a thousand integers.
> 
> If loading a text file isn't a problem, this entire discussion was moot.

Yikes.  I wasn't suggesting loading the text file at all.  I was
suggesting hiding a binary search of the text file behind a tied hash
fetch.  

I'm not saying it's a better approach than using a dbm file--I suspect
it's a bit slower.  But I don't imagine this would be accessed in a tight
loop.  I really don't have a strong opinion either way.

I bet coming up with the actual color names will prove much more
challenging than coming up with the class implementation.  As long as the
implementation is suitably encapsulated, it can be improved as needed.

Brad



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

Date: Wed, 21 Feb 2001 12:45:58 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <Pine.A41.4.21.0102211235430.11852-100000@ginger.libs.uga.edu>

On Wed, 21 Feb 2001, Brad Baxter wrote:
> Yikes.  I wasn't suggesting loading the text file at all.  I was
> suggesting hiding a binary search of the text file behind a tied hash
> fetch.  

And below is a preliminary stab at it.  Line 18 is there to get around an
apparent bug in my version of Interpolation.pm.  I'm not suggesting that
this be the actual implementation code.  It's just a proof of concept.

Brad

     1  #!/usr/local/bin/perl
     2  use warnings;
     3  use strict;
     4  use Search::Dict;
     5
     6  my $colors = "colors.txt";
     7  open my $colorfh, $colors or die "Can't open $colors: $!";
     8  sub get_color {
     9    if( ( look $colorfh, $_[0], 0, 1 ) >= 0 ) {
    10      my( $name, $code ) = split /,/, scalar <$colorfh>;
    11      return '' unless $name eq $_[0];
    12      chomp $code;
    13      return $code;
    14    }
    15    return '';
    16  }
    17
    18  *get_colour = *get_couleur = *get_colore = *get_color;
    19
    20  use Interpolation
    21      color      => \&get_color,
    22      colour     => \&get_colour,
    23      la_couleur => \&get_couleur,
    24      colore     => \&get_colore,
    25      ;
    26
    27  print <<_end_;
    28  <font color="$color{red}">Red</font>
    29  <font color="$colore{rojo}">Rojo</font>
    30  <font color="$la_couleur{vert}">Vert</font>
    31  <font color="$colour{green}">Green</font>
    32  <font color="$la_couleur{bleu}">Bleu</font>
    33  <font color="$colore{azul}">Azul</font>
    34  _end_
    35
    36  __END__
    37  Output:
    38
    39  <font color="ff0000">Red</font>
    40  <font color="ff0000">Rojo</font>
    41  <font color="00ff00">Vert</font>
    42  <font color="00ff00">Green</font>
    43  <font color="0000ff">Bleu</font>
    44  <font color="0000ff">Azul</font>


Datafile:

azul,0000ff
black,000000
blanc,ffffff
blanco,ffffff
bleu,0000ff
blue,0000ff
green,00ff00
negro,000000
noir,000000
red,ff0000
rojo,ff0000
rouge,ff0000
verde,00ff00
vert,00ff00
white,ffffff




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

Date: Wed, 21 Feb 2001 12:05:59 -0500
From: "Philip Obbard" <pobbard@hotresponse.com>
Subject: Quickest way to convert all keys in a hash from uppercase to lowercase (or vice-versa)?
Message-Id: <970sge$863$1@taliesin.netcom.net.uk>

Hi all,

At one point in my code, I wind-up with a hashref containing uppercase key
names when I eventually need lower case key names, so I do the following
with my hashref $results:

 #Put keys in lowercase
 while(my ($key, $value) = each(%$result)) {
  $result->{lc($key)} = $value;
  delete($result->{$key});
 }

This works, but I'm wondering: is there a quicker way to do this (and
wind-up with another hashref, perhaps)?

Thanks,
Philip





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

Date: Wed, 21 Feb 2001 15:08:31 GMT
From: Mindfield <mindfield@badgers.emulationnet.com>
Subject: Re: Re: PERL Request
Message-Id: <uam79t4602aso1k94aba5pa2kn21hboio3@4ax.com>

On 21 Feb 2001 10:08:16 GMT, "Scott R. Godin"
<dontspamthewebmaster@webdragon.net> drooled an embarassing wet spot
in his lap as he typed:

>^ this might be why -- you get an e-mail sent to you by the moderation 
>business on any first post to that group -- since you're spamblocked, 
>you cannot get the auto-e-mail. 
>
>comp.infosystems.www.authoring.cgi is a self-moderated newsgroup -- for 
>more info, search for the comp.infosystems.www.authoring.cgi FAQ on 
>www.dejanews.com

Hmm.  Perhaps, then, I should post the message removing the badgers
myself for the first post, then put it back in.  I, like you, just do
that to prevent spam trawlers from grabbing my E-Mail address 'cos I,
like you, utterly loathe that with a passion that practically IS an
obsession.  If I had a dime for every spammer I've reported... :-)

Anyway, I'll give that a try, thanks.  :-)

-- 

Almost there...

"Ignorance breeds confidence more often than does knowledge."  -Darwin
The Emulation Newbie FAQ: http://www.emulationnet.com/emufaq.html

Remove the badgers before E-Mailing.


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

Date: Wed, 21 Feb 2001 15:09:06 GMT
From: Mindfield <mindfield@badgers.emulationnet.com>
Subject: Re: Re: PERL Request
Message-Id: <udm79t81m43lrkvn33ofr9pj6mg9li3qqo@4ax.com>

On Wed, 21 Feb 2001 10:15:24 GMT, Bart Lateur <bart.lateur@skynet.be>
drooled an embarassing wet spot in his lap as he typed:

>No, there appears to be a problem with the automoderator bot. There
>hardly have appeared any posts since Feb 9.

I read that recently, actually, having gotten new headers just to see
if the group really was dead.  I'll try my post again...	

-- 

Almost there...

"Ignorance breeds confidence more often than does knowledge."  -Darwin
The Emulation Newbie FAQ: http://www.emulationnet.com/emufaq.html

Remove the badgers before E-Mailing.


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

Date: Wed, 21 Feb 2001 19:00:20 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Specifying the length of regular expression
Message-Id: <t98424jngves5b@corp.supernews.com>

In article <eli$0102201628@qz.little-neck.ny.us>,
    Eli the Bearded  <elijah@workspot.net> wrote:

: In comp.lang.perl.misc, Greg Bacon <gbacon@hiwaay.net> wrote:
:
: > I would argue the a module like the one you've described is
: > unnecessarily limited.  Giving the user the option of providing a
: > coderef to check individual strings or filter lists of strings would
: > yield considerably more flexibility.
: 
: What if the regex is being used by split()? Will you provide a patch
: to perl so that split() will use coderefs? How will that work
: efficently?

Using split() is great if your data permits it, but split() isn't a
universal tool.  split() is a great example of optimizing for a
common case, but it has its limits.  TMTOWTDI, so Perl doesn't force
you to split() to split data.

Greg
-- 
As a general rule, don't solve puzzles that open portals to Hell. 
    -- Ralph Mason


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

Date: Wed, 21 Feb 2001 16:58:25 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: Thank you! It works. But.....
Message-Id: <RsSk6.14818$Qb7.2367412@newsb.telia.net>

The script is writing to the page, but I'l still got the error message "500
internal server message"

Fabian







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

Date: Wed, 21 Feb 2001 17:06:49 GMT
From: Jozxyqk <jfeuerst@eecs.tufts.edu>
Subject: Re: Thank you! It works. But.....
Message-Id: <JASk6.1899$ce4.869659@typhoon.ne.mediaone.net>

Fabian Thorbj-rnsson <fabian@markisspecialisten.com> wrote:
> The script is writing to the page, but I'l still got the error message "500
> internal server message"

> Fabian


That's because your script isn't printing out any headers.

Just put:

print "Content-type: text/html\n\n";
print "File created successfully\n";

at the end of your file, before (or instead of) exit;






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

Date: Wed, 21 Feb 2001 09:14:18 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Thank you! It works. But.....
Message-Id: <3A93F76A.14E46FD9@stomp.stomp.tokyo>

"Fabian Thorbjörnsson" wrote:
 
> The script is writing to the page, but I'l still got the error message
> "500 internal server message"

This is to be expected. Your script does not provide
a content type header nor any return data to a browser.

Godzilla!
--

#!/usr/bin/perl

print "Content-type: text/plain\n\n";
 
$foo = "/home/markiser/www/foo.html";
 
open( FILE, ">$foo");
print FILE qq(
<html>
<head>
<title>Foo</title>
</head>
<body>
<h1 align=center>Foo foo</h1>
</body>
</html>
);

print "Program Finished\n\n  Open foo.html And Examine Content.";
 
exit;


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

Date: Wed, 21 Feb 2001 12:15:53 -0500
From: Ying Hu <yhu@mail.nih.gov>
Subject: version of Unix operation system
Message-Id: <3A93F7C9.D6869BA2@mail.nih.gov>

Hi,
What function of perl can display the version of Unix operation system?
Any suggestion?
thanks
Ying



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

Date: Wed, 21 Feb 2001 17:43:47 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: version of Unix operation system
Message-Id: <slrn997vij.pu6.peter@uboat.berghold.net>

On Wed, 21 Feb 2001 12:15:53 -0500, Ying Hu <yhu@mail.nih.gov> wrote:
>What function of perl can display the version of Unix operation system?

Try this:

my $os=`uname -s`;
my $version=`uname -r`;
chomp $os;
chomp $version;



-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: 21 Feb 2001 17:41:04 +0000
From: nobull@mail.com
Subject: Re: version of Unix operation system
Message-Id: <u9u25o2atr.fsf@wcl-l.bham.ac.uk>

Ying Hu <yhu@mail.nih.gov> writes:

> What function of perl can display the version of Unix operation system?

POSIX::uname()

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 21 Feb 2001 15:21:42 GMT
From: Alexey Morozov <morozov@novosoft.ru>
Subject: Re: Well, looks like ANOTHER bug in perl-5.6.0
Message-Id: <970me6$2j5g$1@news.itfs.nsk.su>

Steven Smolinski <sjs@linux.ca> wrote:
SS> value3() here is in list context.  Watch it propagate.  value3() returns
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The first and basic thing I missed. Ok.

SS> And what happens to a list with empty lists as elements?  They are left
SS> out:

SS> $ perl -e 'my @flat=(1,2,3,(),( (),(),() ),4); print scalar @flat, "\n";'
Ok, I got it. thank you

SS> This should work.  I thought a hash's keys and values had to be scalar
SS> values, and so couldn't contain an empty list.  So I don't know what
SS> your problem there is.
I got 
'key1' => 'value1'
'key2' => 'value2'
'key3' => 'key4'
undef  => {}



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

Date: Wed, 21 Feb 2001 06:57:15 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Whats wrong with this????
Message-Id: <3A93D74B.1A51488E@stomp.stomp.tokyo>

Eric Provence wrote:
 
> First off, Godzilla!, you are totaly wrong. It does run. 

You are full of crap, Bud. Screw off.

Godzilla!


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

Date: Wed, 21 Feb 2001 15:18:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Whats wrong with this????
Message-Id: <qum79tknef2h3nqmlb3th3268klvpdhhhs@4ax.com>

Eric Provence wrote:

>open (NEWPOST, ">$subject");

You better check

 A) What $subject is, and if you can even use it as a file name. Imagine
a subject like "s/a/b/ doesn't work". Is it even safe? What if people
start a new thread with an existing subject line, such as "help!"?

 B) The error code if it fails.

	open (NEWPOST, ">$subject")or
	  die "Cannot write to '$subject'": $!";

-- 
	Bart.


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

Date: Wed, 21 Feb 2001 18:30:08 -0000
From: Eric Provence <infinityzone@hotmail.com>
Subject: Re: Whats wrong with this????
Message-Id: <t9829gop6c4sc9@corp.supernews.com>

I'll be re-writing the script in about 281 days to make it better. I'm 
just writing this as a temporary thing. See, the person i'm writing this 
message board for is using a VirtualAve.net free webspace account. And as 
some of you know, it has the capability for perl, but they don't tell you 
what the machine path is, so I gotta keep this all in the same folder. And 
theres a ton of other reasons why I'm writing it the way I am, but I fear 
it would take everyone too long to read them all, :).

Eric

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Wed, 21 Feb 2001 14:57:05 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: Write to a text file works, but not to an html file.
Message-Id: <5HQk6.14789$Qb7.2364645@newsb.telia.net>


How can i get a perl script to write anything to an html page.
Can anyone give me the simplyest example script?

Is it possible to write anything to a totally empty html file
--
MVH
Markisspeciaisten
Fabian Thorbjörnsson
08-252500




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

Date: Wed, 21 Feb 2001 16:14:05 +0100
From: "Peter Søgaard" <peter.s@tjgroup.dk>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <970lph$qqd$1@news.inet.tele.dk>

I don't think the procedure is any different from writing to a text file:

open( FILE, ">foo.html");
print FILE qq(
<html>
<head>
<title>Foo</title>
</head>
<body>
<h1 align=center>Foo foo</h1>
</body>
</html>
)





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

Date: Wed, 21 Feb 2001 15:22:31 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <X2Rk6.14795$Qb7.2365153@newsb.telia.net>

I tryed to put this file foo.html in the same directory (Cgi-bin ) as the
script. Added the correct path to perl on top. Set the pl file to chmod 755
and the html file to 777. = Internal server error.

"Peter Søgaard" <peter.s@tjgroup.dk> skrev i meddelandet
news:970lph$qqd$1@news.inet.tele.dk...
> I don't think the procedure is any different from writing to a text file:
>
> open( FILE, ">foo.html");
> print FILE qq(
> <html>
> <head>
> <title>Foo</title>
> </head>
> <body>
> <h1 align=center>Foo foo</h1>
> </body>
> </html>
> )
>
>
>




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

Date: Wed, 21 Feb 2001 16:38:26 +0100
From: Matthias Papesch <mpapesch@gmx.de>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <970nc8$e7n$07$1@news.t-online.com>

Hi,

Do you have write permissions to the cgi-bin directory?

Does the user under which the web-server runs have write permissions to the 
cgi-bin directory?

Try executing the script from the command line as both of these users in 
the cgi-bin directory and check the error messages, also check the web 
server error log file.

HTH,
Matthias

Fabian Thorbjörnsson wrote:

> I tryed to put this file foo.html in the same directory (Cgi-bin ) as the
> script. Added the correct path to perl on top. Set the pl file to chmod
> 755 and the html file to 777. = Internal server error.
> 
> "Peter Søgaard" <peter.s@tjgroup.dk> skrev i meddelandet
> news:970lph$qqd$1@news.inet.tele.dk...
> > I don't think the procedure is any different from writing to a text
> > file:
> >
> > open( FILE, ">foo.html");
> > print FILE qq(
> > <html>
> > <head>
> > <title>Foo</title>
> > </head>
> > <body>
> > <h1 align=center>Foo foo</h1>
> > </body>
> > </html>
> > )
> >
> >
> >
> 
> 




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

Date: Wed, 21 Feb 2001 16:21:21 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <5WRk6.14810$Qb7.2366210@newsb.telia.net>

I have also tryed with the path "http://www........., but it does'nt worked.
Chmod 777 on the file foo.html which is placed directly under www (the roth)
and does'nt contain anything.
Chmod 755 on the perl.pl script which is placed in the cgi catalog.
I have no ploblems with other scrips (like guestbooks)

Fabian


This is my whole script. = Internal server error:


#!/usr/bin/perl

$foo = "/home/markiser/www/foo.html";

open( FILE, ">$foo");
print FILE qq(
<html>
<head>
<title>Foo</title>
</head>
<body>
<h1 align=center>Foo foo</h1>
</body>
</html>
)

exit;




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

Date: Wed, 21 Feb 2001 08:41:09 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <3A93EFA5.81B71B9E@stomp.stomp.tokyo>

"Fabian Thorbjörnsson" wrote:

(snippage)
 
> but it does'nt worked.

> This is my whole script. = Internal server error:
 
> #!/usr/bin/perl
 
> $foo = "/home/markiser/www/foo.html";
 
> open( FILE, ">$foo");
> print FILE qq(
> <html>
> <head>
> <title>Foo</title>
> </head>
> <body>
> <h1 align=center>Foo foo</h1>
> </body>
> </html>
> )
 
> exit;


Add a semicolon after your final right parenthesis,

 </html>
 );  <---- add this semicolon

and your posted script will run as it should.

Godzilla!


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

Date: Wed, 21 Feb 2001 12:32:43 -0500
From: John Crowley <crowj@aol.com>
Subject: Re: Write to a text file works, but not to an html file.
Message-Id: <3A93FBBB.C779C3A2@aol.com>

"Fabian Thorbjörnsson" wrote:
> 
[snip] 
> This is my whole script. = Internal server error:
> 
> #!/usr/bin/perl
> 
> $foo = "/home/markiser/www/foo.html";
> 
> open( FILE, ">$foo");
> print FILE qq(
> <html>
> <head>
> <title>Foo</title>
> </head>
> <body>
> <h1 align=center>Foo foo</h1>
> </body>
> </html>
> )
> 
> exit;

this isn't a perl problem.  you're web server is not configured to run
cgi.  try a cgi newsgroup.


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

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 V10 Issue 328
**************************************


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