[22041] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4263 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 14 18:06:11 2002

Date: Sat, 14 Dec 2002 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 14 Dec 2002     Volume: 10 Number: 4263

Today's topics:
    Re: Delete series of bit sequences 1A1A from end of fil <bik.mido@tiscalinet.it>
    Re: Hashing several million rows of data (Tad McClellan)
    Re: HELP: MYSQL, IMAGES and PERL <NO.koos.JUNK.pol.MAIL@raketnet.nl>
        Hiya <bibleboy_101@shaw.ca>
    Re: Hiya <palladium@spinn.net>
    Re: Hiya <ian@WINDOZEdigiserv.net>
    Re: how to download a website protected with NTLM-authe (Tad McClellan)
    Re: MYSQL, IMAGES and PERL <kstep@pepsdesign.com>
        PerlCE on PocketPC <jeff@vpservices.com>
    Re: Question about Subroutines <renz-t@web.de>
    Re: Syntax of subroutine declarations, relating to use  <NO.koos.JUNK.pol.MAIL@raketnet.nl>
    Re: Syntax of subroutine declarations, relating to use  (Johan Vromans)
    Re: Syntax of subroutine declarations, relating to use  (Jay Tilton)
    Re: Where can I find book about perl4 (Tad McClellan)
    Re: Where can I find book about perl4 <dave@dave.org.uk>
        win2k total directory size, going down one level at lea <jim.bloggs@eudoramail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 14 Dec 2002 22:55:25 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Delete series of bit sequences 1A1A from end of file.
Message-Id: <1d7nvuo694fdljopnkqbcihcpib0sq0dch@4ax.com>

On 13 Dec 2002 15:14:39 -0800, Patrick Flaherty
<Patrick_member@newsguy.com> wrote:

>Thanx Michele,
>
>  I tried this and get back the message:
>
>  'Can't do inplace edit without backup'

(1) what's wrong with 'perldoc perlrun'?
(2) however (since I gave you this suggestion)... you're running perl
on Win* then. Solution: change -i to -i.bak (or what you like):

	perl -pi.bak -e 's/\x1a//g' test.txt
	perl -p0777 -i.bak -e 's/\x1a+$//g' test.txt


HTH,
Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Sat, 14 Dec 2002 09:50:10 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Hashing several million rows of data
Message-Id: <slrnavmkpi.94i.tadmc@magna.augustmail.com>

T Conti <tconti@hotmail.com> wrote:

> I imagine that as more data is loaded into
> a hash its search performance degrades.  


Hashes have an O(1) bound on their running time. 

(determining the bounds of an algorithm assumes that the number of
 elements is "large enough" to drown out the constant time associated
 with calculating the hash function and resolving collisions.
)

That is fancy college talk that means that hashes have _constant_
lookup time, the number of elements in the hash does not affect
how long it takes to search for a particular element.

In other words, the reality is precisely the opposite of what 
you've imagined.  :-)

It should be obvious that that is a Really Cool Thing, which is
why CS curriculums usually require students to spend a few weeks
studying hashing.


> I thought of using multiple
> hashes to implement this. 


That is likely to make it slower rather than faster.


> I was just wondering if anyone had any input
> on what is a good input for the optimal use of hashes for a large
> volume of data.


So execution time is not the limiting factor for "large" hashes.

Memory usage may become the limit, in which case you could consider
a tie()d hash that uses disk instead of memory.

Using disk instead of memory will, of course, be _much_ slower though.



Hashes are also sometimes called "dictionaries" or "associative arrays'.

I've done some googling in case folks want to study hashing on their own:

   http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/hash_tables.html

   http://www.cs.sunysb.edu/~skiena/214/lectures/lect21/lect21.html

   http://www.cs.sunysb.edu/~algorith/lectures-good/node7.html

   http://www-all.cs.umass.edu/~ajonsson/cs187/notes/lecture19.txt

   
-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 14 Dec 2002 20:54:00 +0100
From: Koos Pol <NO.koos.JUNK.pol.MAIL@raketnet.nl>
Subject: Re: HELP: MYSQL, IMAGES and PERL
Message-Id: <atg291$12p16g$1@ID-171888.news.dfncis.de>

On zaterdag 14 december 2002 13:57 Federico Bari wrote:

> Hi all,
> 
>     i have the need to store images in a mysql data base and then show
>     them
> in html pages. I'd like realize a perl script that can be called from html
> source as location for the image; for example
> 
> <img src="/cgi-bin/show_image_n.pl=876">
> 
> where the show_image_n.pl take the binary code of image 876 from a mysql
> database and "print" it. I tried but i doesn't work. Somebody could help
> me? maybe I have to print som especial header befor prinf the image code?
> 
> Thank you very much, from italy
> 
>         Federico.


