[19418] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1613 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 25 21:10:27 2001

Date: Sat, 25 Aug 2001 18:10:10 -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: <998788210-v10-i1613@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 25 Aug 2001     Volume: 10 Number: 1613

Today's topics:
    Re: Perl rookie question!  Setting up perl to work with <somewhere@in.paradise.net>
    Re: pl or not pl, that is the question (Abigail)
    Re: Question about GD (Martien Verbruggen)
    Re: Question about GD <barna@megapage.ch>
    Re: qw// documentation revision (was Re: Openning a fil (Abigail)
    Re: Read/write specific line of file (Eric Bohlman)
    Re: String replacements using s/// <krahnj@acm.org>
    Re: This has got to be a bug <arthur@ablair.physics.wisc.edu>
        Tie and complex hashes <mark.riehl@agilecommunications.com>
    Re: Wait for single key press (Chas Friedman)
    Re: Wait for single key press <Tassilo.Parseval@post.rwth-aachen.de>
        Warning Question <mark.riehl@agilecommunications.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 26 Aug 2001 10:26:16 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Perl rookie question!  Setting up perl to work with IIS or Personal Web Server
Message-Id: <9oXh7.1$mj4.28701@news.interact.net.au>


"S Warhurst" <s.warhurst@rl.ac.uk> wrote in message
news:9m2hgs$14cg@newton.cc.rl.ac.uk...
> "Tintin" <somewhere@in.paradise.net> wrote in message
> news:lNVg7.11$w01.56376@news.interact.net.au...
> > > The line:  #!/usr/bin/perl is for unix.
> > >
> > > You need sth like:  #!c:/perl/bin/perl.exe
> >
> > Rubbish!  Don't answer questions that are off topic and don't give
> incorrect
> > answers.
>
> 1) "/usr/bin" is a unix style path.. and if I get the drive wrong in the
> "c:/perl/bin/perl.exe" path when switching between different NT machines
> with different perl locations my CGI throws up errors, so my answer was at
> least partly correct.

No, your answer was completely incorrect.  It doesn't matter what you put in
the she bang line if you use IIS or PWS (apart from the Perl flags).

>
> 2) His post is about Perl.. maybe the cause of his problem is the
enviroment
> Perl is running in, but he doesn't know that and he has to start somewhere
> to find out. It always amuses me about some newsgroups.. on the one hand
you
> get some great selfless ppl who spend their valuable time helping solve
> other people's problems, and on the other there are people like you who
seem
> to think it is their place to go round "policing" the newsgroup, and do so
> in the most unhelpful way possible. If you think it's off-topic then why
are
> you reading it?

The OP's post is about how to set up IIS or PWS to use Perl CGI scripts.
This is covered very clearly in the appropriate FAQs.

>
> 3) If you are going to accuse someone of being incorrect then at least
have
> the decency to say "why" you think they are. I don't mind being corrected
> and welcome it as long as in doing so is decent about it. Similarly, if
you
> accuse someone with a genuine query of being off-topic, then say why.

OK, here is the answer from the FAQ.  I really shouldn't have to post it,
but it is here in its full glory, so you can see it has nothing to do with
Perl.

To configure IIS or PWS 4.0 to run Perl scripts:

Open the IIS 4.0 Internet Service Manager. This will bring up the Microsoft
Management Console with the Internet Service Manager snap-in selected.

From the tree display on the left, select the level at which to apply the
mappings. You can choose an entire server, web site, or a given virtual
directory.

Select Properties from the Action menu.

If you chose to administer the properties for the entire server, the Server
Properties dialog will appear. Select WWW Service from the Master Properties
pull-down menu and click the Edit button under Master Properties. This opens
WWW Service Master Properties. Select the Home Directory tab and proceed to
step 7.

If you chose to administer the properties for an entire web site, the Web
Site Properties sheet appears. Select the Home Directory tab and proceed to
step 7.

If you chose to administer the properties for a virtual directory, the
Virtual Directory Properties sheet appears. Select the Virtual Directory tab
and proceed to step 7.

Click the Configuration button. This opens the Application Configuration
dialog.

Select the App Mappings tab and click the Add button. You see the Add/Edit
Application Extension Mapping dialog.

To run Perl as a CGI application, type the full path to Perl.EXE followed by
%s %s. When a script is executed, the first %s will be replaced by the full
path to the script, and the second %s will be replaced by the script
parameters.

To run Perl for ISAPI, type the full path to PerlIS.DLL. The %s %s is not
required for ISAPI DLLs.

