[12216] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5816 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 28 12:07:21 1999

Date: Fri, 28 May 99 09:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 28 May 1999     Volume: 8 Number: 5816

Today's topics:
    Re: Alternative to deprecated scalar split (Clinton Pierce)
    Re: Beginner needs help <jdporter@min.net>
    Re: Can someone help me on this challenging problem? <uyv_IGNORE_r@hotmail.com>
    Re: Can someone help me on this challenging problem? <uri@sysarch.com>
        CGI.pm or CGI-LIB.pl <dominikl@pyramid.de>
    Re: conver TO url encoded <mark@artdigital.co.uk>
        Converting a string to URL Encoding (Daniel)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Sitaram Chamarty)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Sitaram Chamarty)
        How do I prevent a CGI timeout? <m.j.phillips@shef.ac.uk>
    Re: How do I prevent a CGI timeout? <burton.not.spam@lucent.com>
        Incrementing a value in a slice (Kate)
    Re: Incrementing a value in a slice (Greg Bacon)
    Re: Incrementing a value in a slice (Kate)
    Re: Incrementing a value in a slice <gellyfish@gellyfish.com>
        mailing <fruffet@kaptech.com>
    Re: mailing <gellyfish@gellyfish.com>
    Re: Newbie: Line spacing <gellyfish@gellyfish.com>
    Re: parsing a file <jdporter@min.net>
        PB writing an uploaded file in perl (size changes!) <olivier.maas@at-lci.com>
    Re: PB writing an uploaded file in perl (size changes!) <gellyfish@gellyfish.com>
    Re: PB writing an uploaded file in perl (size changes!) <craig@mathworks.com>
    Re: perl script as an executable (Steve Vertigan)
    Re: perl script as an executable <gellyfish@gellyfish.com>
    Re: pre-allocating memory needs in perl? <craig@mathworks.com>
    Re: pre-allocating memory needs in perl? (Sam Holden)
    Re: Question about date <gellyfish@gellyfish.com>
    Re: Splicing and the current position in and foreach lo (M.J.T. Guy)
    Re: thread vs process <jkit@jpmorgan.com>
        Tying a double knot in a hash <burton.not.spam@lucent.com>
    Re: What's wrong with this hit counter? (Greg Bacon)
    Re: What's wrong with this hit counter? <gellyfish@gellyfish.com>
    Re: What's wrong with this hit counter? <uri@sysarch.com>
    Re: Y2K infected Perl code <jeromeo@atrieva.com>
    Re: Y2K infected Perl code <gellyfish@gellyfish.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 28 May 1999 14:54:56 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Alternative to deprecated scalar split
Message-Id: <374eadfe.1212132744@news.ford.com>

On 28 May 1999 14:18:35 GMT, John Siracusa <macintsh@cs.bu.edu> wrote:
>"implicit split to @_ is deprecated" according to the docs.
>Fine, but what do I do when I *want* to use split in a scalar
>context?

Obviously, it's a conspiracy, and it goes all the way to the top.

"Hey, I had to let awk be better at *something*...  :-)"
             -- Larry Wall in <1991Nov7.200504.25280@netlabs.com>


-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Fri, 28 May 1999 15:39:41 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Beginner needs help
Message-Id: <7imdbt$nbb$1@nnrp1.deja.com>

In article <374DE50B.51CB@uiuc.edu>,
  thomaslo@uiuc.edu wrote:
> We have some problems displaying PDF files in the secure section of
our
> site. Everything seems to work fine when you click on the link to a
PDF
> file, and Adobe Acrobat Exchange/Reader would load itself up, and
after
> that false hope, it would say it can't open the file. The file is OK
> too.
>
> } elsif ($inputfile ne "" && isElementInArray($extension,
> @protect_pdf_ext) && $is_group_filter_passed) {
>     print "Content-type: application/pdf\n\n";
>     open(PDFFILE, "<$protect_pdf_dir/$filename") ||
>       &CgiDie("Could not open $protect_pdf_dir/$filename");
>     while (<PDFFILE>) {
>         print $_;
>     }
>     close (PDFFILE);

You probably shouldn't print the Content-type header until you
know for sure that you're actually going to be sending PDF data.
I.e. wait until after the open() succeeds.  Something like this:

  if ( open PDFFILE, "< ..." ) {
    print "Content-type: application/pdf\n\n", <PDFFILE>;
    close PDFFILE;
  }
  else {
    print "Content-type: text/html\n\n";
    CgiDie("Could not open $protect_pdf_dir/$filename");
  }

Any good reason you're not using CGI.pm?

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 28 May 1999 10:03:04 -0500
From: "Ralph Emerson" <uyv_IGNORE_r@hotmail.com>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <7imb9u$379@sjx-ixn6.ix.netcom.com>

It's not like I'm not into buying books (I have my own psydo-library of 21
days this, unleashed that,  'Practical' to 'Developer's'), but because of
reasons out of my control, I will not be getting any new books for a long
time + I don't allready have an algorithm book.  I searched on
hotbot/yahoo/excite/dogpile for it, but all the sites were very superfluous
with a lot of things that I didnt' know.  As such, could you please explaine
what that is.

> ....Try to use the Breadth-First
>Search algorithm. It will do fine and should be quick enough for 5000
>nodes. If I remember correctly, its time complexity is O(n+m), where
>n is the number of nodes and m is the number of edges.
>Any book on Data Structures and Algorithms, chapter Graphs.




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

Date: 28 May 1999 11:47:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <x7lne9i4bq.fsf@home.sysarch.com>

>>>>> "RE" == Ralph Emerson <uyv_IGNORE_r@hotmail.com> writes:

  RE> It's not like I'm not into buying books (I have my own
  RE> psydo-library of 21 days this, unleashed that, 'Practical' to
  RE> 'Developer's'), but because of reasons out of my control, I will
  RE> not be getting any new books for a long time + I don't allready
  RE> have an algorithm book.  I searched on hotbot/yahoo/excite/dogpile
  RE> for it, but all the sites were very superfluous with a lot of
  RE> things that I didnt' know.  As such, could you please explaine
  RE> what that is.

sounds like you wasted a lot of money on bad books. if you don't know
basic algorithms like searching, sorting, graphs, then know wing them
will be far more valuable than any book price. they are fundamental
tools that every programmer should know. in fact if there were a
certification for programmers it would be a maijor way to weed out the
script kiddies and newbies who think they are programmers.

  >> ....Try to use the Breadth-First
  >> Search algorithm. It will do fine and should be quick enough for 5000
  >> nodes. If I remember correctly, its time complexity is O(n+m), where
  >> n is the number of nodes and m is the number of edges.
  >> Any book on Data Structures and Algorithms, chapter Graphs.

you might find some info on algorithms on the web for free. describing
this one would take too long for me and it is probably described better
elsewhere. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 28 May 1999 17:19:16 +0200
From: Dominik Leinfelder <dominikl@pyramid.de>
Subject: CGI.pm or CGI-LIB.pl
Message-Id: <374EB3F4.43A504CD@pyramid.de>

Hello,

I have to create some webbased aplications with perl and want to know,
which of the both
ways are more preferable considering security and performance...

any hints for me?

Regards!

Dominik



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

Date: Fri, 28 May 1999 16:15:45 +0100
From: "Mark Hamlin" <mark@artdigital.co.uk>
Subject: Re: conver TO url encoded
Message-Id: <7imbv4$gtj$1@pheidippides.axion.bt.co.uk>

[snip]

>Apparently you're not famililar with the concept of modules, nor the
>fact that huge number of extremely useful ones come as part of your
>perl installation, and many more are available on CPAN (reachable
>via www.perl.com).

I am familiar with modules, but because I do not have a dedicated server,
their installation can be pricey if not tricky.

>
>In this case you want to check out the URI::Escape module.
>(Read its documentation with the 'perldoc URI::Escape' command.)
>
>
>> Saver me getting sick on regexp.
>
>Good, that's your body trying to tell you something.
>

yep - in fact the exact quote was 'gurgle.... Ice cream, sunshine and warm
women go down a lot better.. rumble rumble.....'

>--
>John Porter
>Put it on a plate, son.  You'll enjoy it more.
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.




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

Date: Fri, 28 May 1999 15:26:25 GMT
From: daniel.mendyke@digital.com (Daniel)
Subject: Converting a string to URL Encoding
Message-Id: <7imbvo$i$1@nntpd.lkg.dec.com>


I must have found dozens of scripts that convert from url encoding
to text but I have not found one that converts text to url encoding.

Can anyone point me to some code that converts plain text
into a url encoded string?

-Daniel



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

Date: Fri, 28 May 1999 15:56:33 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7ktdre.1ng.sitaram@diac.com>

On Fri, 28 May 1999 09:44:50 GMT, Eric Bohlman
<ebohlman@netcom.com> wrote:

>order to stay competitive.  The Perl community has (rightly IMHO) shown 
>little interest in trying to make the language more "accessible" to 
>people who simply want to claim credentials as fast as possible without 
>doing their homework.

Yes.  Even as late as 2 years ago, Perl (and Linux - in this
context they are related) used to "keep the riffraff out" - as
someone's tagline said :-)

Sadly, this is not true any more.  It's nice that the quantity of
interest has gone up, but that usually means quality goes down!

>There is a view, frequently and sometimes unfairly attributed to 
>Microsoft, that a computer program, language, etc. should be designed so 
>that a newbie can make full use of it *while remaining a newbie*; that no 
>learning should be required.  This is *not* part of the Perl philosophy, 
>which holds that learning the language increases one's power.

And increasing one's power (should) always imply increasing one's
responsibility, too.


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

Date: Fri, 28 May 1999 15:56:34 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7kteal.1ng.sitaram@diac.com>

On 28 May 1999 05:07:49 GMT, I R A Aggie
<fl_aggie@thepentagon.com> wrote:

>Time for a Wall-ism...
>
>Many computer scientists have fallen into the trap of trying to define
>languages like George Orwell's Newspeak, in which it is impossible to
>think bad thoughts. What they end up doing is killing the creativity
>of programming.

"It is impossible to make anything foolproof because fools are so
ingenious" - I forgot who

"Make a system that any fool can use, and only fools will use it"
- I again forget who ;-)

I hope Jocelyn's next flight is on a plane that has been
"fool-proofed" so much that the airline lets anyone fly it ;-)
Happy landings, Jocelyn!


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

Date: Fri, 28 May 1999 15:48:05 +0100
From: "Dr Marcus Phillips" <m.j.phillips@shef.ac.uk>
Subject: How do I prevent a CGI timeout?
Message-Id: <7imafd$ncb$1@bignews.shef.ac.uk>

To anyone who can help...

How do I prevent a perl CGI from timing out and the browser saying "Document
contains no data"? I have a data analysis program which on some of the more
complicated analysis slows down sufficiently to give this problem. I try to
output data regularly via "print" but this does not seem to work. The
process itself continues even after the browser gives up!

Thanks in advance

Marcus



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

Date: Fri, 28 May 1999 10:44:12 -0500
From: Burton Kent <burton.not.spam@lucent.com>
To: Dr Marcus Phillips <m.j.phillips@shef.ac.uk>
Subject: Re: How do I prevent a CGI timeout?
Message-Id: <374EB9CC.459A1632@lucent.com>

If you haven't unbuffered stdout, then the perl
program will hold onto the output.  I think
the command is $/ = '' or $\=''

Burton

Dr Marcus Phillips wrote:
> 
> To anyone who can help...
> 
> How do I prevent a perl CGI from timing out and the browser saying "Document
> contains no data"? I have a data analysis program which on some of the more
> complicated analysis slows down sufficiently to give this problem. I try to
> output data regularly via "print" but this does not seem to work. The
> process itself continues even after the browser gives up!
> 
> Thanks in advance
> 
> Marcus


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

Date: 28 May 99 15:06:34 GMT
From: kate_no_spam@for_me_chiso.com (Kate)
Subject: Incrementing a value in a slice
Message-Id: <8DD46B23CXXkateXX@news.chiso.com>

Hello,

I'm fairly new to Perl, so I apologize if this is an often asked question. 
I have read through the FAQ and several manuals and haven't seen examples 
of what I am trying to do.

I basically want to read through a text file line by line, place each 
unique line in an array. When I hit a duplicate line, I want to increment a 
value in my array so I can keep track of how many times that line is 
duplicated. I'm not sure if I should be using a List of Lists or a Hash for 
this (like I said, my exposure to Perl is limited).

I know that to print out all elements of an array, I would use something 
like this:

for $i (0 .. $#UniqueLines)
{
   for $j ( 0 .. $#{$UniqueLines[$i]} )
   {
      print $UniqueLines[$i][$j];
   }
}

I tried to do something similar to this to change the value of a slice. I 
haven't found any examples on how to do this, just how to print out. So I 
came up with this:

while ($line = <INPUTFILE>)
{
 for $i (0 .. $#UniqueLines)
   {
      if ($UniqueLines[$i] eq $line)
      {
         for $j ( 0 .. $#{$UniqueLines[$i]} )
         {
            $UniqueLines[$i][$j++];
         }
         $duplicate = 1;
         last;
      }
   }
}

Obviously, this doesn't do what I want, so if someone could point me to a 
man page or an area of the FAQ that could help me out, I'd greatly 
appreciate it.

Thanks,
Kate


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

Date: 28 May 1999 15:26:29 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Incrementing a value in a slice
Message-Id: <7imcj5$jh2$3@info2.uah.edu>

In article <8DD46B23CXXkateXX@news.chiso.com>,
	kate_no_spam@for_me_chiso.com (Kate) writes:
: I basically want to read through a text file line by line, place
: each unique line in an array. When I hit a duplicate line, I want to
: increment a value in my array so I can keep track of how many times
: that line is duplicated. I'm not sure if I should be using a List of
: Lists or a Hash for this (like I said, my exposure to Perl is limited).

Please read section four of the Perl FAQ.  Pay careful attention when
you reach "How can I extract just the unique elements of an array?".

Greg
-- 
The first truth is that liberty is not safe if the people tolerate the growth
of private power to the point where it becomes stronger than that of their
democratic state itself. That, in its essence, is Fascism. 
    -- Franklin D. Roosevelt


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

Date: 28 May 99 15:38:20 GMT
From: kate_no_spam@for_me_chiso.com (Kate)
Subject: Re: Incrementing a value in a slice
Message-Id: <8DD4695EFXXkateXX@news.chiso.com>

Greg Bacon <gbacon@cs.uah.edu> wrote in <7imcj5$jh2$3@info2.uah.edu>:

>In article <8DD46B23CXXkateXX@news.chiso.com>,
>     kate_no_spam@for_me_chiso.com (Kate) writes:
>: I basically want to read through a text file line by line, place
>: each unique line in an array. When I hit a duplicate line, I want to
>: increment a value in my array so I can keep track of how many times
>: that line is duplicated. I'm not sure if I should be using a List of
>: Lists or a Hash for this (like I said, my exposure to Perl is limited).
>
>Please read section four of the Perl FAQ.  Pay careful attention when
>you reach "How can I extract just the unique elements of an array?".
>
>Greg

If I do it this way, I'm still not sure how to count how many times an 
entry occurs. Extracting the unique entries isn't my problem, its 
incrementing my counter.

Thanks for the help,
Kate


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

Date: 28 May 1999 16:44:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Incrementing a value in a slice
Message-Id: <374eb9dd@newsread3.dircon.co.uk>

Kate <kate_no_spam@for_me_chiso.com> wrote:
> Greg Bacon <gbacon@cs.uah.edu> wrote in <7imcj5$jh2$3@info2.uah.edu>:
> 
>>In article <8DD46B23CXXkateXX@news.chiso.com>,
>>     kate_no_spam@for_me_chiso.com (Kate) writes:
>>: I basically want to read through a text file line by line, place
>>: each unique line in an array. When I hit a duplicate line, I want to
>>: increment a value in my array so I can keep track of how many times
>>: that line is duplicated. I'm not sure if I should be using a List of
>>: Lists or a Hash for this (like I said, my exposure to Perl is limited).
>>
>>Please read section four of the Perl FAQ.  Pay careful attention when
>>you reach "How can I extract just the unique elements of an array?".
>>
>>Greg
> 
> If I do it this way, I'm still not sure how to count how many times an 
> entry occurs. Extracting the unique entries isn't my problem, its 
> incrementing my counter.
> 

Doh!

while(<>)
{
  chomp;

  $count{$_}++;
}

Ok ?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Fri, 28 May 1999 16:43:27 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: mailing
Message-Id: <7im8af$khb$1@gatekeeper.ornano.kapt.com>

Hi,

One more question for you, community. I am running a perl script on a
marvellous Unix machine, and would like it to send a mail to idiots runing
their jobs on awful Windows platforms. For them not to tell me that Unix is
only able to produce ugly mails, I would like to send them this one using
HTML format. When I send them a HTML page with mail, their "Outlook express"
gives the source (maybe isn't it as intelligent as Bill says...).
I know there are modules for that, but I don't know what module to use !
I know they are described on CPAN pages, but I don't understand all the
terms (poor frenchie...) and abbrevs (poor programmer...) !
I know terms and abbrevs are explained somewhere, but it's so easy to post
to this newsgroup !

I'm stupid not to know how to do, but my intentions are good. Oh, please
help me !

Fred

-Lot of courtesy is a lack of courtesy.
-Maybe should I use more...





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

Date: 28 May 1999 16:26:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: mailing
Message-Id: <374eb59f@newsread3.dircon.co.uk>

Fred Ruffet <fruffet@kaptech.com> wrote:
> Hi,
> 
> One more question for you, community. I am running a perl script on a
> marvellous Unix machine, and would like it to send a mail to idiots runing
> their jobs on awful Windows platforms. For them not to tell me that Unix is
> only able to produce ugly mails, I would like to send them this one using
> HTML format. When I send them a HTML page with mail, their "Outlook express"
> gives the source (maybe isn't it as intelligent as Bill says...).
> I know there are modules for that, but I don't know what module to use !
> I know they are described on CPAN pages, but I don't understand all the
> terms (poor frenchie...) and abbrevs (poor programmer...) !
> I know terms and abbrevs are explained somewhere, but it's so easy to post
> to this newsgroup !
> 

The module MIME::Lite is the one that you want most probably.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 28 May 1999 16:14:52 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Newbie: Line spacing
Message-Id: <374eb2ec@newsread3.dircon.co.uk>

Uri Guttman <uri@sysarch.com> wrote:
> 
> i think we should add the deja.com domain to the list of, if you post
> from there, you don't know perl. i haven't seen any webtv posts here
> yet. my impression is they make aol'er look like einstein. they are so
> stupid, they bought into that service!
> 

We have had some webtv posts there was a rash of them a couple of weeks
ago from various individuals that wanted us to right them a telnet
program that would run in the CGI environment without modules (beats me
too ...)

> do we want to start a newbie of the week (or day or microsecond)
> contest? :-)
> 

Sounds like fun.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Fri, 28 May 1999 15:33:50 GMT
From: John Porter <jdporter@min.net>
Subject: Re: parsing a file
Message-Id: <7imd0u$n0c$1@nnrp1.deja.com>

In article <374E1AFF.448FD683@cis.tamu.edu>,
  Kenneth Oakeson <oakie@cis.tamu.edu> wrote:
> I can't seem to figure out how to parse this file. The file looks like
> this
>
> dog:run
> cat:sleep
> fred:barney
>
> Can anyone show me a way to parse that.

Your instructor did.  Weren't you paying attention?

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 28 May 1999 16:48:48 +0200
From: Olivier Maas <olivier.maas@at-lci.com>
Subject: PB writing an uploaded file in perl (size changes!)
Message-Id: <374EACD0.64F4B094@at-lci.com>

Hello again
I tried to upload a word or excel document,
I now have the filehandle available in my perl script but when I write
the output file, is does not have the same size... ? how come?

I printed the stats of the input and output file handle... they are not
the same size
even thought when I print the length of the buffers printed in the
OUTPUT file, I get to the same total as the original file...
thanks for any help, if possible send a copy of answer to maas@ensae.fr
thanks...

here is my script :

##########################################################
#!/bin/perl
push(@INC,'C:\Perl');
require("CGI.pm");
use CGI qw(:standard);

#########
#Creation de la page de reponse
#########

$html= CGI->new ;
print $html->header ;

#########
#Recuperation des parametres passes en argument
#########


$FichAT=CGI::param(FichierATraiter);    #this gets the filehandle of the

(e.g.) word file

#Les lignes qui suivent construisent un fichier HTML
 print "<HTML>\n";
 print "<HEAD>\n";
 print      "<TITLE> hello </TITLE>\n";
 print "</HEAD>\n";
 print      "<BODY TEXT=#FFFF00 BGCOLOR=#000000 >\n";
 print      "\n";

 open(OUTFILE, ">c:/temp/testfile.doc"); # ok, I know, I should better
put
                                                                # the
original name but I have not yet
                                                                #thought

of how to "cut" the directory string


 undef $Buffer;
 undef $BytesRead;

 while ($Bytes = read($FichAT,$Buffer,2048)) {
                        $BytesRead += $Bytes;
            print OUTFILE $Buffer;
        }
@sta=stat($FichAT);
print "@sta <BR>";

@sta=stat(OUTFILE);
print "@sta <BR>";

 close($FichAT);
 close(OUTFILE);


 print " fichname : $FichAT <BR>\n";
 print " taille : $BytesRead Bytes <BR>\n";

 #######
 #terminer le fichier HTML
 #######
 print  "\n";
 print  "</BODY>\n";
 print  "</HTML>\n";
#################################################






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

Date: 28 May 1999 16:11:22 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PB writing an uploaded file in perl (size changes!)
Message-Id: <374eb21a@newsread3.dircon.co.uk>

Olivier Maas <olivier.maas@at-lci.com> wrote:
> Hello again
> I tried to upload a word or excel document,
> I now have the filehandle available in my perl script but when I write
> the output file, is does not have the same size... ? how come?
> 

binmode binmode binmode binmode binmode binmode binmode binmode binmode
binmode binmode binmode binmode binmode binmode binmode binmode binmode
binmode binmode binmode binmode binmode binmode binmode binmode binmode
binmode binmode binmode binmode binmode binmode binmode binmode binmode
binmode binmode binmode binmode binmode binmode binmode binmode binmode
binmode binmode binmode binmode binmode binmode binmode binmode binmode

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Fri, 28 May 1999 11:24:11 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: PB writing an uploaded file in perl (size changes!)
Message-Id: <374EB51A.41D26A08@mathworks.com>

What are the sizes of the file(s) on disk??

Are they the same or different??

Try closing the file and then stating the file based on its location on
disk.

Craig

Olivier Maas wrote:

> Hello again
> I tried to upload a word or excel document,
> I now have the filehandle available in my perl script but when I write
> the output file, is does not have the same size... ? how come?
>
> I printed the stats of the input and output file handle... they are not
> the same size
> even thought when I print the length of the buffers printed in the
> OUTPUT file, I get to the same total as the original file...
> thanks for any help, if possible send a copy of answer to maas@ensae.fr
> thanks...
>
> here is my script :
>
> ##########################################################
> #!/bin/perl
> push(@INC,'C:\Perl');
> require("CGI.pm");
> use CGI qw(:standard);
>
> #########
> #Creation de la page de reponse
> #########
>
> $html= CGI->new ;
> print $html->header ;
>
> #########
> #Recuperation des parametres passes en argument
> #########
>
> $FichAT=CGI::param(FichierATraiter);    #this gets the filehandle of the
>
> (e.g.) word file
>
> #Les lignes qui suivent construisent un fichier HTML
>  print "<HTML>\n";
>  print "<HEAD>\n";
>  print      "<TITLE> hello </TITLE>\n";
>  print "</HEAD>\n";
>  print      "<BODY TEXT=#FFFF00 BGCOLOR=#000000 >\n";
>  print      "\n";
>
>  open(OUTFILE, ">c:/temp/testfile.doc"); # ok, I know, I should better
> put
>                                                                 # the
> original name but I have not yet
>                                                                 #thought
>
> of how to "cut" the directory string
>
>  undef $Buffer;
>  undef $BytesRead;
>
>  while ($Bytes = read($FichAT,$Buffer,2048)) {
>                         $BytesRead += $Bytes;
>             print OUTFILE $Buffer;
>         }
> @sta=stat($FichAT);
> print "@sta <BR>";
>
> @sta=stat(OUTFILE);
> print "@sta <BR>";
>
>  close($FichAT);
>  close(OUTFILE);
>
>  print " fichname : $FichAT <BR>\n";
>  print " taille : $BytesRead Bytes <BR>\n";
>
>  #######
>  #terminer le fichier HTML
>  #######
>  print  "\n";
>  print  "</BODY>\n";
>  print  "</HTML>\n";
> #################################################



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

Date: Fri, 28 May 1999 15:22:37 GMT
From: vertigan@bigfoot.com (Steve Vertigan)
Subject: Re: perl script as an executable
Message-Id: <374eb2a8.126236047@news.aurum.net.au>

Uri Guttman <uri@sysarch.com> wrote thus:

>>>>>> "SV" == Steve Vertigan <vertigan@bigfoot.com> writes:
>
>  SV> Uri Guttman <uri@sysarch.com> wrote thus:
>  >> CGI.pm allows you to test the programs from a command line. it can make
>  >> errors display cleanly in html. it can handle data persistance across
>  >> forms.
>  >> 
>  >> can any hand-rolled cgi package do all those useful things? 
>
>  SV> Err, yes.  Mine does all that in fact.
>
>if it is so good, publish it on cpan! 

I would but, as you've said, there's a CGI.pm which already does that and
undoubtedly does it better than my "hand-rolled" library which isn't even a
module.  I actually am planning to release some scripts in the near future
but first have to find all the bad and evil things that'll get me screamed
at and fix 'em.

--Steve


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

Date: 28 May 1999 16:29:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl script as an executable
Message-Id: <374eb660@newsread3.dircon.co.uk>

Steve Vertigan <vertigan@bigfoot.com> wrote:
>          I actually am planning to release some scripts in the near future
> but first have to find all the bad and evil things that'll get me screamed
> at and fix 'em.

Spoil our fun would you ;-}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Fri, 28 May 1999 11:26:42 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: pre-allocating memory needs in perl?
Message-Id: <374EB5B2.A96F8FF2@mathworks.com>

See Camel book page 82.

Craig

"Nathan O. Siemers" wrote:

> Greetings,
>
>         I have some perl code that uses some fairly large hashes
>         (multi-megabyte size, nested too).  Would there be any
>         performance advantage to pre-allocating memory for these,
>         instead of making the interpreter allocate more memory
>         multiple times as the hash grows in size?  If so, how would
>         one do this?  I believe that one can do this with arrays by
>         something like:
>
>         $array[1000000] = 1;
>
>         (BTW, what's this simplest way to do this with a large
>         scalar? Any advantages to pre-allocation there?)
>
>         Practical as well as Philosophical advice welcomed.
>
>         Thanks,
>
>         nathan
>
> --
> N a t h a n   O .  S i e m e r s
> Bioinformatics
> Division of Applied Genomics
> Bristol-Myers Squibb Pharmaceutical Research Institute
> Hopewell Building 3B, P.O. Box 5400, Princeton, NJ 08543-5400
> 609 818-6568
> siemersn@bms.com



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

Date: 28 May 1999 15:30:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: pre-allocating memory needs in perl?
Message-Id: <slrn7ktdkj.138.sholden@pgrad.cs.usyd.edu.au>

On Fri, 28 May 1999 11:26:42 -0400, Craig Ciquera <craig@mathworks.com> wrote:
>See Camel book page 82.

And what if they don't own the Camel. Why not point them to the perl
documentation which they have if they have perl...

-- 
Sam

Fifty years of programming language research, and we end up with C++ ???
                --Richard A. O'Keefe


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

Date: 28 May 1999 16:03:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Question about date
Message-Id: <374eb043@newsread3.dircon.co.uk>

Nicola <nicolabo@prof.it> wrote:
> I use the following code to obtain the current date on my server:
> 
>    $tempo = time;          # Time in seconds from 1 Jan. 1970 on server
>    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
> ($tempo);
> 
> I'd want to know:
> Can this to create problems with the year 2000 ?
> 

Not at all as long as you read and understand this part of the localtime
section of the perlfunc manpage:

     In particular this means that $mon has the range 0..11 and
     $wday has the range 0..6 with sunday as day 0.  Also, $year
     is the number of years since 1900, that is, $year is 123 in
     year 2023, and not simply the last two digits of the year.


/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 28 May 1999 15:44:24 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Splicing and the current position in and foreach loop
Message-Id: <7imdko$4ql$1@pegasus.csx.cam.ac.uk>
Keywords: for foreach splice shift unshift

In article <u9d7zm8kwd.fsf@wcl-l.bham.ac.uk>,
Brian McCauley  <B.A.McCauley@bham.ac.uk> wrote:
>I'm sure this is a common problem but I don't see mention of it in the
>FAQ (maybe I'm blind).

You must have missed this part of the discussion of 'Foreach Loops' in
perldoc perlsyn:

     If any part of LIST is an array, foreach will get very
     confused if you add or remove elements within the loop body,
     for example with splice.   So don't do that.


Mike Guy


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

Date: Fri, 28 May 1999 10:47:17 -0400
From: John Kit <jkit@jpmorgan.com>
Subject: Re: thread vs process
Message-Id: <374EAC75.37CF51CF@jpmorgan.com>

I've written something simaliar to what you need.  It uses fork.  It seems

to work with 10 or 15 forks but goes crazy when there is more.  I've
posted
the code in this news group for help.  Maybe you can use some of it.
Search
for "Need help on fork" in the Subject.

John

izzac@my-deja.com wrote:

> I have to create bots that take a DB of URLs and make a GET(with
> libwww) on each to find any informations. I would like at least 8 to 10
> GET performing at the same time. This works well with the module IProc
> that allows to manage processes and see when they have finished or kill
> them when they timeout.
>
> But, I also know that libwww allows parrallel GET, but I read that
> these threads do not perform very well (maybe my sources are not
> good!?).
>
> So, which are the advantage of threads, and those of proccess ?
> Is it more easy to manage many process or many threads ?
> And what about the memory or cpu ?
>
> For the informations that should be passed to my process I use files
> and the result of the search is written also in the same file. Is there
> a better way possible ?
>
> If anybody can help me, this would be very appreciated!!:o)
> thanks
> Jonthan.
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---



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

Date: Fri, 28 May 1999 09:56:42 -0500
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Tying a double knot in a hash
Message-Id: <374EAEAA.D46D71DA@lucent.com>

I'm using perl's ability to 'tie' a hash
to specially handle a database.  

The double knot occurs because I'm also tying
a SDBM_database to the anonymous hash returned
by TIEHASH.

Problem arises when within TIEHASH, I try
to create a tied SDBM_File (which is a tie within 
a tie).  Without that code, the program works fine.

Adding these lines of code:

#dbmopen(%hash, $DATABASE, 0700) ||  #interchangable with below
tie (%hash, 'SDBM_File', "$DATABASE", O_RDWR|O_CREAT, 0700) || #interchangable
with above
        die "Could not open database $DATABASE\n";

Throw this error:

Can't use string ("HASH(0x175064)") as a HASH ref while "strict refs" in use at
remap line 207, <INPUT> chunk 1.

What can I try?  Is this a bug?

B


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

Date: 28 May 1999 15:27:44 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: What's wrong with this hit counter?
Message-Id: <7imclg$jh2$4@info2.uah.edu>

In article <m1so8ijvgg.fsf@halfdome.holdit.com>,
	merlyn@stonehenge.com (Randal L. Schwartz) writes:
: The number is MEANINGLESS.  Get it?  MEANINGLESS!  MEA-NING-LESS!

RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!

Greg :-)
-- 
A wise man speaks because he has something to say, a fool because he has to
say something. 
    -- Plato


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

Date: 28 May 1999 16:41:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: What's wrong with this hit counter?
Message-Id: <374eb915@newsread3.dircon.co.uk>

Greg Bacon <gbacon@itsc.uah.edu> wrote:
> In article <m1so8ijvgg.fsf@halfdome.holdit.com>,
> 	merlyn@stonehenge.com (Randal L. Schwartz) writes:
> : The number is MEANINGLESS.  Get it?  MEANINGLESS!  MEA-NING-LESS!
> 
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
> 

Or if one is feeling particularly evil:

use LWP::Simple;

while(1)
{
   my $junk = get('http://www.come.com/cgi-bin/counter.cgi');
}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 28 May 1999 11:49:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: What's wrong with this hit counter?
Message-Id: <x7iu9di47x.fsf@home.sysarch.com>

>>>>> "GB" == Greg Bacon <gbacon@itsc.uah.edu> writes:

  GB> In article <m1so8ijvgg.fsf@halfdome.holdit.com>,
  GB> 	merlyn@stonehenge.com (Randal L. Schwartz) writes:
  GB> : The number is MEANINGLESS.  Get it?  MEANINGLESS!  MEA-NING-LESS!

  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!
  GB> RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD! RELOAD!

hey greg!!! WAKE UP!! you fell asleep on your mouse while it was on the
reload button in your browser!

<splash!!> there! now you will stop ruining my hit counts.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 28 May 1999 08:03:44 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: Y2K infected Perl code
Message-Id: <374EB050.1998E39B@atrieva.com>

finsol@ts.co.nz wrote:

>   Jerome O'Neil <jeromeo@atrieva.com> wrote:
> > Please, show us your qualifications by posting some Y2K brokeness in
> > CGI.  Then, show us how we might fix it.

> You may have missed my posting today where I gave examples of Y2K broken
> code, so I have included them below. 

I think I understood it quite clearly.  You posited:

__QUOTE__
The fact is that CGI shares the same Y2K booby-trap problem as Perl.
Fixing Y2K problems is more important than playing stupid semantics.
_/QUOTE__

And I'm still waiting to see some Y2K broken CGI code.  

> These examples are in Perl but
> similar examples can be found in Java and several other languages
> frequently used for CGI programming.

Just a side note:  Java is rarely used for CGI.  Not that it can't be,
but experienced coders know the pros and cons, and use better tools for
that particular job.  

> I targetted localtime in Perl as it
> appears to be the most frequently found Y2K problem within CGI routines.
> If Perl code can be infected with Y2K problems, then so can CGI routines
> - deny that if you can!

I'm still waiting to see this CGI language you keep going on and on
about.

As far as the code below goes, all it does is prove my point.  There are
lots of bad programmers out there.  Abuse of perl's functions isn't any
indicator of it's quality.

<Bad perl snipped>
 
> These examples only took 10 minutes to find on the internet using an
> AltaVista advanced search on 'perl' and looking for 'localtime near 19
> and localtime near 20'.

So?  You're making my case again.  Bad programmers are everywhere.
 
> Try it sometime for a close view of programming in the real world.

I don't have to go any farther than my desk for a close view of
programming "in the real world."  It is apparent, though, that you do.

>These programmers are still hard-coding 19 for the century in 1999!

Those fools!  They must not know that localtime() is well defined and
clearly documented!

> These web pages are provided by their authors so that the code can be
> copied and pasted into new or existing programs.

I think they are provided so ex-HR "computer experts" can parade around
as "Y2K consultants."  When you've been in this business for a while,
you learn to spot the bovine stool artists quickly.  You should consider
yourself so marked.

> As for how to fix it - that's the easy part. 

Tell us, then.  How do we fix that which is not broken.

> The hardest part is
> getting programmers to realise that there is a problem in the first
> place.  With all this denial from programmers such as yourself, it is
> not surprising that many of us are still blissfully unaware that we may
> have serious problems in our code.

Who is 'we'?  I haven't seen one line of *your* code.  And I'm very
excited to see this CGI language I've heard you talk so much about.

> For anyone interested in what the booby trap code problem is, check out
> the following links.

Obviously they will trap the boobies.

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: 28 May 1999 16:09:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Y2K infected Perl code
Message-Id: <374eb1a0@newsread3.dircon.co.uk>

In comp.lang.perl.misc docdwarf@clark.net wrote:
> In article <7ils7e$ptu$2@ash.prod.itd.earthlink.net>,
> Bob Trieger <sowmaster@juicepigs.com> wrote:
>>[ courtesy cc sent by mail if address not munged ]
>>     
>>elcore@sgi.net (Lane Core Jr.) wrote:
>>>On 27 May 1999 22:47:28 -0400, Uri Guttman <uri@sysarch.com> wrote:
>>>
>>>>so fucking what if cgi
>>>>routines and perl routines can be infected with y2k. that is the
>>>>programmers problem and not the language's.
>>>
>>>same with cobol.
>>>same with any language.
>>>so it's still a problem.
>>>so, like, what's your point?
>>
>>It's not still a problem if you don't have a retard writing your code 
>>for you!
>>
> 
> And is it a problem if you have, say, a McCracken writing code which
> *must* ( = 'will not get into Prod if it doesn't') adhere rigidly to specs
> written by a 'retard'?
> 

Sorry,  are you saying that you have seen a specification for a *Perl*
program that prescribes the use of: $year = '19' . $year ?  Whoaaa .

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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