[22991] in Perl-Users-Digest
Perl-Users Digest, Issue: 5211 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 10 21:05:55 2003
Date: Thu, 10 Jul 2003 18:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Jul 2003 Volume: 10 Number: 5211
Today's topics:
Re: and EZ way to convert XLS file to CSV? <asu1@c-o-r-n-e-l-l.edu>
Re: comparing floating point numbers <michael.p.broida@boeing.com>
compiling Perl code (-bill)
Re: creating a directory with cgi and owner ends up as <mbudash@sonic.net>
Re: creating a directory with cgi and owner ends up as <me@home.com>
Re: creating a directory with cgi and owner ends up as <me@home.com>
Re: creating a directory with cgi and owner ends up as <Juha.Laiho@iki.fi>
Re: creating a directory with cgi and owner ends up as <mbudash@sonic.net>
Re: creating a directory with cgi and owner ends up as <vladimir@NoSpamPLZ.net>
Re: creating a directory with cgi and owner ends up as <emschwar@pobox.com>
Re: Fastest way to build a hash <REMOVEsdnCAPS@comcast.net>
Re: Grabbing certain section of a string <REMOVEsdnCAPS@comcast.net>
Re: How do I clone a structure? <bik.mido@tiscalinet.it>
Re: How do I clone a structure? (Greg Bacon)
install_driver(Oracle) failed <jgiblin@roadrunner.com>
Re: my first japh <bik.mido@tiscalinet.it>
NDBM_File <fkwlau@student.math.uwaterloo.ca>
Re: NET::FTP ls error <mbudash@sonic.net>
Re: Perl FAQ error in "variable as a variable name" <jkeen@concentric.net>
Re: Perl FAQ error in "variable as a variable name" (Jay Tilton)
Re: Perl FAQ error in "variable as a variable name" (Jay Tilton)
Re: Q- Empirical usable upper limit on hash array numbe (Jay Tilton)
Re: Reading JPEG file <asu1@c-o-r-n-e-l-l.edu>
Re: Synchronizing two ftp sites/folders <gareth.glaccum@btopenworld.com>
Re: Total Butt Heads in this news group <yoy@comcast.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Jul 2003 19:24:29 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: and EZ way to convert XLS file to CSV?
Message-Id: <Xns93B49CBD9408Easu1cornelledu@132.236.56.8>
genericax@hotmail.com (Sara) wrote in news:776e0325.0307100525.37b06a42
@posting.google.com:
> OK, I'm painted into a corner by Bill G again.. This time with XL, yet
I do not know what XL is but I'll assume you are talking about Excel.
> another package NIH by Microsoft but still controlled by them...
NIH?
> If I bop into OpenOffice I can read in an XLS and export it as a CSV.
> I looked in cpan and news but didn't see a straightforward way to do
> the same thing with a Perl module. I saw XL-Parse but the readme
> implied it didn't have a quick-conversion capability.
I do not know about modules, but some time ago, I wrote a very
rudimentary method to save each sheet in a bunch of Excel files in text
format. If you are on a Win32 system with Excel installed, you could use
that method. See:
http://www.people.cornell.edu/pages/asu1/notes/perl-excel.html
Sinan
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 10 Jul 2003 16:52:58 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: comparing floating point numbers
Message-Id: <3F0D99EA.D3D37938@boeing.com>
Thens wrote:
>
> Hi,
>
> I have a problem comparing floating point numbers.
One of the things you need to learn about floating point
numbers is:
NEVER compare them for equality (or inequality).
Mike
------------------------------
Date: 10 Jul 2003 14:31:54 -0700
From: i_ching@yahoo.com (-bill)
Subject: compiling Perl code
Message-Id: <1b0363da.0307101331.34360a3d@posting.google.com>
hi all,
I know little about Perl, so I ask the following question. when you
compile Perl code, can a PDB(symbols file) be created the way you can
within MSVS IDE for VB, C/C++ ?
thanx
-bill
------------------------------
Date: Thu, 10 Jul 2003 18:05:19 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <mbudash-E0AE5F.11052410072003@typhoon.sonic.net>
In article <90lrgv08kedm1lst04f39ulhbv9eunqnf5@4ax.com>,
Steve <me@home.com> wrote:
> On Thu, 10 Jul 2003 17:41:43 GMT, Michael Budash <mbudash@sonic.net>
> wrote:
>
> >In article <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>,
> > Steve <me@home.com> wrote:
> >
> >> Hi,
> >>
> >> I'm trying to create a directory and files using cgi. The strange
> >> thing is when I call the script directly, I have no problem, but when
> >> I call it using forms on an index.html file, the directory and files
> >> have user:owner as apache:apache. Any ideas why this is happpening.
> >
> >[snip code]
> >
> >cgi scripts usually run as 'nobody', though they can run as whatever the
> >admin set apache up as... in your case, it looks like they run as
> >'apache'... you can usually change the permissions and/or user/group in
> >the script...
>
> wow...thanks for the quick reply. Can you give me a hint as to how to
> create a file and directory with me as owner? Or point me in the right
> direction?
you already know how to create a dir. for creating a file and changing
its owner:
perldoc -f open
perldoc -f chown
hth-
--
Michael Budash
------------------------------
Date: Thu, 10 Jul 2003 14:19:30 -0700
From: Steve <me@home.com>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <bslrgv8e47urmomrig093n66m9i4j68npe@4ax.com>
>> wow...thanks for the quick reply. Can you give me a hint as to how to
>> create a file and directory with me as owner? Or point me in the right
>> direction?
>
>you already know how to create a dir. for creating a file and changing
>its owner:
>
>perldoc -f open
>perldoc -f chown
>
>hth-
Thank you Mike, I can now see that when the CGI script runs, it runs
as user apache. And any directories and files created are owned by
apache.
So...my mission is to read the documentation and find out what
permissions I should give the file to allow me to chown to myself...I
am guessing drwxrwxrwx
But...why do the things you think will be simple always take four
hours?
------------------------------
Date: Thu, 10 Jul 2003 14:44:11 -0700
From: Steve <me@home.com>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <pfnrgv4c5prd0q40i1hr5aeopjd0d37v18@4ax.com>
Bah! I guess its:
`chmod -R +rwx dumb_file`;
so I can delete it and go read the docs
------------------------------
Date: Thu, 10 Jul 2003 18:52:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <bekceh$cn6$3@ichaos.ichaos-int>
Michael Budash <mbudash@sonic.net> said:
>In article <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>,
> Steve <me@home.com> wrote:
>> I'm trying to create a directory and files using cgi. The strange
>> thing is when I call the script directly, I have no problem, but when
>> I call it using forms on an index.html file, the directory and files
>> have user:owner as apache:apache. Any ideas why this is happpening.
>
>cgi scripts usually run as 'nobody', though they can run as whatever the
>admin set apache up as... in your case, it looks like they run as
>'apache'... you can usually change the permissions and/or user/group in
>the script...
I disagree with Michael here -- I think the typical Unix systems currently
don't allow "donating" files (i.e. chown files to another account) - this
has previously been used to circumvent disk quota systems, etc, so the
chown capability has largely been disabled from regular users.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Thu, 10 Jul 2003 19:25:41 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <mbudash-BD5D4A.12254010072003@typhoon.sonic.net>
In article <bekceh$cn6$3@ichaos.ichaos-int>,
Juha Laiho <Juha.Laiho@iki.fi> wrote:
> Michael Budash <mbudash@sonic.net> said:
> >In article <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>,
> > Steve <me@home.com> wrote:
> >> I'm trying to create a directory and files using cgi. The strange
> >> thing is when I call the script directly, I have no problem, but when
> >> I call it using forms on an index.html file, the directory and files
> >> have user:owner as apache:apache. Any ideas why this is happpening.
> >
> >cgi scripts usually run as 'nobody', though they can run as whatever the
> >admin set apache up as... in your case, it looks like they run as
> >'apache'... you can usually change the permissions and/or user/group in
> >the script...
>
> I disagree with Michael here -- I think the typical Unix systems currently
> don't allow "donating" files (i.e. chown files to another account) - this
> has previously been used to circumvent disk quota systems, etc, so the
> chown capability has largely been disabled from regular users.
you are likely correct... i was thinking of perl's 'chmod' function, not
its 'chown' function... my mistake...
--
Michael Budash
------------------------------
Date: Thu, 10 Jul 2003 20:25:28 GMT
From: "Vladimir P." <vladimir@NoSpamPLZ.net>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <YYjPa.7363$Pe2.132113@wagner.videotron.net>
On Thu, 10 Jul 2003 14:19:30 -0700, Steve wrote:
> So...my mission is to read the documentation and find out what
> permissions I should give the file to allow me to chown to myself...I
> am guessing drwxrwxrwx
Only root can do chown.
--
.signature: No such file or directory
------------------------------
Date: 10 Jul 2003 14:32:27 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <eton0fm86n8.fsf@wormtongue.emschwar>
"Vladimir P." <vladimir@NoSpamPLZ.net> writes:
> On Thu, 10 Jul 2003 14:19:30 -0700, Steve wrote:
> > So...my mission is to read the documentation and find out what
> > permissions I should give the file to allow me to chown to myself...I
> > am guessing drwxrwxrwx
>
> Only root can do chown.
This depends on your OS, filesystem, and fs options. One filesystem
(ISTR it's XFS) on Linux supports giveaway by default, but you can
configure other filesystems to allow or disallow by default. For most
sensible setups, your statement is true, however.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Thu, 10 Jul 2003 16:42:25 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Fastest way to build a hash
Message-Id: <Xns93B4B42D0B092sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
fischerlaender@gmx.de (Stefan Fischerländer) wrote in
news:ff9bee6c.0307100531.4a3a12f6@posting.google.com:
> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
> news:<Xns93B43D68554D7sdn.comcast@206.127.4.25>...
>
>> Okay, this is the fastest I've come up with yet:
>> open IN, $input_file or die "Can't read $input_file: $!\n";
>> $/ = \5; # set input record length to 5 bytes
>> my %hash;
>> $hash{$_} = chop while <>;
>
> Took some time to figure out that the last line must read:
> $hash{$_} = chop while <IN>;
Oops, yeah, sorry about that.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPw3d0WPeouIeTNHoEQIA6ACbB9ewoSHwXns6RFyQd/m6RA8syDUAoJMd
2sQ3cjurQs+EXDekC6NJFowz
=RzlF
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 10 Jul 2003 17:36:11 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Grabbing certain section of a string
Message-Id: <Xns93B4BD3EBB657sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
fatted@yahoo.com (fatted) wrote in
news:4eb7646d.0307100721.1e7fd616@posting.google.com:
> Abigail <abigail@abigail.nl> wrote in message
> news:<slrnbgob6k.q45.abigail@alexandra.abigail.nl>...
>> Desmo (me@helpme.com) wrote on MMMDXCIX September MCMXCIII in
>> <URL:news:94724eff9e851813349be69596df5d41@free.teranews.com>:
>
> <snip>
>
>> Assuming the string is in $str:
>>
>> my @filenames = $str =~ /filename="([^"]*)"/g;
>
> Can you explain how the part of the regexp thats inside the () works.
> I just don't follow :(. Is there any reason not to use (.*?) {instead
> of what you have ([^"]*)}?
>
Speed. It's faster to greedily slurp up "as many non-quote characters
as possible" than it is to non-greedily find "as few of any character as
possible".
When you use a greedy expression, the RE engine zips forward as far as it
can, then backs off until the next atom matches. In the above case,
it'll zip past all the non-quote characters and will match the next atom
(quote), and so will not have to back off at all.
When you use a non-greedy expression, the RE engine trods forward one
matching character at a time, each time stopping to check if the next
atom matches. Ih the above case, it'll match . (any character) and each
time check to see if the next character is a quote, which most of the
time it won't be.
The actual situation inside the RE engine is a bit more complex, because
it does some fancy optimizations here and there, and has a bit more
smarts than I described above. But the above is conceptually correct,
and is the way to think about greed vs non-greed if you want to write
faster expressions.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPw3qWmPeouIeTNHoEQKW7ACg3RfO1WM0D1c+4/ogCRccLVoRUAsAoMDe
COVQikVe3hvOhbuEf/PR28sl
=rK1g
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 10 Jul 2003 21:00:09 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I clone a structure?
Message-Id: <ej1pgvc8ucp1rc9sqredtb8uffrald2785@4ax.com>
On Tue, 08 Jul 2003 13:34:16 -0000, gbacon@hiwaay.net (Greg Bacon)
wrote:
>It depends on your perspective. You mentioned C equivalent, but how
>about the O'Caml equivalent, in which a list is recursively defined as
>the first element (the head) followed by the rest of the list (the
>tail)?
<OT>
It is so in *any* ML and, I think, in most strictly functional
languages.
</OT>
But that is *ML. Perl's point of view is different, and your
perspective on something having to do with Perl cannot be based on
another point of view.
You were mentioned the C equivalent because it is not fundamentally
different from Perl, wrt the subject matter being discussed.
Michele
--
$\=q.,.,$_=q.print' ,\g,,( w,a'c'e'h,,map{$_-=qif/g/;chr
}107..q[..117,q)[map+hex,split//,join' ,2B,, w$ECDF078D3'
F9'5F3014$,$,];];$\.=$/,s,q,32,g,s,g,112,g,y,' , q,,eval;
------------------------------
Date: Thu, 10 Jul 2003 21:50:09 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: How do I clone a structure?
Message-Id: <vgrnsht7u9tnb7@corp.supernews.com>
In article <ej1pgvc8ucp1rc9sqredtb8uffrald2785@4ax.com>,
Michele Dondi <bik.mido@tiscalinet.it> wrote:
: [...]
:
: You were mentioned the C equivalent because it is not fundamentally
: different from Perl, wrt the subject matter being discussed.
The code I included isn't so different -- especially considering that
I chose a simple example for sake of argument -- from head (shift) and
tail (what's left in @_):
sub print_data_structure_recursively {
if (@_) {
print shift(), "\n";
&print_data_structure_recursively;
}
}
Greg
--
I couldn't believe it. My book was used to define the ultimate geek, and
suddenly my son thinks I'm really cool.
-- W. Richard Stevens on Garth carrying UNP in Wayne's World
------------------------------
Date: Thu, 10 Jul 2003 19:09:28 GMT
From: "John Giblin" <jgiblin@roadrunner.com>
Subject: install_driver(Oracle) failed
Message-Id: <IRiPa.8818$351.4804143@twister.nyc.rr.com>
I am getting the following error when I run my script
install_driver(Oracle) failed: Can't load
'F:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle:
load_file:Access is denied at F:/Perl/lib/DynaLoader.pm line 206.
Compilation failed in require at (eval 2) line 3.
Perhaps a required shared library or dll isn't installed where expected
I am running Oracle9i, IIS5, perl 5.6
The script works from the command line but through the webserver/browser
John
------------------------------
Date: Thu, 10 Jul 2003 21:00:10 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: my first japh
Message-Id: <ck1pgvg4h2pqg3q0ahirst3cs1p70gl5pd@4ax.com>
On 7 Jul 2003 09:29:46 -0700, rook_5150@yahoo.com (Bryan Castillo)
wrote:
>Here is my first attempt at a JAPH. Any pointers on how to shorten
>it up more and obscure it?
>
>$|++;print"\033[2J";$f="\033[5;%dH%s";$x=33;END{print"\n\n"}
>@_=map{[--$x,$_]}split//,'rekcaH lreP rehtonA tsuJ';
>select'','','',(printf$f,@{splice@_,rand@_,1})/10 while(@_);
Well, Abigail just answered you:
> Use a 2pt font.
but in the thread 'Google's newsgroups' you can see a japh of his own
that accomplishes a somewhat similar task as yours, in a (relatively)
simple and elegant way. Also, it doesn't need an ANSI terminal to
run...
What bothers me about your japh (and in any case you're warned: my
opinion is very humble!) is that there is *no* actual data
obfuscation. OTOH there's *some* logic obfuscation, but hey, as far as
I'm concerned, anything that has to do with ANSI sequences is
automatically obfuscated...
Michele
--
$\=q.,.,$_=q.print' ,\g,,( w,a'c'e'h,,map{$_-=qif/g/;chr
}107..q[..117,q)[map+hex,split//,join' ,2B,, w$ECDF078D3'
F9'5F3014$,$,];];$\.=$/,s,q,32,g,s,g,112,g,y,' , q,,eval;
------------------------------
Date: Thu, 10 Jul 2003 15:03:49 -0400
From: Francis Lau <fkwlau@student.math.uwaterloo.ca>
Subject: NDBM_File
Message-Id: <Pine.SOL.4.44.0307101453430.11319-100000@blanch.math.uwaterloo.ca>
Hi All,
I'm trying to get NDBM_File to install on my machine. I am running redhat
9 (kernel 2.4.20-18.9smp) with the perl-5.8 that comes with the redhat 9
install.
I downloaded the gdbm-1.8.3.tar.gz file and took the necessary steps to
install the libgdbm_compat.so, libgdbm_compat.a, libgdbm_compat.la, and
ndbm.h files (to /usr/local/lib and /usr/local/include). To get the
libndbm.a and libndbm.so, I just made symmlinks (as follows):
ln -s /usr/local/lib/libgdbm_compat.so /usr/local/lib/libndbm.so
ln -s /usr/local/lib/libgdbm_compat.a /usr/local/lib/libndbm.a
I then downloaded the perl-5.8 source and tried to get it to make the
NDBM_File.so and NDBM_File.pm. After 'sh Configure' and 'make' are done,
I did a 'make test', but then these errors would always show up:
(from the output of the 'make test')
<snip>
# GOT:
# /home/fkwlau/perl-5.8.0/perl: relocation error:
../lib/auto/NDBM_File/NDBM_File.so: undefined symbol: dbm_open
# STATUS: 32512
# Failed at ./test.pl line 567
<snip>
ext/NDBM_File/ndbm...................FAILED at test 0
<snip>
Can anyone give me some ideas on how I can get NDBM_File to work?
Thanks,
Francis
------------------------------
Date: Thu, 10 Jul 2003 18:10:48 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: NET::FTP ls error
Message-Id: <mbudash-786487.11105310072003@typhoon.sonic.net>
[top-posting fixed just this once]
In article <3f0da6e5$0$100$8f4e7992@newsreader.goldengate.net>,
"Bob" <rpl-erroroneous@goldengate.net> wrote:
> "Michael Budash" <mbudash@sonic.net> wrote in message
> news:mbudash-EFA94D.10392510072003@typhoon.sonic.net...
>
> > In article <3f0da34a$0$99$8f4e7992@newsreader.goldengate.net>,
> > "Bob" <rpl-erroroneous@goldengate.net> wrote:
> >
> > > running on w2k pro sp2 system. Code is:
> > >
> > > # ftptst.plx - 10 July 2003. testing ftp script
> > > use warnings;
> > > use strict;
> > > use Net::FTP;
> > > my ($hostname, $username, $password, $directory, $filename, $ftpobj,
> @last);
> > > #declaration of parameters
> > > $hostname="ftp.nowhere.com";
> > > $username="anonymous";
> > > $password="tst\@tsthere";
> > > $directory="/pub";
> > > $filename="*.txt";
> > >
> > > $ftpobj = Net::FTP -> new ($hostname);
> > > $ftpobj -> login($username, $password);
> > > $ftpobj -> cwd ($directory);
> > > @last = ftp->ls($filename) or die "No $filename found.\n";
> > > $ftpobj -> quit;
> > > -------------------- end of code ---------------------------
> > > The above code works - the error is with the line requesting ls
> > > @last = ftp->ls($filename) or die "No $filename found.\n";
> > >
> > > the error reported is:
> > > D:\perl\srccode\ftp>perl ftptst.plx
> > > Can't locate object method "ls" via package "ftp" (perhaps you
> forgot to
> > > load "ftp"?) at ftptst.plx line 25.
> > >
> >
> > s/b:
> >
> > @last = $ftpobj -> ls($filename) or die "No $filename found.\n";
> >
> > > Questions:
> > > 1. Doesn't the line -- use NET::FTP -- load "ftp" ???
> >
> > no. it loads a set of methods, mainly.
> >
> > > 2. Is there a source for examples of using net::ftp?
> >
> > perldoc Net::FTP
>
> thanks.
>
> another question.. to avoid these really "bad" mistakes, is there some
> kind of checker program that checks the code for content or properly defined
> statement, etc.
the error you got is as good as you can get!
--
Michael Budash
------------------------------
Date: 10 Jul 2003 22:43:33 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Perl FAQ error in "variable as a variable name"
Message-Id: <bekq6l$cq8@dispatch.concentric.net>
"Eric Pement" <pemente@northpark.edu> wrote in message
news:227a55e9.0307100744.6170bb93@posting.google.com...
> In trying to learn about references, I believe I've found an error in
> the Perl FAQ, section 7 ("General Perl Language Issues"), under the
> question, "How can I use a variable as a variable name?" The problem
> exists in the documentation for Perl 5.6 and Perl 5.8. I tried
> emailing the FAQ keepers a while ago and got no response. Maybe
> somebody can confirm or correct me here. (smile)
>
> The FAQ currently reads in part:
>
> By using symbolic references, you are just using the package's
> symbol-table hash (like %main::) instead of a user-defined hash.
> The solution is to use your own hash or a real reference instead.
>
> $fred = 23;
> $varname = "fred";
> $USER_VARS{$varname}++; # not $$varname++
>
> This solution does not work and does not provide "24" as one would
> expect. You can prove it by just running the script:
>
No, one would *not* expect '24' as the result. You're not doing anything
with $fred once you've assigned '23' to it. Until you make some assignment,
$USERS_VARS{'fred'} == 0, which when ++ed makes 1.
------------------------------
Date: Fri, 11 Jul 2003 00:02:02 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl FAQ error in "variable as a variable name"
Message-Id: <3f0df7ed.81740525@news.erols.com>
"James E Keenan" <jkeen@concentric.net> wrote:
: "Eric Pement" <pemente@northpark.edu> wrote in message
: news:227a55e9.0307100744.6170bb93@posting.google.com...
: > In trying to learn about references, I believe I've found an error in
: > the Perl FAQ, section 7 ("General Perl Language Issues"), under the
: > question, "How can I use a variable as a variable name?" The problem
: > exists in the documentation for Perl 5.6 and Perl 5.8. I tried
: > emailing the FAQ keepers a while ago and got no response. Maybe
: > somebody can confirm or correct me here. (smile)
: >
: > The FAQ currently reads in part:
: >
: > By using symbolic references, you are just using the package's
: > symbol-table hash (like %main::) instead of a user-defined hash.
: > The solution is to use your own hash or a real reference instead.
: >
: > $fred = 23;
: > $varname = "fred";
: > $USER_VARS{$varname}++; # not $$varname++
: >
: > This solution does not work and does not provide "24" as one would
: > expect. You can prove it by just running the script:
: >
: No, one would *not* expect '24' as the result.
Not from looking at the code, no. But that's not what Eric meant.
He is talking about the expectation, raised by the discussion around
the code snippet, that it will do something similar to the preceding
snippet:
$fred = 23;
$varname = "fred";
++$$varname; # $fred now 24
but it clearly does not.
The only thing demonstrated in the second snippet is that $fred and
$USER_VARS{fred} are not the same. If that is what the FAQ authors
intended to show, obvious as it may be, it should be stated.
It's more likely that they meant to show how to use a hash as a
private namespace, instead of wrecking the global namespace through
symbolic references as was done in the first snippet. As Eric
observed, it fails to demonstrate that.
Either way, it's a source of confusion. Explicity saying what the
snippet is meant to do will prevent a reader from having to infer its
purpose, and will help ensure that the code meets that purpose.
------------------------------
Date: Fri, 11 Jul 2003 00:04:57 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl FAQ error in "variable as a variable name"
Message-Id: <3f0dfef3.83539116@news.erols.com>
pemente@northpark.edu (Eric Pement) wrote:
: Finally, the FAQ says another solution is to use a real reference
: instead. Am I correct in thinking that such a solution would look like
: this,
: $fred = 23;
: $varname = \$fred;
: $$varname++;
Exactly correct.
------------------------------
Date: Fri, 11 Jul 2003 00:33:04 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Q- Empirical usable upper limit on hash array number of elements
Message-Id: <3f0e050d.85101506@news.erols.com>
carltonbrown@hotmail.com (Carlton Brown) wrote:
: All the docs (that I've read) say that there is no limit on the size
: of a hash in PERL.
^^^^
See perlfaq1, What's the difference between "perl" and "Perl"?
: But in my experience, when documentation says "no
: limit" on a spec, it means the limit lies outside the boundaries of
: what anyone has tested.
Or what anybody has been adequately capable of testing. Whomping up
some test code is trivial enough. Give it a shot and see what
happens.
: A quick "Fermi problem" review of the expected orders of magnitude
: shows that these data structures shouldn't consume more than 12GB of
: memory (unless of course there exists some non-trivial overhead that I
: don't know about).
That accounts only for the size of the data itself. Imposing a
structure on that data is indeed non-trivial.
Allocating space for the hash will give a better idea how much memory
will be consumed.
keys(%hash) = 100e6;
Pre-allocating the space would also eliminate the speed hit from
perl's need to dynamically resize the hash as it grows.
As for the speed of the hash lookup itself, under ideal circumstances
it would be independent of the number of elements. Whether ideal
circumstances exist depends not only on the hashing function but on
the data as well. Others' experiences with big hashes may not be
applicable, since their data will be different from yours.
: The essence of the problem is to take extremely large list A, compare
: it to slightly smaller list B, and identify the elements from list A
: that are not found in list B.
That's computing the difference between two lists. How come you
called it a union at the beginning of your article?
------------------------------
Date: 11 Jul 2003 00:19:42 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Reading JPEG file
Message-Id: <Xns93B4CECB97693asu1cornelledu@132.236.56.8>
Zvone Zagar <zvone.zagar@siol.net> wrote in
news:HnIOa.101$2B6.20527@news.siol.net:
> Hello!
> I made very rudimentary perl script which produces postcript file.
> Temporary link is http://freeweb.siol.net/an511zvo
> It not quite what I imagined,but it works. At least for JPEG files.
> It may encourage somebody to make a better one.
A few comments:
* I had not realized that ImageMagick also had a text format. IMHO, it is
not the output format you want because it creates a lot of extra work for
you.
* I am still not clear on the output format you want. I looked at the
sample PS image (raptor2.ps) but it does not have the contents of the
$dcp, $dci, and $dc variables.
* Speaking of those, you should probably output those using "here docs"
rather than defining multiline strings.
* Using raptor2.ps as a guide, I put together a short script that might
be helpful. However, I have not been able to test it because I haven't
been able to install PerlMagick on my XP or FreeBSD boxes. Also, I am not
sure what the third value (8) in
%!
250 80 8 matrix {
at the top of raptor2.ps file.
That said, here is my attempt at the script:
#! /usr/bin/perl
# WARNING: Completely untested
use strict;
use warnings;
use Image::Magick;
my $chunk_size = 33;
foreach my $img_file (@ARGV) {
my $rgb_file = "$img_file.rgb";
my $image = Image::Magick->new;
$image->Read($img_file);
$image->Write($rgb_file);
my $ps_file = "$img_file.ps";
open(PS, "> $ps_file") || die "Cannot open $ps_file: $!\n";
my $width = $image->Get('columns');
my $height = $image->Get('rows');
print PS "%!\n$width $height 8 matrix {<\n";
undef $image;
open(RGB, "< $rgb_file") || die "Cannot open $rgb_file: $!\n";
binmode RGB;
my $chunk;
while(read(RGB, $chunk, $chunk_size)) {
foreach my $octet (split //, $chunk) {
printf(PS "%2.2X", ord($octet));
}
print(PS "\n");
}
print PS ">\n} false 3 colorimage\nshowpage\n";
close(PS);
close(RGB);
}
HTH.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 10 Jul 2003 20:06:13 +0000 (UTC)
From: "Gareth Glaccum" <gareth.glaccum@btopenworld.com>
Subject: Re: Synchronizing two ftp sites/folders
Message-Id: <bekgvk$mnl$1@hercules.btinternet.com>
Assuming un*x on both machines yes. However, if perl is the way you want to
go, try w3mir (search on google for it). It hasn't been updated for a while,
but it is designed to copy websites. Will even perform username and password
authentication if your staging site is protected.
Gareth
"Perusion hostmaster" <nanae@perusion.com> wrote in message
news:slrnbglqmm.1hv.nanae@ns.valuemedia.com...
> > Does anyone know of any kind of shell script/perl script which we
> > could run which could recursively look at each folder on the live site
> > and STAGING, and if any files are out of date on live copy them up
> > from STAGING to live?
> >
> Perl is not the best thing for the job, rsync(1) is:
------------------------------
Date: Thu, 10 Jul 2003 15:25:44 -0500
From: Buteo Lagopus <yoy@comcast.net>
Subject: Re: Total Butt Heads in this news group
Message-Id: <Xns93B4A6F4F35B0yoycomcastnet@206.127.4.25>
"Robert" <yyyy@yyy.com> wrote in news:uKnOa.184175$nr.8352141
@twister.southeast.rr.com:
>
>
>
Wasting three \n's is boneheaded, imho.
------------------------------
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 5211
***************************************