In the Extension field, type .pl or .plx (or whatever extension you want to
use).

The application mapping is now complete. Click the OK button and click OK to
dismiss any remaining dialogs/property sheets.

Close the IIS 4.0 Internet Service Manager.

Because IIS runs as a service (see What is a Windows NT service?), you need
to take special steps to make sure that files and environment variables are
available to it.


> 4) Don't tell me what to do.. you are nobody to me, so fuck you.

I have the right to correct postings to newsgroups, you have the right to
whatever opinion you like of me.  Freedom of speech.






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

Date: 25 Aug 2001 23:05:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: pl or not pl, that is the question
Message-Id: <slrn9ogbqi.em5.abigail@alexandra.xs4all.nl>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMCMXVI September
MCMXCIII in <URL:news:m13d6hx8rk.fsf@halfdome.holdit.com>:
!! >>>>> "Ilya" == Ilya Martynov <ilya@martynov.org> writes:
!! 
!! Ilya> .pl as 'perl library' was valid in Perl 4 days. Nowdays people
!! Ilya> (including me) often use .pl for scripts. I think it is ok.
!! 
!! Do you put .sh on the end of all your shell scripts, and .py on the
!! end of all your python programs?

Uhm, yes, I do.

!!                                   And do you rename /bin/cat to
!! /bin/cat.o?  It's an object file after all!  And what happens
!! if you change the implementation from Perl to shell?  Do you have
!! to readjust all the invokers of your commands?
!! 
!! I'm of the firm belief that a *command* (aka "program") should *not*
!! have the implementation language embedded in the path.  And I'm not
!! the only one out there.  Why should I care when I invoke your program
!! that it was shell or Perl or C originally?  I just care about the
!! interface!
!! 
!! Also, if it's in the path, and that path is used for CGI, then it
!! gives away a potential exploit.  For example, if I'm a bad guy, and I
!! discover that many Python scripts can be broken by typing "FOO" into a
!! form box, then I'll look for "_____.py" in paths using a search
!! engine.  Instant hole, because you've given away more than you need to
!! give away.

Most people don't believe in security through obscurity. But I guess 
some people do. Not that I really care. I name my Perl programs foo.pl -
and they are 100% CGI free anyway.

But I just went to your website, and was I amazed. I found images with
 .gif and .jpg extensions. Why do you care what kind of image it is?
Do you want to readjust your html pages if you decide to make your site
GIF free and use PNG? The information what kind of image it is, is all
in the magic bytes too - Unix doesn't need extensions!

!! Please stop with this nonsense about "Perl scripts are named .pl".
!! Maybe they *must* be on stupid operating systems that need to use
!! extensions, but *not* under Unix.  Unix doesn't need extensions to
!! determine executable file types.  It's all in the first two bytes,
!! baby!

Just because Unix doesn't need extensions to determine executable file
types, doesn't mean extensions cannot be handy. Oh, besides, Unix doesn't
use the first two bytes to determine whether a file is executable - that's
what file permissions bits are for. Unix only uses the first two bytes
to determine what kind of execution it is. Not that '#!' tells Unix it's
a Perl program. It still might be a Python program, or a shell program.

But I don't give a fuck that Unix peeks into the first two bytes of a file.
I'm a human, and I prefer efficiency. Given a directory listing, I don't
want to open 50 files, inspect the first two bytes, and the complete line
if the first two bytes are '#!' to determine what kind of files they are.
I'd rather have .pl, .py, .c and .png.

Heh, why give your files descriptive names? For Unix, they're just inodes
anyway!



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Sun, 26 Aug 2001 08:11:19 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Question about GD
Message-Id: <slrn9og8k6.3ga.mgjv@martien.heliotrope.home>

On Sat, 25 Aug 2001 19:43:38 +0200,
	Bernhard Schelling <barna@megapage.ch> wrote:
> Hi all,
> 
> I have a really big image, and i only need a piece of the big image
> everytime a web page is accessed.
> Now im not sure what's the fastest way to cut it out.
> 
> I have infinite diskspace and a mysql database on a linux system, so I
> ask you, what should i do?

In the case of infinite disk space, I would store every possible
conceivable way of slicing a part of the image on disk, preprocessed, in
an uncompressed format, and directly serve it up with the web server.
That's the fastest. You might need some directory hierarchy to keep
performance up.

