[11801] in Perl-Users-Digest
Perl-Users Digest, Issue: 5401 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 16 16:07:26 1999
Date: Fri, 16 Apr 99 13:00:17 -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, 16 Apr 1999 Volume: 8 Number: 5401
Today's topics:
Re: Complex sort help needed. Please! Never Mind!! troutmask338@my-dejanews.com
Re: FAQ 9.3: How do I remove HTML from a string? <Allan@due.net>
Re: fork processes in batches <tchrist@mox.perl.com>
Re: fork processes in batches (Larry Rosler)
Re: FREE Certifications Offered Online to perl programm <uri@home.sysarch.com>
Re: FREE Certifications Offered Online to perl programm (David H. Adler)
How to open file across network <qsun@kitco.ca>
Image::Magick - append and more rueyin@my-dejanews.com
Re: interesting hash problem <Wm.Blasius@ks.sel.alcatel.de>
Re: Need info on Perl vs. VB for manager persuasion <tchrist@mox.perl.com>
Re: Need info on Perl vs. VB for manager persuasion <cassell@mail.cor.epa.gov>
New FAQ: How can I read in an entire file all at once? <tchrist@mox.perl.com>
Oracle and BSDi (Try Out)
Re-Escaping the $ENV{QUERY_STRING_UNESCAPED} variable <khowe@performance-net.com>
Signals handlers using POSIX <macintsh@cs.bu.edu>
Re: TZ not used in winnt Date/Time routines <gury@interaccess.com>
Re: Uploading script. <ozette.brown@infotechfl.com>
Re: Want to install printers with perl <cassell@mail.cor.epa.gov>
Re: Would anyone care to teach me perl? <cassell@mail.cor.epa.gov>
{ } question/problem (David Walford)
Re: { } question/problem <tchrist@mox.perl.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Apr 1999 18:07:42 GMT
From: troutmask338@my-dejanews.com
Subject: Re: Complex sort help needed. Please! Never Mind!!
Message-Id: <7f7u96$88e$1@nnrp1.dejanews.com>
I found a module from CPAN that does exactly what I wanted:
Sort::Fields
Thanks anyway!!!
-Les Brown
In article <7f7nkm$1l6$1@nnrp1.dejanews.com>,
troutmask338@my-dejanews.com wrote:
> Hello!
>
> I'm trying to sort lines in a text database based on multiple criteria and am
> having no luck.
>
> I have an unsorted textfile containing space-delimited fields for the name, IP
> address and score for a variety of web servers, like this:
>
> myServer 123.345.567.765 29
> yourServer 234.432.234.432 105
> hisServer 123.345.567.765 29
> herServer 234.432.234.432 105
> theirServer 111.222.111.222 13
> anotherServer 123.345.567.765 29
> yetAnotherServer 255.244.255.244 105
>
> As you can see, several servers share the same IP address and, therefore, have
> the same score.
>
> What I want to do is sort this list with highest scoring servers listed first
> and sorted by like IP addresses and then alphabetically by server name. The
> output for the above example would be:
>
> herServer 234.432.234.432 105
> yourServer 234.432.234.432 105
> yetAnotherServer 255.244.255.244 105
> anotherServer 123.345.567.765 29
> hisServer 123.345.567.765 29
> myServer 123.345.567.765 29
> theirServer 111.222.111.222 13
>
> so we have the highest-scoring servers at the top, sorted by IP address when
> the score is the same, then sorted alphabetically on the server name.
>
> I can sort on individual fields to produce, for instance, the list sorted
> based upon score only, but how do I incorporate several criteria to create a
> "sub-sort"? I've tried putting multiple sorts into the sort subroutine with
> the result that the last sort produces the final result. That is, if I sort
> first on score, then on IP address, then on name, I get a list sorted by name
> only.
>
> Any tips/help greatly appreciated!!!!!
>
> Thanks!
>
> -Les Brown
> lbrown2@uswest.net
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 15:13:39 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: FAQ 9.3: How do I remove HTML from a string?
Message-Id: <7f825g$ubo$1@camel19.mindspring.com>
Tom Christiansen wrote in message <37177f08@cs.colorado.edu>...
:(This excerpt from perlfaq9 - Networking
: ($Revision: 1.25 $, $Date: 1999/04/14 03:46:19 $)
:part of the standard set of documentation included with every
:valid Perl distribution, like the one on your system.
:See also http://language.perl.com/newdocs/pod/perlfaq9.html
:if your negligent system adminstrator has been remiss in his duties.)
:
: How do I remove HTML from a string?
:
: The most correct way (albeit not the fastest) is to use HTML::Parse
: from CPAN (part of the HTML-Tree package on CPAN).
I thought the use of HTML::Parse has become deprecated in favor of Parser?
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
An old pond-
The sound of the water
When the frog jumps in
- Basho
------------------------------
Date: 16 Apr 1999 12:09:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: fork processes in batches
Message-Id: <37177cd8@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
senthilr@email.com writes:
:Hi:
:
:I am writing a job dispatching program. The goal is to keep
:n number of jobs running all the time. Right now I fork n jobs
:and wait for those n jobs to complete, then I fork another n jobs.
:
:The thing is sometimes a few jobs finish early and cpu time is wasted
:in waiting for the rest of the jobs to finish before I can submit the
:next batch. What I would like to do is, say n = 10, the dispatcher should
:dispatch 10 jobs, if 1 job finishes, the dispatcher should submit one more
:to keep the number of running jobs 10.
:
:What would be the best approach to do this.
A very simple matter of rather basic systems programming, something all
undergraduates seem to do as their first assignment in operating systems.
Here's a trivial little version I whipped up in about ten minutes.
Your bill's in the mail. :-)
--tom
#!/usr/bin/perl -w
# sched demo
# tchrist@perl.com
use strict;
$| = 1; # fork can really make for stdio surprises
my $TOTAL = 100;
my $CONCUR_MAX = 10;
my $FORK_RETRIES = 5;
my $RETRY_SLEEP = 5;
my $DAWDLE = 10; # kid spins jets for 1+rand this
my %Launched = ();
run_queue();
exit;
##################
sub run_queue {
my $started = 0;
my $done = 0;
my $running = 0;
JOB:
while ($TOTAL > ($done+$running) || $running > 0) {
# sort by date in case pids wrap
print "Run queue: ", join(" ",
sort { $Launched{$a} <=> $Launched{$b} } keys %Launched),
"\n";
if ($running >= $CONCUR_MAX || $started >= $TOTAL) {
print "$$: waiting R=$running, S=$started D=$done\n";
my $child = wait;
die "REAPED WRONG CHILD: $child ($?)" unless $Launched{$child};
my $runtime = time() - $Launched{$child};
delete $Launched{$child};
print "Child $child has completed, after $runtime seconds\n";
print "Child $child exited " . ($? << 8) . "\n" if $?;
$done++;
--$running;
next JOB;
}
next if ($done+$running) >= $TOTAL;
my $tries = 0;
my $kid;
RETRY: {
$kid = fork();
unless (defined $kid) {
warn "$0 $$: cannot fork: $!";
if ($tries++ < $FORK_RETRIES) {
warn "$0 $$: sleep and retry\n";
sleep 5;
redo RETRY;
}
}
}
if ($kid) {
$running++;
$started++;
$Launched{ $kid } = time();
}
else {
run_job();
exit;
# NOT REACHED
}
}
}
sub run_job {
print "$$ is napping\n";
sleep(1 + int(rand($DAWDLE)));
print "$$ had a nice nap.\n";
}
--
"I find this a nice feature but it is not according to the documentation.
Or is it a BUG?"
"Let's call it an accidental feature. :-)" Larry Wall in <6909@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Fri, 16 Apr 1999 12:55:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: fork processes in batches
Message-Id: <MPG.11813573d2705e509898ca@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37177cd8@cs.colorado.edu> on 16 Apr 1999 12:09:28 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
...
> Here's a trivial little version I whipped up in about ten minutes.
...
> print "Child $child exited " . ($? << 8) . "\n" if $?;
print "Child $child exited " . ($? >> 8) . "\n" if $?;
?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Apr 1999 14:16:02 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <x790bsmnx9.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <3717629e@newsread3.dircon.co.uk> on 16 Apr 1999 17:17:34
LR> +0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
>> Leo Schalkwyk <schalkwy@minnie.RZ-Berlin.MPG.DE> wrote:
>> > Uri Guttman (uri@home.sysarch.com) wrote:
>> > : >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
>> >
>> > : l> To qualify as a Certified perl Programmer, you must pass the
>> > : l> examination with a score of 2.75 or higher. To be certified as a
>> > : l> Master perl Programmer, you must obtain a score of 4.00 or higher.
>> >
>> > : this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
>> > : i am certified as a master perl hacker. hell i BOUGHT for $3 a
>> >
>> > Well I know at most a tenth as much as Uri and I got 4.17
>>
>> I cheated like hell and got 4.53 ...
LR> I didn't "cheat" at all (I didn't think it was an 'open-book' exam), and
LR> got over 4. That included guessing at things I know nothing about (tk)
LR> or little about (OOP).
it says it is open book. any resource you would have around normally are
fine. so it came down to how fast i could look up some obscure thing
(like the tk question) in some index. also if it is open book, is it
open computer? many (including me) ran code under perl to see what would
happen. i would use perl under normal circumstances to write perl!
LR> In regard to the $3 certificate that Uri mentioned, mine (bought at the
LR> same time as his) reads "Certifiable Perl Pornographer". I'll stand by
LR> that!
i'll certify that is what you are!
and mine says "certified perl quiz hacker". i need to frame and hang
it.
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: 16 Apr 1999 14:24:58 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <slrn7hf03p.b17.dha@panix.com>
On Fri, 16 Apr 1999 10:36:45 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>In regard to the $3 certificate that Uri mentioned, mine (bought at the
>same time as his) reads "Certifiable Perl Pornographer". I'll stand by
>that!
*I'm* a Certified Perl Druid! :-)
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I drink to my coming cirrhosis... - Charles Aznavour
------------------------------
Date: Fri, 16 Apr 1999 15:14:33 -0400
From: qinqiang sun <qsun@kitco.ca>
Subject: How to open file across network
Message-Id: <37178C19.754F24BE@kitco.ca>
Hi, everyone,
I tried to open file on another machine by specifying the driver map
letter and failed. Could you please help me on this? Thank you.
I also failed to open MS access database on another machine even though
local database has no problem.
Please give me some clues.
qinqiang
------------------------------
Date: Fri, 16 Apr 1999 19:09:58 GMT
From: rueyin@my-dejanews.com
Subject: Image::Magick - append and more
Message-Id: <7f81tv$bna$1@nnrp1.dejanews.com>
Two questions.
1. I have two gif files, say, 1.gif and 2.gif, which are all
in the same width. How can I append 2.gif to 1.gif using the "append"
function in the Image::Magick module?
2. I need to replace all the blue
gradients (eg. (50, 50, 255), (30, 30, 255) etc) in a gif file with the
blue (0, 0, 255) color. How can I do that?
Thanks for any help.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 20:06:01 +0200
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
Subject: Re: interesting hash problem
Message-Id: <37177C09.167EB0E7@ks.sel.alcatel.de>
[ a copy of this posting was sent to Mike Soulier at nt.com ]
Soulier, Michael (EXCHANGE:SKY:1Z22) wrote:
>
> Hey guys. I'm having an interesting confusion about hashes (well, it's
> interesting to me anyway). I was under the impression that I could add
> levels to a hash dynamically, all I wanted. For example, if I had:
>
> my %myHash = ();
>
> I could say
>
> $myHash{'key1'} = 1;
>
> Then, I could later say
>
> $myHash{'key1'}{'key2} = 1;
>
> And continue all I wanted. I've been doing this for a while and never
> run into a problem, until now. Here's a code snippet:
That's hard to believe. "$myHash{'key1'} = 1" makes the value of the
hash data for key1 a scalar. "$myHash{'key1'}{'key2} = 1" would make
the hash data for key1 become an anonymous hash but I wouldn't think
perl is quite that creative. On my system:
$myHash{'key1'}{'key2} = 1;
$myHash{'key1'} = 1;
x %myHash
0 'key1'
1 1
which seems pretty normal...
$myHash{'key1'}{'key2'} = 1;
x %myHash
0 'key1'
1 1
which looks like nothing was assigned. Even being explicit...
${$myHash{'key1'}}{'key2'} = 1;
x %myHash
0 'key1'
1 1
doesn't help much, but...
$myHash{'key1'} = { 'key2' => 1 } # explicit array construction
x %myHash
0 'key1'
1 HASH(0x233910)
'key2' => 1
which is what I think you expected.
If you check the changes to your code, that is exactly what you did.
hth
Wm Blasius
Stuttgart
--
...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my mail
server says!
------------------------------
Date: 16 Apr 1999 12:01:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Need info on Perl vs. VB for manager persuasion
Message-Id: <37177aea@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
kdphillips@my-dejanews.com writes:
:This is where the trade journals work against me. She can easily see all the
:ads / articles /editorials for and about VB; aren't too many about Perl...
That's not so -- I read a lot of them. She just reads MS-sponsored stuff.
--tom
--
There's some side effect based on the fact that SIGCHLD isn't sent by
anyone, but is fabricated by the kernel when a child dies. It's a huge
kludge. But then, it _is_ SysV. --Chip Salzenberg, aka <chs@nando.net>
------------------------------
Date: Fri, 16 Apr 1999 12:10:15 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need info on Perl vs. VB for manager persuasion
Message-Id: <37178B17.E8747552@mail.cor.epa.gov>
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> kdphillips@my-dejanews.com writes:
> :This is where the trade journals work against me. She can easily see all the
> :ads / articles /editorials for and about VB; aren't too many about Perl...
>
> That's not so -- I read a lot of them. She just reads MS-sponsored stuff.
You can get a subscription to The Perl Journal, and get plenty of good
Perl stuff to show aorund.. not to mention helpful code and neat info.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 16 Apr 1999 12:39:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: New FAQ: How can I read in an entire file all at once?
Message-Id: <371783f9@cs.colorado.edu>
=head2 How can I read in an entire file all at once?
The customary Perl approach for processing all the lines in a file is to
do so one line at a time:
open (INPUT, $file) || die "can't open $file: $!";
while (<INPUT>) {
chomp;
# do something with $_
}
close(INPUT) || die "can't close $file: $!";
This is tremendously more efficient than reading the entire file into
memory as an array of lines and then processing it one element at a time,
which is often -- if not almost always -- the wrong approach. You might
find it more fun to use the the standard DB_File module's $DB_RECNO
bindings, which allow you to tie an arrya to a file so that accessing
an element the array actually accesses the corresponding line in the file.
On very rare occasion, you may have an algorithm that demands that
the entire file be in memory at once as one scalar. The simplest solution
to that is:
$var = `cat $file`;
Being in scalar context, you get the whole thing. This tiny but expedient
solution is neat, clean, and portable to all systems that you've bothered
to install decent tools on, even if you are a Prisoner of Bill.
For those die-hards PoBs who've paid their billtax and refuse to use
the toolbox, or who like writing complicated code for job security,
you can of course read the file manually.
$var = {
local(*INPUT, $/);
open (INPUT, $file) || die "can't open $file: $!";
<INPUT>;
};
That temporarily unders your record separator, and will automatically
close the file at block exit. If the file is already open, just use this:
$var = do { local $/; <INPUT> };
--
X-Windows: No hardware is safe.
--Jamie Zawinski
------------------------------
Date: Fri, 16 Apr 1999 19:42:07 GMT
From: dmelnik@optonline.net (Try Out)
Subject: Oracle and BSDi
Message-Id: <371791f6.14266504@news.optonline.net>
Has anyone use DBD and DBi from BSDi to Oracle running on Solaris? I
need to connect to an Oracle database running on Solaris from a Web
server running BSDi, any suggestions?
Thanks!
Dave Melnik
dave63@earthling.net
------------------------------
Date: Fri, 16 Apr 1999 16:06:49 -0300
From: "Kevin Howe" <khowe@performance-net.com>
Subject: Re-Escaping the $ENV{QUERY_STRING_UNESCAPED} variable
Message-Id: <8SLR2.23411$134.244510@tor-nn1.netcom.ca>
Hi, I am using both the $QUERY_STRING and $QUERY_STRING_UNESCAPED variables
in my script. How you ask?
I have URL with a query string. Ex: http://.....File.shtml?A=B
Inside this file (File.shtml) there is an SSI call, also with a query
string.
Ex: <!--#INCLUDE virtual = "mycgi.cgi?C=D"-->
This makes the $ENV{$QUER_STRING} equal C=D
and makes the $ENV{$QUER_STRING_UNESCAPED} equal A=B
My problem is that the UNESCAPED variable has been unescaped, and in order
to turn it into a regular string I need to "re-escape" it.
Does anyone know how this is done?
Much Appreciated,
Kevin
------------------------------
Date: 16 Apr 1999 19:35:51 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: Signals handlers using POSIX
Message-Id: <7f83en$iht$1@news1.bu.edu>
As I explained in another thread, Perl's conventional signal handler
mechanisms don't appear to work on my perl installation. In desperation,
I tried using the POSIX module. Since the documentation basically just
refers me to the C man pages, I'm a bit lost. Below is my attempt at
getting this stuff to work. Any help is appreciated.
Notes on the script: I just want to handle suspend (usually invoked via
control-Z) and resume. That is, I want to intercept SIGTSTP, explicitly
perform the default behavior (i.e. suspend the processs), and then do
some stuff when the script resumes (in this example, just print a newline
so the prompt is on its own line).
So far, I haven't even been able to get the handler() function to
intercept the signal and execute :-/ Obviously I'm missing something.
It's times like these that I wish I'd just plunked down the cash for the
Stevens book...
And yes,this is just a dummy test script, so no scolding about -w and
strict ;-)
---
#!/usr/local/bin/perl
use POSIX qw(signal_h);
sub handler { die 'suspended' }
$action = new POSIX::SigAction;
$default = new POSIX::SigAction;
sigaction(SIGTSTP, $action, $default);
sigaction(SIGTSTP, $default);
# Is the only diff between intercept and default the handler attribute?
$action->{'HANDLER'} = \&handler;
for(;;)
{
eval
{
sigaction(SIGTSTP, $action);
print "> ";
$res = <STDIN>;
sigaction(SIGTSTP, $default);
};
if($@ =~ /^suspended/)
{
sigaction(SIGTSTP, $default);
raise(SIGTSTP); # I'd wonder if I should use kill() instead...
# ...if my script ever got here, that is :-/
print "\n";
redo;
}
elsif($@) { die "Eval error: $@" }
exit if($res =~ /^q/i);
}
---
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: Fri, 16 Apr 1999 13:12:41 -0500
From: "john gury" <gury@interaccess.com>
Subject: Re: TZ not used in winnt Date/Time routines
Message-Id: <924286371.068.88@news.remarQ.com>
The best fix I found is to do a Date_Init("TZ=XXX")
with txs to Sullivan Beck....
Larry Rosler wrote in message ...
>In article <371769EB.EDE2E4E8@mail.cor.epa.gov> on Fri, 16 Apr 1999
>09:48:43 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
>> Jonathan Stowe wrote:
>> > john gury <gury@interaccess.com> wrote:
>> > > Does anyone know how to get the TZ var to work under winnt perl?
>> > > I'm showing that regardless of TZ settings the timezone used is the
>> > > unadjusted windows system timezone. Is this another "use a real
>> > > OS to get it to work" issue?
>> >
>> > I seem to recall it depends with whose C libraries the Perl was built.
>> > Anyhow it shouldnt matter the NT settings should work properly. But I
>> > would advocate switching OS just for the hell of it.
>>
>> The easiest kludge on win32 is stuffing the value of TZ into %ENV
>> yourself. But that's still a kludge, and has to be done for each such
>> program.
>
>That seems to depend on the version of perl, as Jonathan said. The
>ActiveState perl that most of us are now using takes no notice of
>$ENV{TZ} for localtime. But the MKS ToolKit versions of perl 5.002 and
>5.003 do respect it.
>
>I remember a long time ago finding code in the source for ctime etc. in
>the M$ Visual C++ 5.0 library that looks for $ENV{TZ} before consulting
>the system clock. Evidently ActivePerl is bound with a different
>library.
>
>--
>(Just Another Larry) Rosler
>Hewlett-Packard Company
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com
------------------------------
Date: Fri, 16 Apr 1999 15:56:47 -0400
From: Ozette Brown <ozette.brown@infotechfl.com>
Subject: Re: Uploading script.
Message-Id: <371795FF.CF4D8CBA@infotechfl.com>
Yes,
Remember, CGI.pm is your friend. Start investing in the book, "Official Guide
to Programming with CGI.pm".
Thanks,
Ozette
Ours wrote:
> Hi All,
>
> I would like to have a script (write) that would upload an attachement to my
> server.
> Idea is to be able to browse my local drives and find the source-file and
> then press UPLOAD to upload to a remote server.
>
> Is this at all possible and can someone point me in the right direction/hand
> me the script?
>
> Thanks,
>
> MW
--
Ozette Brown <Ozette.Brown@Infotechfl.com>
Webmaster - Systems Analyst, Infotech Inc.
5700 S.W. 34th St. Suite 1235 Phone: 352-375-7624
Gainesville, FL 32608-5371 Fax: 352-373-9586
------------------------------
Date: Fri, 16 Apr 1999 12:07:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Want to install printers with perl
Message-Id: <37178A88.2F3E7FD0@mail.cor.epa.gov>
NCTECH wrote:
>
> I'm a system administrator.
> I have a lot of script to automate administration task.
> I would like to create a script to install a printer on a NT server
> and to share it.
> How to do ?
Have you looked in the O'Reilly octopus [NT Administration using Perl]
book?
Just a thought,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Fri, 16 Apr 1999 12:22:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Would anyone care to teach me perl?
Message-Id: <37178DEB.BCBEF3D@mail.cor.epa.gov>
KC wrote:
>
> Ala Qumsieh wrote:
> > Why? Don't you know how to read books? It's very simple. In English,
> > words go from left to write, but you knew that already.
> > Pages can be flipped. A book is made up of one or more pages. Words in
> > books look almost exactly like words in email messages. They can be
> > read too.
>
> Book?? You mean a non-volitale storage media ;-)
I have a 4-year-old who likes animal pictures. My O'Reilly books
therefore constitute a *very* volatile storage medium. :-)
David, who is eyeing your spelling but is not going there today...
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 16 Apr 1999 18:35:40 GMT
From: davewal@echo.corp.sgi.com (David Walford)
Subject: { } question/problem
Message-Id: <7f7vts$fg8$1@murrow.corp.sgi.com>
How do I call up an array that has a name which is built with a variable?
something like
(sort keys %${appliedEngin_tag}_array)
what do I put between the "%$" or prevent bare word/scalar errors or what is the
proper way of representing this?
I tried:
(sort keys %{${appliedEngin_tag}_array})
Thanks
David
--
--------------------------------------------------------------
David M. Walford | email: davewal@corp.sgi.com
------------------------------
Date: 16 Apr 1999 12:42:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: { } question/problem
Message-Id: <3717848d@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, davewal@echo.corp.sgi.com (David Walford) writes:
:How do I call up an array that has a name which is built with a variable?
You don't. Stop using the package symbol table as an ersatz hash.
Use your own.
--tom
=head2 How can I use a variable as a variable name?
Beginners often think they want to have a variable contain the name
of a variable.
$fred = 23;
$varname = "fred";
++$$varname; # $fred now 24
This works I<sometimes>, but it is a very bad idea for two reasons.
The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether. Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.
Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.
The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes. By using
symbolic references, you are just using the package's symbol-table hash
(like C<%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++
There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables. This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one. Instead of
reading a string and expanding it to the actual contents of your program's
own variables:
$str = 'this has a $fred and $barney in it';
$str =~ s/(\$\w+)/$1/eeg; # need double eval
Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:
$str =~ s/\$(\w+)/$USER_VARS{$1}/g; # no /e here at all
That's faster, cleaner, and safer than the previous approach. Of course,
you don't need to use a dollar sign. You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.
$str = 'this has a %fred% and %barney% in it';
$str =~ s/%(\w+)%/$USER_VARS{$1}/g; # no /e here at all
Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes. For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.
$name = "fred";
$$name{WIFE} = "wilma"; # set %fred
$name = "barney";
$$name{WIFE} = "betty"; # set %barney
This is still a symbolic reference, and is still saddled with the
problems enumerated above. It would be far better to write:
$folks{"fred"}{WIFE} = "wilma";
$folks{"barney"}{WIFE} = "betty";
And just use a multilevel hash to start with.
The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table. This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.
In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table. For example:
@colors = qw(red blue green yellow orange purple violet);
for my $name (@colors) {
no strict 'refs'; # renege for the block
*$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
}
All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.
So, sometimes you might want to use symbolic references to directly
manipulate the symbol table. This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
--
Q. Why is this so clumsy?
A. The trick is to use Perl's strengths rather than its weaknesses.
--Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>
------------------------------
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 5401
**************************************