1. This is really not a Perl question. You should ask this question in an 
appropriate newsgroup (comp.infosystems.www?) The Perl part of your problem 
is an absolute triviality.

2. YOUR CAPS-LOCK SEEMS TO BE STUCK. YOU WILL GET A SOAR THROAT FROM ALL 
THIS SHOUTING!

3. One specific problem is that you are missing a query param:
    > <img src="/cgi-bin/show_image_n.pl=876">
                                        ^
                                        ^
This should at least be something like:
    <img src="/cgi-bin/show_image_n.pl?id=876">

You can retrieve the 'id' param with something like $cgi->param("id") if you 
let the CGI module handle your query params. Read `perldoc CGI' for 
details.

4. You do need indeed a proper image header to have your browser understand 
you are feeding images. Again, ask in an appropriate newsgroup.

HTH.

-- 
KP
koos _ pol @ raketnet nl


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

Date: Sat, 14 Dec 2002 22:15:20 GMT
From: "Anadriel" <bibleboy_101@shaw.ca>
Subject: Hiya
Message-Id: <Y3OK9.165302$ea.3217386@news2.calgary.shaw.ca>

Hey all. I'm a newbie here, and to Perl. Basically, all I really want is a
page that will give me a thourough intro to perl, step-by-stpe, and what
excactly I need to use Perl. TY a bunch,
--
Andy
--------------------------------------------------------------
"Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!"




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

Date: Sat, 14 Dec 2002 15:22:33 -0700
From: "Rod" <palladium@spinn.net>
Subject: Re: Hiya
Message-Id: <uvnbtvdp9sara8@corp.supernews.com>

"Anadriel" <bibleboy_101@shaw.ca> wrote in message
news:Y3OK9.165302$ea.3217386@news2.calgary.shaw.ca...
> Hey all. I'm a newbie here, and to Perl. Basically, all I really want is a
> page that will give me a thourough intro to perl, step-by-stpe, and what
> excactly I need to use Perl. TY a bunch,
> --

Try
perl.com
perl.org
cpan.org

Most O'Reilly Books are good references.

BTW: in order to use Perl you need perl and a text editor, thats it.
(Although a device with a microprocessor also helps).

Good Luck,
Rodney






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

Date: Sat, 14 Dec 2002 22:35:07 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Hiya
Message-Id: <vicnvusdjh5fiuggorpvalvpfn6ja6lbgr@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Sat, 14 Dec 2002 22:15:20 GMT, "Anadriel"
<bibleboy_101@shaw.ca> managed to scribble:

> Hey all. I'm a newbie here, and to Perl. Basically, all I really want
> is a page that will give me a thourough intro to perl, step-by-stpe,
> and what excactly I need to use Perl. TY a bunch,

What kind of subject is "Hiya"!?

Try google and stop wasting all our time.. including yours.


Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPfuyhGfqtj251CDhEQJvbQCg3nOKR8hWFvEN47vcNS6cztGu4TgAoPn+
2X+DEsvDS3NKSb9RLWLq0h7E
=qumK
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Sat, 14 Dec 2002 09:57:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to download a website protected with NTLM-authentication?
Message-Id: <slrnavml7e.94i.tadmc@magna.augustmail.com>

ZZT <a@b.c> wrote:

> wget is not supporting NTLM but maybe there is a http-get module for 
> perl that support NTLM.


Then you should consider looking for such a module:

   http://search.cpan.org/search?query=NTLM&mode=all


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 14 Dec 2002 20:03:52 GMT
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: MYSQL, IMAGES and PERL
Message-Id: <I8MK9.8904$4W1.2436@nwrddc02.gnilink.net>

"Federico Bari" <fede72bari@tiscali.it> wrote in message
news:atf9tg$vci$1@lacerta.tiscalinet.it...
> Hi all,
>
>     i have the need to store images in a mysql data base and then show
them
> in html pages. I'd like realize a perl script that can be called from html
> source as location for the image; for example

I have a few comments, none of which are Perl related.  First of all, why
are you storing the image files in MySQL?  Just because a database handles
BLOB fields does not mean that you should use them for storing things that
could more easily be handled through the file system.  Why not store the URL
in MySQL and leave the images on disk?

>
> <img src="/cgi-bin/show_image_n.pl=876">
>

This is not a valid query string.  Don't you mean something like:

<img src="/cgi-bin/show_image_n.pl?id=876">

> where the show_image_n.pl take the binary code of image 876 from a mysql
> database and "print" it. I tried but i doesn't work. Somebody could help
me?
> maybe I have to print som especial header befor prinf the image code?

You will need to send a header with the appropriate content type such as
'image/jpeg' or 'image/gif'.  This also means that you will need to store
the content type in the database, unless all of the images are of a known
type.

Again, unless there is a really good reason to store the images in the
database, I would store the image on disk and the URL in the database.  Your
script would then write the URL from the database to each <img> tag, and let
the web server serve the image files without the expense of additional CGI
calls.

HTH,

Kurt Stephens




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

Date: Sat, 14 Dec 2002 10:41:38 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: PerlCE on PocketPC
Message-Id: <3DFB7B62.5090002@vpservices.com>

Has anyone got perl working on a pocketPC?  Any tips for me?  I'm 
looking to test DBI::PurePerl from my new handheld toy. With DBI and 
DBI::proxy and the built in WiFi card, it may graduate from being a toy. 
        But first I need to figure out how to install perl.

-- 
Jeff



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

Date: Sat, 14 Dec 2002 22:41:24 +0100
From: "Tobias Renz" <renz-t@web.de>
Subject: Re: Question about Subroutines
Message-Id: <atg8hd$de8$1@news.online.de>

I get the same result,
perhaps you should poste more of your program
especially declared variables..
and tell
what your circumstances are ( OS, Perlversion,... ).

--
Greetings
Tobias Renz
> I dunno.
>
> When I run your code, I get:
>
>    PORT 21 is Unknown
>
> just as I would have expected.
>
>
> > Your
> > help is greatly appreciated.
>
>
> Can't duplicate the problem, can't help.
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Sat, 14 Dec 2002 21:12:02 +0100
From: Koos Pol <NO.koos.JUNK.pol.MAIL@raketnet.nl>
Subject: Re: Syntax of subroutine declarations, relating to use and variable scope
Message-Id: <atg3aj$1302l4$1@ID-171888.news.dfncis.de>

On zaterdag 14 december 2002 06:26 David B. Nagle wrote:

> I was looking at the code in News::Article and came across some syntax
> that I had never encountered before. 

>     sub post;
>     
>     use Net::NNTP ();
>     
>     ; sub post
>     {
>         # Code removed
>     }
>     
>     
>     sub _unique_name;
>     
>     my $unique_count = "aa";
>     
>     ; sub _unique_name
>     {
>         # Code removed
>     }
> 
> I've never seen Perl code that duplicates the sub declaration like that
> before, with statements in between. Plus, the use of the extra
> semicolon before the duplicate sub statements is completely new (and
> rather strange) to me.


This is probably a local coding style. I agree it seems unusual.


> I think that I somewhat understand what the
> syntax is for: in the first case, the Net::NNTP module is only loaded
> if the post method is called,


No, au contaire. Read on...


>     sub post;


This only declares the sub. So the parser knows we have it laying around 
somewhere. As 'use...' statements are executed at compilation time, the 
Net::NNTP module is loaded as soon as the code is read.


> and is only in scope for that method;


Again no. According to 'perldoc -f use' the scope is the current package.


> in
> the second case, I'm guessing that $unique_count is a static variable
> whose value is retained across calls, though I'm not really sure.


'my' variables are always local to the current block. In this case it is 
scoped to the subroutine, as it is declared there. This easily concludes to 
that it can not be retained easily. Read 'perldoc -f my'.


> The module also includes the statement "use SelfLoader;", and I had the
> thought that this syntax might be related to SelfLoader. However, after
> scanning through the documentation on the SelfLoader module, I wasn't
> able to find anything related.


You assumption is right. SelfLoader is irrellivant in this.


> Is this syntax documented somewhere? I'd like to read about it, instead
> of making blind assumptions that would certainly get me in trouble if I
> tried to work off them. :)

Read to understand and then forget about it. Instead, read 'perldoc 
perlstyle' for a pretty good 'lecture' on the subject.

HTH.

-- 
KP
koos _ pol @ raketnet nl


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

Date: 14 Dec 2002 21:35:45 +0100
From: jvromans@squirrel.nl (Johan Vromans)
Subject: Re: Syntax of subroutine declarations, relating to use and variable scope
Message-Id: <m265twpcda.fsf@phoenix.squirrel.nl>

David B. Nagle <Z@wersh.com> writes:

>     sub post;

This declares a subroutine. The definition (with body) of the
subroutine should follow later. The only advantage of pre-declaring a
subroutine is that you can use it in the program as an operator
(without parentheses).

>     ; sub post

The leading semicolon has no significance for Perl, and is probably
use to prevent source parsing tools from interpreting this source line
as a subroutine specification (and getting confused since they aready
encountered the "sub post;" above).

-- Johan


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

Date: Sat, 14 Dec 2002 22:27:27 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Syntax of subroutine declarations, relating to use and variable scope
Message-Id: <3dfbaf4c.74888616@news.erols.com>

Koos Pol <NO.koos.JUNK.pol.MAIL@raketnet.nl> wrote:

: On zaterdag 14 december 2002 06:26 David B. Nagle wrote:
: 
: > I was looking at the code in News::Article and came across some syntax
: > that I had never encountered before. 
: 
: >     sub post;
: >     
: >     use Net::NNTP ();
: >     
: >     ; sub post
: >     {
: >         # Code removed
: >     }
: >     
: >     
: >     sub _unique_name;
: >     
: >     my $unique_count = "aa";
: >     
: >     ; sub _unique_name
: >     {
: >         # Code removed
: >     }
: > 
: > The module also includes the statement "use SelfLoader;", and I had the
: > thought that this syntax might be related to SelfLoader. However, after
: > scanning through the documentation on the SelfLoader module, I wasn't
: > able to find anything related.
: 
: You assumption is right. SelfLoader is irrellivant in this.

Are you certain?  The subroutine stubs look an awful lot like what is
described in SelfLoader.pm.  In which case, SelfLoader would have
everything to do with the peculiarity.



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

Date: Sat, 14 Dec 2002 09:56:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Where can I find book about perl4
Message-Id: <slrnavml4n.94i.tadmc@magna.augustmail.com>

Dave Cross <dave@dave.org.uk> wrote:
> On Fri, 13 Dec 2002 07:50:49 +0000, Phov wrote:
> 
>> Our root refused to upgrade perl 4 to perl 5.  are there any perl4
>> books or resource online.  Can anyone help me to locate them.
> 
> I recommend upgrading your sysadmin to one who knows what he's talking
> about :)


A few more approaches you might take:


perl4 is completely unsupported, so all support questions must
be directed to the sysadmin herself. Perhaps she is already
"busy enough" and would like to avoid taking on more responsibilities.

There are CERT advisories against perl4. Sysadmins should care
about the possiblity of having their system cracked.

A manager's job is to ensure that her people have the tools they
need to do their jobs. Ask your manager to speak with the 
sysadmin's manager.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 14 Dec 2002 17:36:42 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Where can I find book about perl4
Message-Id: <pan.2002.12.14.17.36.41.292020@dave.org.uk>

On Sat, 14 Dec 2002 09:56:07 +0000, Tad McClellan wrote:

> Dave Cross <dave@dave.org.uk> wrote:
>> On Fri, 13 Dec 2002 07:50:49 +0000, Phov wrote:
>> 
>>> Our root refused to upgrade perl 4 to perl 5.  are there any perl4
>>> books or resource online.  Can anyone help me to locate them.
>> 
>> I recommend upgrading your sysadmin to one who knows what he's talking
>> about :)
> 
> A few more approaches you might take:
> 
> 
> perl4 is completely unsupported, so all support questions must
> be directed to the sysadmin herself. Perhaps she is already
> "busy enough" and would like to avoid taking on more responsibilities.
> 
> There are CERT advisories against perl4. Sysadmins should care
> about the possiblity of having their system cracked.
> 
> A manager's job is to ensure that her people have the tools they
> need to do their jobs. Ask your manager to speak with the 
> sysadmin's manager.

And are we still using the old favourite:

"There are no plans to make Perl 4 y2k compliant" :)

Dave...

-- 
  ...she opened strange doors that we'd never close again



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

Date: Sat, 14 Dec 2002 21:23:09 -0000
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: win2k total directory size, going down one level at least ?
Message-Id: <atg7g1$13mh77$1@ID-150435.news.dfncis.de>

Besides doing something like this...

 my $dirsize;

 my %dir;

 tie %dir, 'IO::Dir', DIRECTORY_OF_DATA . $self->getUsername;

 foreach (keys %dir) {

  $dirsize += $dir{ $_ }->size;

 }

 ... does anybody know a better way of getting the size of a directory on
win32 (win2k). I have looked in CPAN but can't see anything.

Sorry if this is a stupid question.

I thought it would be a simple stat, but that doesn't seem to work in
win2k and, short of recursing, well, I'm just thinking, somebody must
have done this before.

I only need to go down one level, in this particular case.

Grateful for any replies.

Thanks.... :-)

--
doofus






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

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


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