It's hard to tell what is best, because you don't give enough
information. Are those pieces of the larger piece always the same? In
other words, are the coordinates that determine the smaller images,
relative to the larger a predetermined static set of coordinates? For
example, if the sub-images are always the same size, and can't overlap,
you can slice your main image with a grid, and pre-store all those
images. However, if either coordinate can come from the user, this would
require fairly large, althouh finite, amounts of disk space.

We also don't know enough about the boundaries of the problem. How large
is the pargest image? How small the smallest sub-image? What is the most
frequently needed size?

> - Use one big PNG file, load it, and copy the piece into another image
> ($image->copy(..)) (really slow, I tried that first)
> - Use one big GD file, and do it like the one above

This is bound to be faster, since there is no conversion necessary. If
you use this, use the GD2 format, which allows you to even read small
bits.

> - Use more smaller PNG file, load only the needed one (or multiple files
> if its over a border) and copy them together (thats what i'm doing now
>:-)

This, to me suggests that there is a grid that these subimages have to
fit in. If so, then you can pre-generate all possible images, and there
shouldn't be that many. And in that case, you don't need to copy and
stuff, on the fly. You just pick the right image.

> - Use a GD2 File and use ->newFromGd2Part(..) (is that fast??)

I'd say this is probably the fastest if you have to do it dynamically,
_unless_ your main image is really, really really large, and the
subimages are really, really, really small. In that case you might want
to use some intermediate solution, where you store images of
intermediate size, and assemble them into a larger, or load part for
smaller images.

> - Copy the big PNG file in the database as GD Format and load it with
> GD::Image->new($datafromdatabase) and copy the piece

Nope. Adding database access is nto going to make it faster than a file
system. Goinf back to PNG is not going to make it faster than using GD2
format (unless you have very slow or very very busy disks and not enough
file cache memory).

> - another way?

Hard to tell. Not enough information to make guesses. Not enough time to
do the benchmarks for you.

Anyway, I got this far:

use Benchmark;
use GD;

Maybe you want to finish it? :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: Sun, 26 Aug 2001 03:04:44 +0200
From: Bernhard Schelling <barna@megapage.ch>
Subject: Re: Question about GD
Message-Id: <3B884B2C.166D2E83@megapage.ch>

Thanks a lot for your answer, I will benchmark the GD2 version

Some more information:
The big image is now 5896 x 5704, maybe it changes in some months or years,
but thats not important now...
The small clip can be anything from 50x50 to 300x300 and starts at any pixel
coordinate in the big image.

Now I have 16 files (each 1474x1426), and i load just the needed files, so it
loads 4 files in the worst case. Its faster than one file, but I hope to get
it faster. Maybe I should slice it up into 300x300 pieces, so it still needs 4
files in the worst case...




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

Date: 25 Aug 2001 22:39:02 GMT
From: abigail@foad.org (Abigail)
Subject: Re: qw// documentation revision (was Re: Openning a file)
Message-Id: <slrn9oga8d.em5.abigail@alexandra.xs4all.nl>

Ren Maddox (ren@tivoli.com) wrote on MMCMXV September MCMXCIII in
<URL:news:m3itfd5t1l.fsf_-_@dhcp9-161.support.tivoli.com>:
~~ 
~~ Shows that the behavior is the same as the comma operator.  The
~~ current (5.6.1) documentation:
~~ 
~~ should be changed to something like:
~~ 
~~ Comments?


Please send patches to p5p. Discussion here doesn't have any effect
until someone sends a patch to p5p.



Abigail
-- 
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];


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

Date: 25 Aug 2001 18:10:44 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Read/write specific line of file
Message-Id: <9m8pn4$b0g$1@bob.news.rcn.net>

Mario Rizzuti <mariorizzuti@yahoo.com> wrote:
> Mantaining an index file has just a problem: when the length of a
> record changes, all the offsets of the records following need to be
> updated. This can be an huge task if the records are a lot.

The usual way around this to simply write a new record, of the appropriate 
length, to the end of the main file and change the index file entry to 
point to it.  You'd periodically "pack" the main file and rebuild the 
index file.  Obviously this won't work very well if you have a very large 
file where records need to be changed very frequently, but in that case 
variable-length files are simply the wrong tool for the job anyway.



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

Date: Sat, 25 Aug 2001 19:38:19 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: String replacements using s///
Message-Id: <3B87FF1B.C769F0C@acm.org>

