[14069] in Perl-Users-Digest
Perl-Users Digest, Issue: 1479 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 24 14:06:03 1999
Date: Wed, 24 Nov 1999 11:05:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943470321-v9-i1479@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 24 Nov 1999 Volume: 9 Number: 1479
Today's topics:
'/usr/bin/file' function in bash for perl??? support@wildapache.net
advanced whois query <jon@home.com>
Array/hash of subroutines? (Cat)
Bath.pm Meeting (Leon Brocard)
compare a string to values in an array? geetago@my-deja.com
Re: compare a string to values in an array? (Mark-Jason Dominus)
Re: compare a string to values in an array? <lr@hpl.hp.com>
Re: dynamically created filehandles. Help!! (Mark-Jason Dominus)
Re: foreach on a hash within a hash <dbartmess@netlibrary.com>
Re: Generating pi <jarrowwx@home.com>
Re: how to print special characters? + new question <lr@hpl.hp.com>
HTTP upload without browser hatteluve@my-deja.com
Re: Initialize Variables <aqumsieh@matrox.com>
Re: Initialize Variables <cassell@mail.cor.epa.gov>
Re: lex, yacc perl ports (Mark-Jason Dominus)
lock a dbm file on solaris <qchen@snet.net>
Re: need help with regular expr. (Craig Berry)
Re: New dialect of perl: xperl (or reinventing perl, or (Abigail)
Re: New dialect of perl: xperl (or reinventing perl, or (Benjamin Franz)
Re: New dialect of perl: xperl (or reinventing perl, or <durbin@cig.mot.com>
Re: newbie PERL question <cassell@mail.cor.epa.gov>
Re: newbie PERL question <cassell@mail.cor.epa.gov>
Re: newbie PERL question <cassell@mail.cor.epa.gov>
Newbie: Hash question dan_simser@my-deja.com
Re: Newbie: Hash question <lr@hpl.hp.com>
Re: Outputting "#" in URL for anchoring <jeff@vpservices.com>
Re: Percentages Question <nandu@cimedia.com>
Re: Percentages Question <cassell@mail.cor.epa.gov>
Perl vs. ASP (was Re: win32 alarm workaround???) <peter@berghold.net>
Please help install GD.pm 1.23 <A.Lazic@Austria.EU.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Nov 1999 18:25:44 GMT
From: support@wildapache.net
Subject: '/usr/bin/file' function in bash for perl???
Message-Id: <383c2b87.2246961930@news.wildapache.net>
Hello,
Does anyone know if there is a perl function to get the same results
as the 'file' function in bash?
I need to determine what types of files are in a directory and want to
be able to do something similar to the following in bash:
...
/usr/bin/file -b somefile.zip | grep -q "Zip archive data"
if /bin/test $? -eq 0; then
## do the things that I need to do to somefile.zip
...
Thanks in advance,
M
------------------------------
Date: Wed, 24 Nov 1999 18:44:48 -0000
From: "Jon" <jon@home.com>
Subject: advanced whois query
Message-Id: <943469308.19846.0.nnrp-02.d4e4391f@news.demon.co.uk>
Can anyone point me towards information on how to setup advanced queries
network solutions whois database? I am trying to find / build a perl tool
that will query the whois by field
thanks
Jon
------------------------------
Date: Wed, 24 Nov 1999 17:54:43 GMT
From: digilady@NOhome.SPAMcom (Cat)
Subject: Array/hash of subroutines?
Message-Id: <383c2742.2696870@news>
Hi!
I need to set up an array of refs to subroutines. Attempted to glob
them, and actually *saw* a ref at one point, but can't then call the
thing.
Code looks like this:
sub nada;
sub nada2;
@subs2=(*nada,*nada2);
\&s=$subs[0];
print "$s";
sure enough, it prints main::nada.
How on earth (or can I) then call it?
TIA,
Cat LeDevic
------------------------------
Date: 24 Nov 1999 17:34:10 GMT
From: acme@tigger.netcraft.com (Leon Brocard)
Subject: Bath.pm Meeting
Message-Id: <slrn83o7hj.3u9.acme@tigger.netcraft.com>
Bath.pm is the Perl Monger group for people in the Bath (Somerset, UK)
area.
We meet (very informally) at The Hobgoblin in Saint James's Parade,
Bath, every Wednesday from 6pm. Come and join us!
This is just a little heads-up to attract more people to Bath.pm.
As a kind of side note, some of us will be marching off to London
this weekend to join Croydon.pm, London.pm, and NY.pm. Greetings
to NY.pm-ers and I hope you enjoy your stay in the UK...
Leon
--
Leon Brocard................................http://bath.pm.org/
leon@netcraft.com........................http://www.astray.com/
... C program run. C program crash. C programmer quit
------------------------------
Date: Wed, 24 Nov 1999 17:25:17 GMT
From: geetago@my-deja.com
Subject: compare a string to values in an array?
Message-Id: <81h71m$351$1@nnrp1.deja.com>
Is there a way to compare a string to values in an array to see if
there is a match without looping through each value in the array?
Would appreciate your suggestions.
thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 Nov 1999 17:57:08 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: compare a string to values in an array?
Message-Id: <81h8sb$5a8$1@monet.op.net>
In article <81h71m$351$1@nnrp1.deja.com>, <geetago@my-deja.com> wrote:
>Is there a way to compare a string to values in an array to see if
>there is a match without looping through each value in the array?
There are two answers to your question.
2. There is no way to examine the elements of an array without looping
over them. The program is not clairvoyant.
1. You should have been using a hash instead of an array. If the
values in the array were hash keys instead of array elements, then
you could use
exists $hash{string};
to see if the string was one of the keys.
------------------------------
Date: Wed, 24 Nov 1999 10:04:06 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: compare a string to values in an array?
Message-Id: <MPG.12a5c872a007081a98a278@nntp.hpl.hp.com>
In article <81h71m$351$1@nnrp1.deja.com> on Wed, 24 Nov 1999 17:25:17
GMT, geetago@my-deja.com <geetago@my-deja.com> says...
> Is there a way to compare a string to values in an array to see if
> there is a match without looping through each value in the array?
Not without looping through the array at least once.
> Would appreciate your suggestions.
I suggest you read perlfaq4: "How can I tell whether a list or array
contains a certain element?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 24 Nov 1999 17:06:54 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: dynamically created filehandles. Help!!
Message-Id: <81h5t0$48a$1@monet.op.net>
In article <81h38k$5r$1@nnrp1.deja.com>, <jkosowan@my-deja.com> wrote:
>I have a hack that will work, namely putting $handlelist[0] into a
>separate variable then calling the <>:
>
>my $temp = $handlelist[0];
>$date_stamp = <$temp>;
That's what you should do. See perlfaq5 for example:
How can I use a filehandle indirectly?
...
In the examples above, we assigned the filehandle to a
scalar variable before using it. That is because only
simple scalar variables, not expressions or subscripts
into hashes or arrays, can be used with built-ins like
`print', `printf', or the diamond operator.
------------------------------
Date: Wed, 24 Nov 1999 10:37:52 -0700
From: "David A. Bartmess" <dbartmess@netlibrary.com>
Subject: Re: foreach on a hash within a hash
Message-Id: <81h7ro$ao0$1@fir.prod.itd.earthlink.net>
If I modify the code as below, it doesn't work... What am I thinking wrong??
The values come out null.
$\ = "\n";
$h{a}{w} = 1;
$h{a}{x} = 2;
$h{b}{y} = 3;
$h{b}{z} = 4;
sub (\%)
my($t1) = @_;
foreach $k1 (keys %$t1) {
print $k1;
foreach $k2 (keys %{$t1->{$k1}}) {
print $k2;
print $t1->{$k1}{$k2};
}
}
}
Thunderdust (TomH) wrote in message <38321b04.2006428@news.bedford.net>...
>$\ = "\n";
>
>$h{a}{w} = 1;
>$h{a}{x} = 2;
>$h{b}{y} = 3;
>$h{b}{z} = 4;
>
>foreach $k1 (keys %h) {
> print $k1;
> foreach $k2 (keys %{$h{$k1}}) {
> print $k2;
> print $h{$k1}{$k2};
> }
>}
>
>On Wed, 17 Nov 1999 03:32:07 GMT, Curtis Jones
><curtisj@BannerFusion.com> wrote:
>
>>What is the best way to go about retrieving a list of the values of a
>>hash within a hash?
>>
>>If I simply have a hash,
>>
>>%hash;
>>$hash{'one'};
>>$hash{'two'};
>>$hash{'three'};
>>
>>I can do a:
>>
>>foreach ( sort keys %hash ) ...
>>
>>to retrieve each of the values in it, but I can't seem to figure out how
>>to do that to a hash that is within a hash...or deeper.
>>
>>Thanks for any help.
>>
>>-Curtis
>>
>>
>>Sent via Deja.com http://www.deja.com/
>>Before you buy.
>
>
>
>
>
>
>Schnoodlewinks-constantly leveling up warrior
>Fluffy_the_Fly-lvl.7 warrior (x2-don't ask!)
>Flame-QFG5 Paladin
------------------------------
Date: Wed, 24 Nov 1999 17:11:30 GMT
From: John Arrowwood <jarrowwx@home.com>
Subject: Re: Generating pi
Message-Id: <Pine.LNX.4.10.9911240905200.11126-100000@c42753-a.potlnd1.or.home.com>
On 22 Nov 1999, Csaba Raduly wrote:
> Here's one I adapted from a C program:
[code snipped]
> Calculating 1000 digits in C took 0.61 sec ( gcc -O5 )
> Calculating 1000 digits in Perl: 24.68 sec
That is SWEET! Very impressive, and answers well to the original poster's
request.
Don't suppose you could send me the C source that you ported from, could
you? Since it's not Perl, the group probably isn't interested, so via
e-mail is probably okay, just don't forget to remove the NOSPAM from the
hostname... Thanks!
-- John
------------------------------
Date: Wed, 24 Nov 1999 09:53:29 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how to print special characters? + new question
Message-Id: <MPG.12a5c5f927734b8d98a276@nntp.hpl.hp.com>
In article <YmU_3.2769$QA6.186179584@news.telia.no> on Wed, 24 Nov 1999
16:28:40 GMT, cuteman <cuteman@sensewave.com> says...
...
> I just thought I should add another aproach. I made a script listing up the
> ASCII value of each character. Then I found that the characters I needed had
> the values:
> æ:230
> ø:248
> å:229
>
> Then when I wanted to print something I used the syntax
>
> print "Trykk her for ";
> print chr(229);
> print " g";
> print "chr(229);
> print " tilbake\n";
>
> Now I wonder how this could be written in one line.(?)
Let me count the ways...
print "Trykk her for "; print chr(229); print " g"; print chr(229);
print " tilbake\n";
(Wrapped by the newsreader, sorry! Oh, that's not what you had in mind
anyway. :-)
print "Trykk her for ", chr(229), " g", chr(229), " tilbake\n";
print "Trykk her for ${\chr(229)} g${\chr(229)} tilbake\n";
printf "Trykk her for %c g%c tilbake\n", 229, 229;
print pack 'A*CA*CA*' => 'Trykk her for ', 229, ' g', 229, " tilbake\n";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 24 Nov 1999 18:42:17 GMT
From: hatteluve@my-deja.com
Subject: HTTP upload without browser
Message-Id: <81hbi8$6n2$1@nnrp1.deja.com>
Can anyone help me with a Perl program to upload
a file to a web server ?
Please note that I'm NOT looking for a script to
create a html form with <input type=file> in it,
and I'm NOT looking for a cgi-script to handle
the server side of the upload.
What I'm looking for is a standalone program
that connects to a web server and uploads a file.
I thought something like the script below would
work but the server doesn't like it at all.
#!/usr/local/bin/perl -w
use IO::Socket;
$EOL = "\015\012";
$BLANK = $EOL x 2;
$host = "localhost";
$port = "8080";
$doc = "/cgi-bin/upload.cgi";
$file = "/tmp/TEST.TXT";
open (TEST, "<$file") or die;
$len = -s TEST;
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => $host, PeerPort => $port);
unless ($remote) { die "cannot connect to http
daemon on $host" }
$remote->autoflush(1);
print $remote "POST $doc HTTP/1.0" . $BLANK;
print $remote "Content-Length: " . $len . $BLANK;
print $remote "Content-type: multipart/form-data;
boundary=---------------------------19740979919896"
. $BLANK;
print $remote
"-----------------------------19740979919896" .
$BLANK;
print $remote 'Content-Disposition: form-data;
name="TEST"; filename="$file"' . $BLANK;
while (<TEST>) {
chomp();
print $remote "$_" . $BLANK;
}
close TEST;
print $remote $BLANK .
"-----------------------------19740979919896--" .
$BLANK;
while ( <$remote> ) {print}
close $remote;
exit;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 Nov 1999 10:44:28 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Initialize Variables
Message-Id: <x3yso1v3ndv.fsf@tigre.matrox.com>
abigail@delanet.com (Abigail) writes:
> Brett W. McCoy (bmccoy@foiservices.com) wrote on MMCCLXXV September
> MCMXCIII in <URL:news:slrn83lunq.bke.bmccoy@moebius.foiservices.com>:
> ## Not gonna happen. It's a unary operator.
> ##
> ## If you have $a, @a, $B, %B, you can do typeglobbing:
> ##
> ## undef *a;
> ## undef *B;
I wouldn't recommend that.
>
> reset 'aB'; # ;-)
Interesting :-)
A small caveat though for the unwary. From perlfunc:
Resets only package variables--lexical variables are
unaffected, but they clean themselves up on scope exit
anyway, so you'll probably want to use them instead.
--Ala
------------------------------
Date: Wed, 24 Nov 1999 10:06:10 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Initialize Variables
Message-Id: <383C2912.5ACD9F4@mail.cor.epa.gov>
Abigail wrote:
[snip]
> reset 'aB'; # ;-)
Nifty. I hadn't thought of using reset() . But if the querent's
variables are lexically scoped, reset() won't wipe them.
And won't you need to say:
reset 'abcAB';
to get all the listed variables? Uh-oh, I just ate @ARGV ...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Nov 1999 17:40:49 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: lex, yacc perl ports
Message-Id: <81h7tv$52a$1@monet.op.net>
In article <slrn83ne9i.d7m.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
> "This program, py, implements LALR(1) parsers in Perl.
> These are the sorts of parsers produced by YACC and Bison.
> But the program is a complete oddity."
Yeah. It's actually described at
http://www.plover.com/~mjd/perl/py/
I have a much better version sitting around, but I've never released
it because why bother updating an oddity? I did use the better
version in my implementation of `units' however. Units is at
http://www.plover.com/~mjd/perl/units/, and you can see the parser;
it's all the code under the comment that says:
################################################################
#
# I'm the parser
#
To anyone familiar with how YACC parsers work, it should be completely
transparent. To everyone else, it's probably impenetrable.
The lexer may be instructive, however.
------------------------------
Date: Wed, 24 Nov 1999 13:04:53 -0500
From: Richard Chen <qchen@snet.net>
Subject: lock a dbm file on solaris
Message-Id: <383C28C5.44B0A44D@snet.net>
Hello,
I tried to lock a dbm file on a sparc solaris 2.6 box
like this:
use MLDBM qw(DB_File Storable);
use Fcntl;
tie(%hash,'MLDBM','foobar',O_RDWR|O_EXLOCK,0666) or die $!;
It complains with the following:
Your vendor has not defined Fcntl macro O_EXLOCK ...
Does anyone know a reliable way to lock a dbm file
on a solaris machine? I remember reading somewhere that
the usual documented way to lock a dbm file is flawed.
But I don't remember the details.
Thanks for any info.
Richard
------------------------------
Date: Wed, 24 Nov 1999 18:47:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: need help with regular expr.
Message-Id: <s3ocm2umrrp74@corp.supernews.com>
venkatmohan@my-deja.com wrote:
: I need to parse out the following string
:
: 2323I am a 3343perl43progra!mer
:
: In this string I want to extract only the white space and
: alphabets (both lower and upper case). Please help me with
: forming the regular expr for this.
Actually, a tr/// might be a better choice:
$str =~ tr/A-Za-z \t//cd;
: I tried this
:
: $a="2323I am a 3343perl43progra!mer";
: $a=~ s/(?![a-zA-Z\s]+)//g;
:
: but this doesn't works.
I'm not sure what you think you're doing there, but what you have actually
written is fairly nonsensical. It tries to find every place in the string
not followed by alpha or space chars, and subsitutes each such zero-width
place with zero-width nothingness.
To actually do this as a substitution would look like this:
s/[^A-Za-z\s]+//g;
(It will work with or without that '+', by the way. It may be instructive
to analyze how it behaves in each case.)
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: 24 Nov 1999 11:58:56 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: New dialect of perl: xperl (or reinventing perl, or perl-izing jpython)
Message-Id: <slrn83oa13.m2v.abigail@alexandra.delanet.com>
Chris Durbin (durbin@cig.mot.com) wrote on MMCCLXXVI September MCMXCIII
in <URL:news:Pine.GSO.4.21.9911241047250.19723-100000@ballad>:
__
__ A) Is there a "perfect" OO language, and if so what is it?
No, otherwise, everyone would be using it.
__ B) What are your thoughts on design patterns: Useful programming
__ tools, or over-generic crutches for lazy programmers?
What do you mean with "design patterns"?
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 24 Nov 1999 18:04:45 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: New dialect of perl: xperl (or reinventing perl, or perl-izing jpython)
Message-Id: <1NV_3.225$Wo6.3632@typhoon01.swbell.net>
In article <slrn83o40s.m2v.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>I'm familiar with the trick. The trick requires extra work, and it requires
>cooperation *DONE IN ADVANCE*. It's making easy things hard. It's not
>Perl. It's anti-Perl.
Yes, but using 'base' 'Class::' constructors rather than always
rolling your own would make it easy.
package MyOwnClass;
use base qw(Class::ImprovedNamedParms);
sub new {
my $proto = shift;
my $class = ref ($proto) || $proto || __PACKAGE__;
my $self = SUPER::new({ -class => $class,
-namespace => __PACKAGE__,
-legal_parms => [qw(-named_parm -another_named_parm)],
-init_values => [@_],
});
$self;
}
This would by trivially sub-classable with no worries.
(Note - 'Class::NamedParms' doesn't actually do that trick - but it is
on my 'to do' list).
--
Benjamin Franz
------------------------------
Date: Wed, 24 Nov 1999 10:58:05 -0600
From: Chris Durbin <durbin@cig.mot.com>
Subject: Re: New dialect of perl: xperl (or reinventing perl, or perl-izing jpython)
Message-Id: <Pine.GSO.4.21.9911241047250.19723-100000@ballad>
On 23 Nov 1999, Abigail wrote:
A>Nandu Shah (nandu@cimedia.com) wrote on MMCCLXXV September MCMXCIII in
A><URL:news:m3emdh3zgf.fsf@budgie.cimedia.com>:
A>?? abigail@delanet.com (Abigail) writes:
<snip of some pretty interesting stuff about OO Perl>
A>About the only positive thing OO-Perl gives you is the '->' syntax, so
A>our pet language can look cool, just like Java and C++. (That doesn't
A>imply I think Java and C++ have perfect OO).
A>
A>
A>Abigail
A>
I know this is getting really off-topic, but OO is something that
I am relatively new to (Java and C++, for a few years, by no
means in any meaning uses) but in my ongoing quest to know
EVERYTHING, I have a few questions:
A) Is there a "perfect" OO language, and if so what is it?
B) What are your thoughts on design patterns: Useful programming
tools, or over-generic crutches for lazy programmers?
You seemed like the perfect person to ask, as you already DO know
everything $^)...
--
Chris Durbin Motorola, Cellular Infrastructure Group
--------------------------------------------------------------
Phone: (847)435-9558 Pager: 1-800-759-8888, #1268222
Fax: (847)632-4552 Email: durbin@cig.mot.com
------------------------------
Date: Wed, 24 Nov 1999 10:12:08 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie PERL question
Message-Id: <383C2A78.116451D9@mail.cor.epa.gov>
Jeff Zucker wrote:
>
> David Cassell wrote:
[snip]
> > Jeff, I don't know how to break it to you, but *all*three*
> > of those groups exist.
>
> Ooops, silly me. <gilda> never mind </gilda>.
Probably Freudian. You just didn't *want* to believe those
other groups existed.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Nov 1999 10:13:47 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie PERL question
Message-Id: <383C2ADB.5D1B3AEE@mail.cor.epa.gov>
Andrew Johnson wrote:
>
> In article <383B3556.52048C1E@mail.cor.epa.gov>,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> [snip]
> ! I think that the original poster might benefit from buying
> ! [and reading] Andrew Johnson's runaway best-seller "Elements
> ! of Programming with Perl." Soon to be a major motion picture
> ! starring Jeff Speakman.
>
> you're just trying make up for that 'fashion victim' remark
> now aren't you?
I wouldn't call a movie starring Jeff Speakman to be 'praise'
of anything... He's the kind of actor who makes people
reconsider Jean Claude van Damme as 'talented'.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Nov 1999 10:17:38 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie PERL question
Message-Id: <383C2BC2.3A011BA8@mail.cor.epa.gov>
Martien Verbruggen wrote:
>
> On Tue, 23 Nov 1999 16:46:14 -0800,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
[snip]
> > Jeff, I don't know how to break it to you, but *all*three*
> > of those groups exist.
>
> Not here they don't :) And I'll be damned before I go to deja to read
> any of the ones that aren't available from my newsfeed.
<Yorkshireman>
You're lucky!
</Yorkshireman>
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Nov 1999 18:12:08 GMT
From: dan_simser@my-deja.com
Subject: Newbie: Hash question
Message-Id: <81h9pj$5bq$1@nnrp1.deja.com>
I have a form with 15 possible entries, with only four fields required.
These fields are uploaded image files from the user. I am able to
currently save the files one by one using the code below:
opendir (DIR, $slide_dir) or die "Unable to open directory $slide_dir:
$!";
open(FILE, ">$slide_dir/$p1_photo") or die "Cannot open file
$org_photo1 for writing: $!";
while ($Bytes = read($org_photo1,$Buffer,1024)) {
$BytesRead += $Bytes;
binmode FILE;
print FILE $Buffer;
}
close FILE;
closedir DIR;
but what I want to do is instead of creating a section of code like
above for each field, I would like to have a loop.
Each uploaded file has a variable name $p1_photo...$p15_photo/
$org_photo1...$org_photo15.
Anyway to create one loop to do the above code for every file?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 24 Nov 1999 10:48:38 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie: Hash question
Message-Id: <MPG.12a5d2e593f9f1af98a27a@nntp.hpl.hp.com>
In article <81h9pj$5bq$1@nnrp1.deja.com> on Wed, 24 Nov 1999 18:12:08
GMT, dan_simser@my-deja.com <dan_simser@my-deja.com> says...
There are two things wrong with your Subject: It contains the word
'Newbie', which is guaranteeed to get you ignored by many people; It
says 'Hash question', but there aren't any hashes in your question.
Other than that, the Subject is perfect.
> I have a form with 15 possible entries, with only four fields required.
> These fields are uploaded image files from the user. I am able to
> currently save the files one by one using the code below:
> opendir (DIR, $slide_dir) or die "Unable to open directory $slide_dir:
> $!";
Good diagnostic, but useless statement. You need to open a directory
only when you are going to read the names of the entries using readdir,
etc. You don't need to open it to read a file in it.
> open(FILE, ">$slide_dir/$p1_photo") or die "Cannot open file
> $org_photo1 for writing: $!";
That diagnostic refers to the wrong filename.
> while ($Bytes = read($org_photo1,$Buffer,1024)) {
Where is this file opened? You need a filehandle, but this looks like a
filename.
> $BytesRead += $Bytes;
> binmode FILE;
This should be immediately after opening the file, not in the read-loop.
> print FILE $Buffer;
> }
> close FILE;
> closedir DIR;
>
> but what I want to do is instead of creating a section of code like
> above for each field, I would like to have a loop.
>
> Each uploaded file has a variable name $p1_photo...$p15_photo/
> $org_photo1...$org_photo15.
>
> Anyway to create one loop to do the above code for every file?
Sure. UNTESTED:
for my $num (1 .. 15) {
open(IN, $org_photo$num) or die
"Cannot open file $org_photo$num for reading: $!";
binmode IN;
open(FILE, ">$slide_dir/$p{$num}_photo") or die
"Cannot open file $p{$num}_photo for writing: $!";
binmode FILE;
while (my $bytes = read(IN, $Buffer, 1024)) {
$BytesRead += $bytes;
print FILE $Buffer;
}
close IN;
close FILE;
}
There is also a File::Copy module, if you prefer to have someone else do
the work.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 24 Nov 1999 16:48:21 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Outputting "#" in URL for anchoring
Message-Id: <383C1680.F17C2ED8@vpservices.com>
ether_nut@my-deja.com wrote:
>
> Let me re-phrase the origional question. It works embedding a url
> with an anchor using print "http//.../index.html?#AZ\">\n"; in IE only.
> Netscape just spits out /index.html? and ignores the whole anchor.
If Perl is doing what you want (printing characters to an HTML page),
then there is no Perl problem. If the HTML is not correct or a browser
does not know how to deal with it, then that is an HTML or a browser
problem. Please ask your question in a newsgroup having to do with
browsers or HTML.
--
Jeff
------------------------------
Date: 24 Nov 1999 12:24:27 -0500
From: Nandu Shah <nandu@cimedia.com>
Subject: Re: Percentages Question
Message-Id: <m3n1s33ir8.fsf@budgie.cimedia.com>
abigail@delanet.com (Abigail) writes:
> Except for the spacing. There ought to be spaces around binary operators
> and there's a space *before* an opening paren, but *not after*, nor before
> a closing paren. Furthermore, avoid mixed quotes if possible. Hence:
One thing I can say with certainty about you is that at least you have
an intelligible (and intelligent) Perl style. The mixed quotes bit
smacks a little of dementia, however. ;)
Nandu
------------------------------
Date: Wed, 24 Nov 1999 10:02:47 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Percentages Question
Message-Id: <383C2847.8AC74246@mail.cor.epa.gov>
Abigail wrote:
>
> Larry Rosler (lr@hpl.hp.com) wrote on MMCCLXXVI September MCMXCIII in
> <URL:news:MPG.12a4e16364478f9098a266@nntp.hpl.hp.com>:
[snip]
> $avg = do {local $" = "+"; eval ("@x") / @x};
>
> // I am sure you realize that this is both slow and EEE-vil.
>
> Yeah, but being evil puts me opposite to Barney, so that isn't too bad.
Ummm, from this I deduce that you have no small children.
Barney is evil. With a capital 'E'. Even more evil than your
most ingenious code.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Nov 1999 18:47:12 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Perl vs. ASP (was Re: win32 alarm workaround???)
Message-Id: <Pine.LNX.3.96.991124134338.2881A-100000@uboat.berghold.net>
On Wed, 24 Nov 1999, Sara wrote:
> Why perl for NT? why not just use asp? I thought people write perl in NT
> only so it can work on both unix and nt
>
Ignoring the fact that this is quite off topic for a moment....
IMHO this is the equivilant of asking why not C++ vs. VBasic. It is a
matter of personal preference. Since this is the comp.lang.perl NG and
not the comp.lang.asp NG what would language would you expect people to be
discussing? Forth?
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold Peter@Berghold.Net
"Linux renders ships http://www.berghold.net
NT renders ships useless...." ICQ# 11455958
------------------------------
Date: 24 Nov 1999 18:11:21 +0100
From: Alexander Lazic <A.Lazic@Austria.EU.net>
Subject: Please help install GD.pm 1.23
Message-Id: <m37lj7ddc6.fsf@samurai.intern.austria.eu.net>
hi,
I have some troubles to install this one with the new gd-lib gd-1.7.3.
The Problem is this:
--------------------------------
samurai:~/.cpan/build/GD-1.23 # make test TEST_VERBOSE=1
PERL_DL_NONLAZY=1 /usr/local/bin/perl -Iblib/arch -Iblib/lib
-I/usr/lib/perl5/5.00502/i686-linux -I/usr/lib/perl5/5.00502
-e 'use Test::Harness qw(&runtests $verbose); $verbose=1; runtests @ARGV;'
t/*.t t/GD................1..9
Can't load './blib/arch/auto/GD/GD.so' for module GD:
./blib/arch/auto/GD/GD.so: undefined symbol: SetCPerlObj at
/usr/lib/perl5/5.00502/i686-linux/DynaLoader.pm line 168.
at t/GD.t line 11
BEGIN failed--compilation aborted at t/GD.t line 11.
not ok 1
dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-9
Failed 9/9 tests, 0.00% okay
Failed Test Status Wstat Total Fail Failed List of failed
-------------------------------------------------------------------------------
t/GD.t 2 512 9 9 100,00% 1-9
Failed 1/1 test scripts, 0.00% okay. 9/9 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 2
-----------------
but only the make is ok ?!?!?!
Also the make && make install by the gd-library is ok ??
perl: This is perl, version 5.005_02 built for i686-linux
cc: egcs-2.91.60
Can anyone help me please?
Thanx
al ;-)
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1479
**************************************