[12215] in Perl-Users-Digest
Perl-Users Digest, Issue: 5815 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 28 11:07:29 1999
Date: Fri, 28 May 99 08:00:27 -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: 5815
Today's topics:
Alternative to deprecated scalar split <macintsh@cs.bu.edu>
Re: conver TO url encoded <devans@radius-retail.kom>
Re: conver TO url encoded <jdporter@min.net>
Re: conver TO url encoded <gellyfish@gellyfish.com>
Re: Converting from ASCII to ANSI (and vice versa) <uri@sysarch.com>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (I R A Aggie)
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Benjamin Franz)
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Tad McClellan)
Re: Getting Digits out of a String with m// <Allan@due.net>
Re: Getting Digits out of a String with m// <andre.pletschette@ltam.lu>
Re: Getting Digits out of a String with m// <jdporter@min.net>
Re: HASH troubles? <jdporter@min.net>
Re: Help explain @_ (John Lathrop)
Re: Help on Regular Xpression <jdf@pobox.com>
How can I use binary compiled code for CGI? <okpolis@okpolis.joo.net>
Re: how many people have obscure addresses (was Re: Ext <Russell_Schulz@locutus.ofB.ORG>
Re: killing exec()ed process - how? <otis@my-deja.com>
Looking for advice on a model <drummond-m@rmc.ca>
Re: m/\d.*?^\d/s; <andre.pletschette@ltam.lu>
MacPerl - ping other hosts PETER@yaleads.ycc.yale.edu
Need help on fork <jkit@jpmorgan.com>
Newbie: Line spacing jknoll@my-deja.com
Re: Newbie: Line spacing <uri@sysarch.com>
Re: Obtaining file version info <stickler.ka@pg.com>
opening .exe files amidalla@my-deja.com
Re: opening .exe files <tchrist@mox.perl.com>
PB writing an uploaded file in perl (size changes!) <olivier.maas@at-lci.com>
Re: Perl call to c/c++ DLL (Scott McMahan)
Re: perl script as an executable <uri@sysarch.com>
pre-allocating memory needs in perl? (Nathan O. Siemers)
Re: pre-allocating memory needs in perl? <uri@sysarch.com>
Re: Question about date <dgris@moiraine.dimensional.com>
Re: two questions, pls help <craig@mathworks.com>
Re: undef of namespaces <marc.dietrich@physik.uni-giessen.de>
Re: use File::Copy; my $my_dir = "C:/";chdir($my_dir) <devans@radius-retail.kom>
Re: workarounds for prototypes <tchrist@mox.perl.com>
Re: Y2K infected Perl code (Malcolm Ray)
Re: Y2K infected Perl code <newsposter@cthulhu.demon.nl>
Re: Y2K infected Perl code ()
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 May 1999 14:18:35 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: Alternative to deprecated scalar split
Message-Id: <7im8jr$m4a$1@news1.bu.edu>
"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? Specifically, I enjoy the awk-like whitespace skipping
of split(' ', ...) or just plain split with no arguments. This
is a useful behavior! It's a shame that grabbing just the
number of fields ends up squashing @_. What are my options
here? Is there a better way to do this? Example:
$foo = " one two three ";
$num_fields = split(' ', $foo); # Bzzzt! Deprecated!
print $num_fields; # Prints "3"
An ugly alternative is something like:
$num_fields = @{[split(' ', $foo)]}; # Yuck!
but the real goal here is just to get a scalar value, without
saving the fields in any array: @_, temporary, or whatever.
Doing it "by hand" with regexes, substitutions, etc. also seems
like a waste, since split is so close to doing what I want in
one simple step. Is this being addressed in the perl dev track?
Or am I just using the wrong function for this?
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: Fri, 28 May 1999 13:57:32 +0100
From: "Dave Evans" <devans@radius-retail.kom>
Subject: Re: conver TO url encoded
Message-Id: <374e8f0b.0@nntp.mmi.org>
[mailed+posted]
There's a couple of subs in CGI that do that, e.g.
use CGI;
$urlpart = CGI::escape($normalstring);
and
$normalstring = CGI::unescape($urlpart);
Or more preferably (especially if you're not using CGI anyway) how about:
use URI::Escape;
$escaped = uri_escape($unescaped);
$unescaped = uri_unescape($escaped);
Mark Hamlin wrote in message <7ilv9s$9ni$1@pheidippides.axion.bt.co.uk>...
>Has anyone got a script to convert a string to the format of URL encoded
>data, ie spaces to pluses, symbols to %<numeric>.
>
>Saver me getting sick on regexp.
>
>Your help is much appreciated,
>Cheers
>Mark Hamlin
>Systems Integration
>
>
>
>
------------------------------
Date: Fri, 28 May 1999 13:33:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: conver TO url encoded
Message-Id: <7im5vp$hij$1@nnrp1.deja.com>
In article <7ilv9s$9ni$1@pheidippides.axion.bt.co.uk>,
"Mark Hamlin" <mark@artdigital.co.uk> wrote:
> Has anyone got a script to convert a string to the format of URL
encoded
> data, ie spaces to pluses, symbols to %<numeric>.
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).
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.
--
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: 28 May 1999 15:23:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: conver TO url encoded
Message-Id: <374ea6f1@newsread3.dircon.co.uk>
Mark Hamlin <mark@artdigital.co.uk> wrote:
> Has anyone got a script to convert a string to the format of URL encoded
> data, ie spaces to pluses, symbols to %<numeric>.
>
> Saver me getting sick on regexp.
>
You dont need to worry about the s/ /+/ as %20 is more correct.
$string =~ s/([^a-zA-Z0-9])/sprintf("%%%02X",ord($1))/eg;
There are modules that will do this as well.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: 28 May 1999 10:33:05 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Converting from ASCII to ANSI (and vice versa)
Message-Id: <x7yai9i7ry.fsf@home.sysarch.com>
>>>>> "PK" == Poul Kornmod <pbk@rdsas.com> writes:
PK> Dear Eric,
PK> I'm sorry that I didn't make myself clear.
PK> You have of cause right - but what I need is be able to display,
PK> danish, german, swedish etc. special characters
PK> eg. "xfeXFE|\iI....." in
PK> Windows. The file that contains these characters is made in ASCII
PK> format and can be view in a DOS box using EDIT.
now that you have cleared up your ascii/ansi confusion? what is your
perl question?
if you want a non-perl solution which is comprehensive and fast, check
out the recode program (from gnu IIR).
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: 28 May 1999 13:36:00 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7kt73u.78p.fl_aggie@thepentagon.com>
On Fri, 28 May 1999 08:15:28 GMT, finsol@ts.co.nz <finsol@ts.co.nz>, in
<7iljav$554$1@nnrp1.deja.com> wrote:
+ to Y2K as any other language, that no language is immune and that all
+ applications need to be checked for Y2K problems.
Of course. I don't think anyone has objected to that. The devil
is in the details, and the details in programming is the actual
implementation. If it isn't right...well...it ISN'T RIGHT.
+ Perl code is just as likely to have Y2K problems as any other language
+ and perhaps because of the booby trap code problem, more so.
More than, say, C/C++ under unix?
+ serious problems for the organisations that continue to use the Perl
+ code that remains unchecked.
If those organizations are concerned about their perl code, I can come
up with a fee scale and check it for them. Until then, it is their
problem, not mine.
Unlike what seems like most of the rest of the planet, I've actually
read both 'perldoc -f localtime' and the man page for the C library
localtime. I *know* what localtime returns for a year, and I know what
an "offset" means, and how to deal with it...
James
------------------------------
Date: Fri, 28 May 1999 14:22:11 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <nEx33.1997$kd5.212304@typhoon-sf.snfc21.pbi.net>
In article <slrn7kt73u.78p.fl_aggie@thepentagon.com>,
I R A Aggie <fl_aggie@thepentagon.com> wrote:
[snip]
>read both 'perldoc -f localtime' and the man page for the C library
>localtime. I *know* what localtime returns for a year, and I know what
>an "offset" means, and how to deal with it...
What it means is 'Broken-As-Designed'. I've thought long and hard about
year-1900. And it comes down to "It's a hack to allow programmers too
lazy or ignorant to do the right thing to screw up with official sanction."
I couldn't come up with even *one* good use of 'year-1900' being
done _correctly_ that wasn't identical in complexity with using
'year'. Need 2 digit dates? To be Y2K compliant you need %100 in
both cases. Need the difference between two dates? Identical. Need
four digit dates? Hmmm...Seems y-1900 is _slightly_ more complex.
The *only* thing y-1900 wins on is: How many years since 1900?
A remarkably *useless* thing in general.
So what exactly is the benefit of y-1900? It allowed programmers
to _pretend_ to be programming correctly when in fact they were
screwing up horribly *and didn't even save any memory*. A 16 bit
signed int can hold up to _at least_ 32767 on any system I've heard
of. One gets you twenty that the justification of y-1900 amounted
to nothing more than "We already stored 2-digit dates in our fixed
size record databases and it would cost money to fix it right now.
This puts off when we have to _fix_ the problem with a bit of
smoke and mirrors to hide the _existance_ of the problem."
Broken-As-Designed.
Perl doesn't have any direct Y2K problems (although its POD system
does) - but it without question greased the rails (following in C's
footsteps) for *programmers* to have Y2K problems.
--
Benjamin Franz
------------------------------
Date: Fri, 28 May 1999 05:12:48 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <gmmli7.2lp.ln@magna.metronet.com>
Chris Torek (torek@elf.bsdi.com) wrote:
: In article <374d6545@cs.colorado.edu> tchrist@mox.perl.com
: (Tom Christiansen) writes:
: >> There are idiots everywhere. What's your point?
: In article <7ikrh1$kmd$1@nnrp1.deja.com> Jocelyn Amon <finsol@ts.co.nz> writes:
: >That's my point exactly. Idiot's [sic] or not, don't expect perfection from
: >programmers, we're only human.
: Perhaps the reason Perl is so easy to mis-use is that it is so easy
: to *use*. In other words, it "attracts the bigger idiots".
Yes!
And there, ladies and gentlemen, is the short version of
many frequently recurring threads on clpmisc. e.g.:
newbies newsgroup
works command line, but not as CGI
use function without reading about function
syntax error
file locking
etc ...
[
Not to imply that folks who participate in such threads are idiots.
I'm just agreeing that Perl has a greater proportion of less
skilled programmers than languages that have a higher barrier
to entry in the first place.
]
Random .sig file quote for sure!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 28 May 1999 09:25:00 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Getting Digits out of a String with m//
Message-Id: <7im509$et6$1@nntp4.atl.mindspring.net>
Pletschette Andri wrote in message <7ill54$fqu$1@calais.pt.lu>...
:Why doesn't this work?
:
: $pic = "123avdfjdf3dfaksfjd3323dkjf.jpg";
: $pic =~ m@\d+\D@s;
: $numb = $&;
: print "$numb";
:
: ## $numb should become the first digits from $pic, so in this case 123.
: ## But the problem is that it only gets 1.
For me the code snippet prints 123a, which is what I would expect. The
first 3 digits and the first following non-digit (you do have the \D in
there too).
perl version 5.005_02
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
[End of diatribe. We now return you to your regularly scheduled
programming...]
- Larry Wall in Configure from the perl distribution
------------------------------
Date: Sat, 29 May 1999 14:43:06 +0200
From: "Pletschette Andri" <andre.pletschette@ltam.lu>
Subject: Re: Getting Digits out of a String with m//
Message-Id: <7im31a$irk$1@calais.pt.lu>
It's OK, I solved the problem ;-)
------------------------------
Date: Fri, 28 May 1999 13:59:31 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Getting Digits out of a String with m//
Message-Id: <7im7g1$il8$1@nnrp1.deja.com>
In article <7ill54$fqu$1@calais.pt.lu>,
"Pletschette Andri" <andre.pletschette@ltam.lu> wrote:
> Why doesn't this work?
>
> $pic = "123avdfjdf3dfaksfjd3323dkjf.jpg";
> $pic =~ m@\d+\D@s;
> $numb = $&;
> print "$numb";
>
> ## $numb should become the first digits from $pic, so in this case
123.
> ## But the problem is that it only gets 1.
No, it doesn't. Did you actually run this code yourself?
$numb gets '123a' -- exactly what one would expect from the regex.
If you just want to get the first digit (and far be it from me to
wonder why), the pattern should consist solely of a \d, as in:
$pic =~ m@\d@s;
Of course, the s option here is utterly superfluous, and the @'s are
obfuscatory.
$pic =~ /\d/; # this sets $& to the first digit.
--
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 13:27:21 GMT
From: John Porter <jdporter@min.net>
Subject: Re: HASH troubles?
Message-Id: <7im5jm$h6a$1@nnrp1.deja.com>
In article <374e80b9@news1.vip.uk.com>,
"Tobin" <Tobin@breathemail.net> wrote:
>
> Sorry if this email is repeated but it hasn't appeared on the list
after 2
> hours! So i'm re-sending....
You have to wait longer than that. Try a day!
> Basically, my search script seen at http://www.freephonedirectory.com
(panel
> in right bottom corner of main page) is not outputting correctly.
>...
> This script works fine when run locally from the command prompt.
How do you expect people to help you with code they can't see?
Post the code, man!
--
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 14:04:08 GMT
From: lathropj@elite.net (John Lathrop)
Subject: Re: Help explain @_
Message-Id: <7im7ov$4i5$1@berry.elite.net>
Thanks for the explanation Eric. That helps a lot.
------------------------------
Date: 28 May 1999 09:46:32 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: tvn007@my-deja.com
Subject: Re: Help on Regular Xpression
Message-Id: <m31zg171dz.fsf@joshua.panix.com>
tvn007@my-deja.com writes:
> while ( <INFILE> ){
>
> chomp;
> s/_//g;
> s/Z/X/g;
[etc.]
You should read perlop in reference to the tr// transiliteration
operator, and perlrun, to see about the -l, -p, and -e switches in
particular.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 28 May 1999 23:20:46 +0900
From: =?euc-kr?B?udrBvrq5IChQYXJrLCBKb25nLVBvcmsp?= <okpolis@okpolis.joo.net>
Subject: How can I use binary compiled code for CGI?
Message-Id: <7im8qu$l7l$1@news1.kornet.net>
Hello.
I use perlcc, and made binary code. (it's not excutive file that like .exe)
How can I use it on CGI?
I can use it that likes...
perl code.bin queries
I want to run it via browser. How can I?
perl?code.bin&queries ???
------------------------------
Date: Thu, 27 May 1999 22:16:09 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: how many people have obscure addresses (was Re: Extracting emails from array)
Message-Id: <19990527.221609.2H2.rnr.w164w@locutus.ofB.ORG>
Jonathan Stowe <gellyfish@gellyfish.com> writes:
> In comp.lang.perl.misc Russell Schulz
> <Russell_Schulz@locutus.ofb.org> wrote:
a) I wrote it in comp.mail.misc also, and redirected there. It has
nothing to do with Perl, and I mentioned that.
b) Your software is (pointlessly) case-smashing my domain. Odd that
it would spend the extra cycles to make a change with no effective
result (since domains are case-insensitive when mailing).
>> `fred&barney@' contrived example.
>
> Its not a contrived example.
Yes it is, as far as I can tell. What definition of `contrived' are
you using that is so different from mine?
> Why did it take you 3 weeks to post this response.
Does it matter? Was there a change in the RFCs that suddenly made my
point moot, or did `fred&barney' become trademarked, or some other
time-critical event?
But anyway, I was travelling, and working, and having a life. So sorry.
> I figure you as a troll
Yes. That's exactly it. If I don't read c.l.p.misc every day, I'm a
troll. How very perceptive of you.
But, I'm curious -- what do you call someone who redirects non-Perl
messages into c.l.p.misc when they've been redirected out?
> *plonk*
Ah well. I don't suppose you'd be happy if I changed email addresses
just for this thread (like you did), would you?
Since I don't see this having much comp.mail.misc content anymore either,
I'll redirect to myself.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Fri, 28 May 1999 14:02:11 GMT
From: Otis Gospodnetic <otis@my-deja.com>
Subject: Re: killing exec()ed process - how?
Message-Id: <7im7l0$io7$1@nnrp1.deja.com>
In article <u990a98mg9.fsf@wcl-l.bham.ac.uk>,
Brian McCauley <B.A.McCauley@bham.ac.uk> wrote:
> Otis Gospodnetic <otis@my-deja.com> writes:
>
> > I was wondering if it is possible to get the PID of a 'command'
executed
> > by exec()
>
> Exec does not fork(). The PID of the command is the same as the PID
> of the process that called the exec.
I see. Doing ps auxw|grep mycommand shows that.
> > so that the 'command' can be killed directly (killing the
> > process that called the exec() doesn't kill the 'command' - the
> > 'command' keeps running)
>
> If the command is given as a single string with metacharacters rather
> than a list then the string is passed to the shell. This can add an
> extra process which could explain your problem.
I see. Again, if I do ps auxw|grep mycommand I see X processes running
mycommand, as well as X /bin/sh -c .... processes.
I guess that is the problem because when I do a kill I can kill the main
process and those /bin/sh -c processes, but not the other X processes
running mycommand - because by killing I just kill the shells which
really started mycommand from within them. OK.
Now, how do I avoid thess /bin/sh -c processes that stand between my
kill and mycommand?
I do exec() like this:
$mycommand = "/some/command';
$myconfig = '/some/config.conf';
$mystring = 'foo bar';
exec("$mycommand -C$myconfir $mystring");
Would calling it like this work (prevent /bin/sh -c stuff):
exec($mycommand, $myconfig, $mystring);
Many thanks,
Otis
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 28 May 1999 10:42:01 -0400
From: Mark E Drummond <drummond-m@rmc.ca>
Subject: Looking for advice on a model
Message-Id: <374EAB39.624E48C2@rmc.ca>
Hi all. I am about to do a major rewrite on a script we use to synch our
staff/student databases on Oracle with our directory server (Netscape).
The old script slurps _everything_ into memory during connections to the
directory and oracle and then proceeds to process the data.
Basically I want the following rules to be respected:
1. If there exists and entry in Oracle that is not in LDAP, create the
entry in LDAP.
2. If there is an entry in LDAP that is not in oracle, _delete_ the
entry in LDAP.
3. If there is an entry in oracle and a corrensponding entry in LDAP,
check to see if there are any differances between the two and modify
LDAP to match the entry in oracle, oracle be authoritative.
Any suggestions? I'm looking for something that is as time&space
efficient as possible, with time efficiency the most important of the
two. The script runs on a machine with plenty of RAM.
--
___________________________________________________________________
Mark E Drummond Royal Military College of Canada
drummond-m@rmc.ca Computing Services
Linux Uber Alles perl || die
...there are two types of command interfaces in the world of
computing: good interfaces and user interfaces.
- Dan Bernstein, Author of qmail
PGP Fingerprint = 503D A72D AF41 2AD1 D433 C514 98D9 9A39 B25A 2405
------------------------------
Date: Sat, 29 May 1999 14:43:48 +0200
From: "Pletschette Andri" <andre.pletschette@ltam.lu>
Subject: Re: m/\d.*?^\d/s;
Message-Id: <7im33o$it3$1@calais.pt.lu>
It's OK, I solved the problem ;-)
------------------------------
Date: Fri, 28 May 99 09:07:09 EDT
From: PETER@yaleads.ycc.yale.edu
Subject: MacPerl - ping other hosts
Message-Id: <1834C803DS86.PETER@yaleads.ycc.yale.edu>
Hi. I was wondering if anyone could help me in figuring out how to
ping other Macintosh hosts from MacPerl. All Macs are running OT.
I seem to be able to ping some Unix hosts, but all Macs appear to be
unreachable. ?
------------------------------
Date: Fri, 28 May 1999 10:42:58 -0400
From: John Kit <jkit@jpmorgan.com>
Subject: Need help on fork
Message-Id: <374EAB72.3D457142@jpmorgan.com>
I am having a strange problem with fork. I am looping the fork to
create multiple processes to do some task. After a certain mount
of loops it seems to start to duplicate it self forever.
I am reading from a file to pass information for the child to do some
work. The loop depends on how many lines there are in the file. It
seems that after 15 or more loops it starts to duplicate. The file
contains Http Url information which is passed to the child to run
a HTTP/GET with LWP::UserAgent.
Thanks ahead of time.
John
open(WEBSERVERLIST,"$ConfWebServerFile") or die "Can't open file";
while (<WEBSERVERLIST>) {
($DirRef,$Url) = split(/;/,$_);
chomp $Url;
$DirRef = atrim($DirRef);
$Url = atrim($Url);
$DataFile = $DataDir."/".$DirRef."/".$DataFileName;
#----------
# Since we want each url to execute at the same time, well almost the
# same time, we are going to fork off a process for each url.
#
$return = fork;
if ($return == 0) {
#----------
# Child
# This is the child process. We will now go out and get the
# the html page and time it.
#
$Hour = convertto2digit(localtime() ->hour);
$Minute = convertto2digit(localtime() ->min);
$TimeStamp = $Hour.":".$Minute;
($TotalTime, $HttpStat, $Http_Desc, $Content) =
get_html($Url,$ProxyServer);
update_log($DataFile,$TimeStamp,$TotalTime,$HttpStat,$Http_Desc,$Url);
exit(0);
} elsif (defined $return) {
#----------
# Parent
# This is the parent process. We will not do anything here but
# we will just let it loop around again to kick off another
process
# or end when there are no more lines to process.
#
} else {
die "for error:$!\n";
}
#----------
}
------------------------------
Date: Fri, 28 May 1999 13:57:20 GMT
From: jknoll@my-deja.com
Subject: Newbie: Line spacing
Message-Id: <7im7bu$ik6$1@nnrp1.deja.com>
Okay when you are printing text in the ' quotes you just hit return to
move down a line, right?
when you are printing text in the " quotes you use the \n escape to
move down a line, but say you need to move down 4 lines- do you just do
this:
print "\n";
print "\n";
print "\n";
print "\n";
or this:
print "\n\n\n\n";
when you use the ` quotes you are printing out directories,
right? How do you move down lines for this one?
tia
jrk
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 28 May 1999 10:45:03 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newbie: Line spacing
Message-Id: <x7pv3li780.fsf@home.sysarch.com>
>>>>> "j" == jknoll <jknoll@my-deja.com> writes:
j> Okay when you are printing text in the ' quotes you just hit return to
j> move down a line, right?
j> when you are printing text in the " quotes you use the \n escape to
j> move down a line, but say you need to move down 4 lines- do you just do
j> this:
j> print "\n";
j> print "\n";
j> print "\n";
j> print "\n";
j> or this:
j> print "\n\n\n\n";
j> when you use the ` quotes you are printing out directories,
j> right? How do you move down lines for this one?
j> tia
j> jrk
this has my vote for the most confused newbie of the week. you seem to
have english for a first language but i have absolutely no idea what
you are asking. what does quoting have to do with directories? what does
"moving down lines" mean? what are tia and jrk and where did they come
from (and why don't they go back there)?
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!
do we want to start a newbie of the week (or day or microsecond)
contest? :-)
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:33:08 -0400
From: "Kurt Stickler" <stickler.ka@pg.com>
Subject: Re: Obtaining file version info
Message-Id: <7im2gu$9bc$1@remarQ.com>
Yep, NT's QuickView program can do it. But only within it's GUI. I need
to obtain file version information from within a PERL script.
Thanks,
Kurt
------------------------------
Date: Fri, 28 May 1999 13:36:59 GMT
From: amidalla@my-deja.com
Subject: opening .exe files
Message-Id: <7im65r$hlr$1@nnrp1.deja.com>
I'm relatively new to Perl and I am unable to figure out how to run a
simple .exe file using some perl code. All I want to do is be able to
open and run one or more programs simultaneously by a call from a perl
script. Thanks for your help.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 28 May 1999 08:01:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: opening .exe files
Message-Id: <374ea1ac@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
amidalla@my-deja.com writes:
:I'm relatively new to Perl and I am unable to figure out how to run a
:simple .exe file using some perl code. All I want to do is be able to
:open and run one or more programs simultaneously by a call from a perl
^^^^
I do not believe that that word means what you think it means.
Now, check the perlfunc manpage and the perlfaq -- included on your system.
--tom
--
"If ease of use is the highest goal, we should all be driving golf carts."
--Larry Wall
------------------------------
Date: Fri, 28 May 1999 16:41:14 +0200
From: Olivier Maas <olivier.maas@at-lci.com>
Subject: PB writing an uploaded file in perl (size changes!)
Message-Id: <374EAB0A.231B9814@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...
last but not least, the original file disapears after the upload!!! why
would it!!!
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);
unlink $FichAT;
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 14:26:11 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Perl call to c/c++ DLL
Message-Id: <374ea783.0@news.new-era.net>
sbeaulieu@my-deja.com wrote:
> Is it possible for Perl to call c/c++ dlls?
It is MUCH easier if you make these Automation servers.
Scott
------------------------------
Date: 28 May 1999 10:22:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl script as an executable
Message-Id: <x73e0hjmtd.fsf@home.sysarch.com>
>>>>> "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!
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: 28 May 1999 04:32:39 -0400
From: nathan@dnase.hpw.pri.bms.com (Nathan O. Siemers)
Subject: pre-allocating memory needs in perl?
Message-Id: <snkr9o1k314.fsf@dnase.hpw.pri.bms.com>
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 10:38:36 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: pre-allocating memory needs in perl?
Message-Id: <x7u2sxi7ir.fsf@home.sysarch.com>
>>>>> "NOS" == Nathan O Siemers <nathan@dnase.hpw.pri.bms.com> writes:
NOS> Greetings,
NOS> I have some perl code that uses some fairly large hashes
NOS> (multi-megabyte size, nested too). Would there be any
NOS> performance advantage to pre-allocating memory for these,
NOS> instead of making the interpreter allocate more memory
NOS> multiple times as the hash grows in size? If so, how would
NOS> one do this? I believe that one can do this with arrays by
NOS> something like:
NOS> $array[1000000] = 1;
that is better done as $#array = 10000000 so you actually don't store a
bogus value.
NOS> (BTW, what's this simplest way to do this with a large
NOS> scalar? Any advantages to pre-allocation there?)
check out the keys function. and it may save you some time but you
should benchmark it yourself.
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 14:36:31 GMT
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Question about date
Message-Id: <PRx33.1113$x11.5060@wormhole.dimensional.com>
"Nicola" <nicolabo@prof.it> writes:
<snip localtime() code snipped from the docs>
> Can this to create problems with the year 2000 ?
Yes. In fact, it'll create such severe problems that
you are probably better off going back to school to
study marketing.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Fri, 28 May 1999 09:21:52 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: two questions, pls help
Message-Id: <374E9870.48BCA2A8@mathworks.com>
jbell@263.net wrote:
> Hi, all,
>
> I have two newbie questions:
>
> 1.
> under unix(not during compilation), how do I change the default @ISA
> library search paths?
>
push(@ISA, <some_path>)
>
> 2.my perl files can only run with the command "perl MyFile", how can I
> make MyFile itself an excutable(without "perl" in front of it)?
>
chmod +x MyFile
>
> Thanks alot!
>
> ________
> JB
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Craig
------------------------------
Date: Fri, 28 May 1999 15:06:54 +0200
From: Marc Dietrich <marc.dietrich@physik.uni-giessen.de>
Subject: Re: undef of namespaces
Message-Id: <374E94EE.C07B6A0E@physik.uni-giessen.de>
Marc Dietrich wrote:
>
> Hello to all,
>
> I thought perl is a relativ secure language...
> I depend on the namespaces because I'm using the CGI module which
> imports variables in its own namespace. Importing a new dataset requires
> deleting the old one.
> I'm going to use the hint of Anno (thanks to you) for now. Perhaps some
> developers should take a look at this problem in future versions of
> perl.
>
> greetings
>
> Marc
Ok. I did't meant secure. That was a bad translation. I thought one
advantage of perl is, that the programmer mustn't think of pointers,
adresses or references. It just does what I meen (and undef %Q:: should
be understandable).
Back to the script of Anno: This works well unter Linux (perl 5.00503,
same output as in the example). It does nothing with %Q:: under AIX
(perl 5.00404, same output in the "before" and "after" line) :(. Same
with delete insted of undef.
The hint using the OO-Interface is good, but because I'm short of time
that's not practical.
Perhaps someone has an other idea
thanks
Marc
------------------------------
Date: Fri, 28 May 1999 14:27:02 +0100
From: "Dave Evans" <devans@radius-retail.kom>
Subject: Re: use File::Copy; my $my_dir = "C:/";chdir($my_dir) || die "Can't change directory! $!"; From Unix I want to read DOS directory
Message-Id: <374e95f5.0@nntp.mmi.org>
Sorry that question didn't make a whole lot of sense to me. Nor anybody
else, judging by the lack of posted responses.
What exactly are you trying to do?
Boris Bakulin wrote in message <2.07b3.QEEH.FCFG7E@eximb.kiev.ua>...
>I read FAQ but didn't find answer
>
>If anybody can help ,please
>
>Boris
>
>
------------------------------
Date: 28 May 1999 05:50:15 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: workarounds for prototypes
Message-Id: <374e82f7@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Gareth Rees <garethr@cre.canon.co.uk> writes:
:I'm intrigued as to what you mean by this. Do you mean that
:Class::Multimethods is a poor implementation of generic functions
:(lacking as it does any equivalents of the CLOS features
:define-method-combination, :around, :most-specific-last or
:call-next-method) or do you mean that generic functions cause more
:problems than they solve? I'd be interested to see your thoughts on
:this issue.
I "mean" nothing, but my doubts tend toward the latter alternative.
In brief, complexity scares me.
--tom
--
I'm not writing any more tapes, ever. --Andrew Hume
------------------------------
Date: 28 May 1999 12:11:09 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Y2K infected Perl code
Message-Id: <slrn7kt1us.1d8.M.Ray@carlova.ulcc.ac.uk>
On Fri, 28 May 1999 01:12:09 GMT, finsol@ts.co.nz <finsol@ts.co.nz> wrote:
>You may have missed my posting today where I gave examples of Y2K broken
>code, so I have included them below. These examples are in Perl but
>similar examples can be found in Java and several other languages
>frequently used for CGI programming. 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!
>
>http://www.hollycole.com/WWWboard/wwwboard.html
> # get information
> local($string) = @_;
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
>localtime(time);
> # calculate useful values
> $cent = ($year < 70) ? 20 : 19;
> $lyear = $year + $cent*100;
>
>http://www2s.biglobe.ne.jp/~j_okada/free_cgi/j_diary/regist.txt
>if ($year > 97) { $year = "19$year"; }
> else { $year = "20$year"; }
> if (!open (DB, "$data_dir/$year$mon\.dat")) {
>
>http://www.linguistic-funland.com/scripts/RemindMe/remindmecgi.txt
>if($data{'Year'} eq "Not Selected"){
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
> if($year !~ /0/){
> $form_year = "19$year";
> }
> else{$year = "20$year";}
>
>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'.
>
>Try it sometime for a close view of programming in the real world. Try
>it with 'getyear' as well for some Java and Javascript examples. Try it
>with '19' and notice how many of these web pages have been created this
>year. These programmers are still hard-coding 19 for the century in
>1999!
I'm willing to bet that those programmers also fail to check the
return value of opens. It's also quite likely that their code
is non-portable. I'm willing to bet that those two examples above
which contain $yday and $isdst never use those variables, and they're
only there because the programmers cut-and-pasted the localtime call
without thinking. Ditto the superfluous arguments to localtime.
There are lousy programmers around - film at 11.
Programming should not be done by guesswork. Let's imagine that
perl never had localtime in its current form. Instead, it had a
function called current_time. Same semantics, except that the year
is returned in the way you'd seem to prefer. So I copy a call to
it into my program, without reading the documentation:
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = current_time;
print "Date is $mday/$mon/$year\n";
Hang on, why does it say the current month number is 8, when it
should obviously be 9? Amazingly, some programmers fail to spot this,
and some who do turn up on clpm asking whether it's a bug, so let's
modify current_time further to return a 1-based month number. Now,
what's $isdst? The name suggests that it's related to daylight saving
time, and, sure enough, I get the value 1, and DST is currently active.
Must be 'hours after GMT', I suppose, so let's do this:
my $rfc822_timezone = 'GMT +0' . $isdst . '00';
Works for me. Would it work in a different timezone? Would you know?
Under what circumstances would it fail? What if I want the time in GMT?
I'm not going to read the docs and find a suitable function, of course,
so I guess I'd have to do this:
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = current_time;
$hour -= $isdst;
Would that be ok? Always?
A lot of lousy code will fail in about six months' time. A lot of lousy
code will fail gracelessly at some indeterminate time in the future when
a file it needs isn't there or has the wrong permissions. A lot of
lousy CGI code will fall in a heap if a form variable it was expecting
is missing or contains shell metacharacters. A lot of lousy code will
fail miserably if run on a different platform, or under a differently-
configured web server. None of these are the fault of the language.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Fri, 28 May 1999 10:39:06 -0400
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Y2K infected Perl code
Message-Id: <374EAA88.3B25DB3@cthulhu.demon.nl>
Alcoholics claim they don't have a problem with alcohol.
So someone who claims not to have a problem with alcohol is an alcoholic.
Ofcourse, any reasonably intelligent person can sees the flaw in this logic.
Ignorant programmers claim they don't have problems with century bugs.
Programmers who claim they don't have problems with century bugs are ignorant.
Same reasoning ...
Besides, what's the problem with 1999->2000 transition anyway. I have power
failures every few weeks anyway, a small icestorm leaves people without power
for weeks, airports seem to shut down due to computer problems on a regular
basis. The first time I drive in a car all traffic lights shut down. A hospital
in DC had computer problems because the floppy drives were full (I think the
'floppy' part was a typo though ;)
Erik van Roode
------------------------------
Date: Fri, 28 May 1999 14:55:55 GMT
From: docdwarf@clark.net ()
Subject: Re: Y2K infected Perl code
Message-Id: <%7y33.102$K2.3731@iad-read.news.verio.net>
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'?
DD
------------------------------
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 5815
**************************************