Jeff Snoxell wrote:
> 
> Can anyone explain why this:
> 
> $start = "This is a string, which I want, hopefully, to turn into a keyword
> list. Hopefully."
> 
> $commaspace = ', ';
> $dotspace       = '. ';
> $dot               = '.';
> $space            = ' ';
> 
> $start =~ s/$commaspace/$space/g;
> $start =~ s/$dotspace/$space/g;
> $start =~ s/$dot/$space/g;
> $start =~ s/$space/$commaspace/g;
> 
> gives this:
> 
> $start = "Thi, i, , string, whic, , want, hopefully, t, tur, int, , keywor,
> list, Hopefully, ";
> 
> instead of what I want which is:
> 
> $start = "This, is, a, string, which, I, want, hopefully, to, turn, into, a,
> keyword, list, Hopefully, ";


$start =~ s/(\w+)\W+/$1, /g;



John
-- 
use Perl;
program
fulfillment


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

Date: 25 Aug 2001 18:11:36 GMT
From: art blair <arthur@ablair.physics.wisc.edu>
Subject: Re: This has got to be a bug
Message-Id: <9m8poo$hj4$1@news.doit.wisc.edu>

Thanx to all. \Q \E worked. 
I need to get a better perl book.

Art.


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

Date: Sat, 25 Aug 2001 20:36:01 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Tie and complex hashes
Message-Id: <R_Th7.1053$tS5.979870@typhoon2.gnilink.net>

All - I've got a data structure that looks like the following:

# %RxTxData = (
#      urn => {
#        my_display => {
#             k1 =  {time=>8456823,  latitude=>35.311,
longitude=>-116.4101, },
#             k2 = {time=>8456824,  latitude=>35.312,
longitude=>-116.4201, },
#             k3 = {time=>8456825,  latitude=>35.313,
longitude=>-116.4301, },
#                   },
#        statistics => {
#             k1 = {this_time=>8451234, visibility=>100, actual=>12,
expected=>12, accuracy=>456, },
#             k2 = {this_time=>8451234, visibility=>100, actual=>12,
expected=>12, accuracy=>456, },
#             ke = {this_time=>8451234, visibility=>100, actual=>12,
expected=>12, accuracy=>456, },
#                   },
#        last_sa_time,
#        last_latitude,
#        last_longitude,
#             },
#              );

I'd like to use Tie so that I can print the hash using insertion order.
I've used Tie before, but not on nested hashes.

I'm using

tie %RxTxData, "Tie::IxHash";

at global scope, but I'm assuming that it applies only to the keys at the
top level.  How do I use Tie for one of the nested hashes, for example:

$RxTxData{$key}{statistics}{$key2}

Thanks,
Mark




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

Date: Sat, 25 Aug 2001 21:36:31 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: Wait for single key press
Message-Id: <3b8819dd.178258268@news.itouch.net>

On 24 Aug 2001 17:24:01 GMT, "Christian Brink" <cb@onsitetech.com>
wrote:

>Perldoc is your friend -
>
>'perldoc -q key' will get you your answer (It's the 5th FAQ)
>
>"Florian Haftmann" <florian@haftmann-online.de> wrote in message
>news:3B867D3F.EA270E8F@haftmann-online.de...
>> Hi!
>>
>> I'm writing a perl script that from time to time outputs information on
>> the console to the user;
>> between to section, I want the script to halt and wait for one key press
>> (indicating the user has finished reading).
>> The whole should run under Win32.
>> Any ideas?

You could put a line of the form:
<>;
in your script. This will cause the script to wait for input;
any input (e.g.<Return>) will let the script continue.



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

Date: Sun, 26 Aug 2001 00:14:54 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Wait for single key press
Message-Id: <3B88235E.6080308@post.rwth-aachen.de>

Chas Friedman wrote:

> You could put a line of the form:
> <>;
> in your script. This will cause the script to wait for input;
> any input (e.g.<Return>) will let the script continue.

It will continue *only* if there's a return.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sat, 25 Aug 2001 18:46:18 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Warning Question
Message-Id: <_nSh7.1027$tS5.909246@typhoon2.gnilink.net>

All - I'm reading from a CSV file, using strict and diagnostics.  I'm
getting a warning on the input that I can't seem to resolve:

$_ = 591347,097 20:15:56.311,8453756,1000896,R,-116.575062,35.350251
Use of uninitialized value in numeric ne (!=) at new_kpp_jev2.pl line 401,
        <INPUT> line 2 (#1)


I'm printing out the current line of my input file ($_) and my input file is
named INPUT.  I'm tracking down the uninitialized warning, but what is the
<INPUT> line 2 (#1)?

Does this refer to the first field on line 2 in the input file?

Thanks,
Mark




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1613
***************************************


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