[17782] in Perl-Users-Digest
Perl-Users Digest, Issue: 5202 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 26 21:05:42 2000
Date: Tue, 26 Dec 2000 18:05:13 -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: <977882713-v9-i5202@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 26 Dec 2000 Volume: 9 Number: 5202
Today's topics:
A question for the Sys Admins out there: <lmoran@wtsg.com>
Re: A question for the Sys Admins out there: <bh_ent@my-deja.com>
Re: A question for the Sys Admins out there: (Abigail)
Re: A question for the Sys Admins out there: <carvdawg@patriot.net>
Re: Any good Perl books? (Tim Hammerquist)
Re: converting code to mod perl (should I use globals?) <joe+usenet@sunstarsys.com>
Re: converting code to mod perl (should I use globals?) (Tim Hammerquist)
Re: count number of occurrences in string (Andrew N. McGuire)
Re: creating a "TCP WAIT" process under inetd aradia@aracnet.com
declaring variables <johnm@acadiacom.net>
Re: Error from MIME::Lite (Abigail)
Re: FAQ 6.21: What's wrong with using grep or map in <johnlin@chttl.com.tw>
Help with searching flat files & CGI wendywds@my-deja.com
Re: Help: modulus problem, docs confusing richardstands@my-deja.com
Re: heredoc within heredoc (Abigail)
Re: heredoc within heredoc <joe+usenet@sunstarsys.com>
Re: heredoc within heredoc (Abigail)
Re: Is there a standard, current Perl for Win32 (withou (Mark W. Schumann)
Re: Net::DNS and NT Permissions (Should be IO::Socket a mrfreeze_2000@my-deja.com
Re: No embeding please! (Tim Hammerquist)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Dec 2000 15:15:59 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: A question for the Sys Admins out there:
Message-Id: <h8th4t00o1rrai52s2664ofkf3jqcigrh5@4ax.com>
--Is anyone running an NT domain with Linux and Perl?
---I run a small 8 server NW and my admin machine is a partitioned
laptop. 5 gigs to WIN2K and 5 gigs to RH 6.2.
---I have a RH 6.2 box on my desk as well. Everything else is NT or
W2K.
--Aside from the occasional Notes crap I need to do I don't use the
W2K side much. (Although I am using it now b/c I like Agent.) I'd
like to just work on the Linux side. I have found Perl very useful to
this end. By using scripts I have found and writing my own I am able
to do a lot of what needs to be done, but I eventually end up having
to boot to W2K to do something (or Heaven Forbid, sometimes I have to
walk to the server room... I hate that it's really cold in there)
--So I was wondering as I peruse Perl for System Administration; is
anyone is running the whole show with Linux and Perl? I realize the
best tool for the job and such but I was just wondering what other Sys
Admins are doing out there. All of my tech friends are programmers
and they are not helpful for this question. (Half of them say rude
things about Perl anyway. "Oh Lou, you should use Eiffel to do that."
I had enough trouble learning Perl.)
--Thanks
lmoran@wtsgSPAM.com
print "\x{263a}"
------------------------------
Date: Tue, 26 Dec 2000 20:40:07 GMT
From: Drew Myers <bh_ent@my-deja.com>
Subject: Re: A question for the Sys Admins out there:
Message-Id: <92avn6$tip$1@nnrp1.deja.com>
In article <h8th4t00o1rrai52s2664ofkf3jqcigrh5@4ax.com>,
Lou Moran <lmoran@wtsg.com> wrote:
[ snip ]
> is anyone is running the whole show with Linux and Perl?
You may want to take a look at VMware. You can boot into your Linux
parition, and launch the NT piece as an app on an as-needed basis. Or
vice versa. I don't use it myself due to the license cost, but I think
it would allow you to do what you want. www.vmware.com
HTH,
Drew Myers
perotsystems
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 26 Dec 2000 23:27:01 GMT
From: abigail@foad.org (Abigail)
Subject: Re: A question for the Sys Admins out there:
Message-Id: <slrn94iaa5.mi8.abigail@tsathoggua.rlyeh.net>
Lou Moran (lmoran@wtsg.com) wrote on MMDCLXXIV September MCMXCIII in
<URL:news:h8th4t00o1rrai52s2664ofkf3jqcigrh5@4ax.com>:
@@ --Is anyone running an NT domain with Linux and Perl?
@@
@@ ---I run a small 8 server NW and my admin machine is a partitioned
@@ laptop. 5 gigs to WIN2K and 5 gigs to RH 6.2.
@@
@@ ---I have a RH 6.2 box on my desk as well. Everything else is NT or
@@ W2K.
@@
@@ --Aside from the occasional Notes crap I need to do I don't use the
@@ W2K side much. (Although I am using it now b/c I like Agent.) I'd
@@ like to just work on the Linux side. I have found Perl very useful to
@@ this end. By using scripts I have found and writing my own I am able
@@ to do a lot of what needs to be done, but I eventually end up having
@@ to boot to W2K to do something (or Heaven Forbid, sometimes I have to
@@ walk to the server room... I hate that it's really cold in there)
@@
@@ --So I was wondering as I peruse Perl for System Administration; is
@@ anyone is running the whole show with Linux and Perl? I realize the
@@ best tool for the job and such but I was just wondering what other Sys
@@ Admins are doing out there. All of my tech friends are programmers
@@ and they are not helpful for this question. (Half of them say rude
@@ things about Perl anyway. "Oh Lou, you should use Eiffel to do that."
@@ I had enough trouble learning Perl.)
Which language you use for your job is not very important. What's
important is that your tools are good, and that you do your job. If Perl
works for your, that's good. But if noone else at your work knows Perl,
writing tools in Perl might not be a good idea - you'll end up maintaining
everything, and you will have lots of trouble getting time off, or making
promotion, as you're the only one knowing the stuff.
A good sysadmin has more trick upon his/her sleeve than just Perl. (S)he's
equally cunning with C, sh, awk and two or three other languages. Because
next week you'll find a neat package that uses some other scripting language
for configuration.
But what are you adminning? You say you hardly use windows, but the only
2 Unix machines are on your desk.
Abigail
--
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'
------------------------------
Date: Tue, 26 Dec 2000 20:48:52 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: A question for the Sys Admins out there:
Message-Id: <3A494A84.F69B2296@patriot.net>
> --Is anyone running an NT domain with Linux and Perl?
VMWare is good...as is VNC from AT&T Research. It doesn't give you the
same
capabilities as VMWare, but it's free.
Re: Perl. None of the really useful modules (Win32::*, particularly
Lanman, Perms,
AdminMisc, EventLog, etc) run on Linux. So it really depends what you
want to use
Perl for...
> --By using scripts I have found and writing my own I am able
> to do a lot of what needs to be done, but I eventually end up having
> to boot to W2K to do something (or Heaven Forbid, sometimes I have to
> walk to the server room... I hate that it's really cold in there)
Many of the available Perl modules for Win32 can save you travel time,
as well as keep your sweater budget low!
> --So I was wondering as I peruse Perl for System Administration; is
> anyone is running the whole show with Linux and Perl?
I can see using Net::Telnet a lot to telnet into a Win2K terminal server
and
have the script execute commands on the server. However, a limitation is
reached as soon as the available command-line tools are insufficient, or
just
don't exist. Using either VMWare or VNC, I can see you booting only to
Linux, and even creating Win32-specific scripts on the NT/2K platform.
------------------------------
Date: Wed, 27 Dec 2000 02:01:56 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Any good Perl books?
Message-Id: <slrn94ijgu.9cd.tim@degree.ath.cx>
Abigail <abigail@foad.org> wrote:
> TommyAu@497179 (perl@dotexpress.com) wrote:
> [] go to see see :
> [] http://perl.oreilly.com
>
> Which will show a lot of bad and average books, and misses out most
> of the better books on Perl.
Abigail doesn't like O'Reilly, and I'm not thrilled with much of what they
publish either. But I invite you to form your own opinion.
Also, 'Programming Perl' from O'Reilly is a good reference. At times it
(namely 2nd edition) seemed like merely a paraphrasing of the
perldocs...for those that like to buy dead trees. =)
O'Reilly's 'Advanced Perl Programming' also has some very good
information and solutions in it (this publication is one of Uri's pet
peaves), but it's NOT for the beginner. KNOW WHAT YOUR DOING AND KNOW
THE CONSEQUENCES!
'Object Oriented Perl' by Damian Conway is an excellent book. It brings
you up to speed and then takes quite a bit further. It is _not_ from
O'Reilly.
DO NOT, I implore you, get carried away and think that O'Reilly is the
"only" or the "best" Perl book publisher. It's not, and it's led to
some bitter regulars in this newsgroup. ;)
The same goes for considering ActiveState the ONLY or BEST Perl for
Win32 platforms. It's not.
HTH
--
-Tim Hammerquist <timmy@cpan.org>
My life has a superb cast but I can't figure out the plot.
-- Ashleigh Brilliant
------------------------------
Date: 26 Dec 2000 14:39:18 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: converting code to mod perl (should I use globals?)
Message-Id: <m3n1djas61.fsf@mumonkan.sunstarsys.com>
Alex Hart <news@#nospam#althepal.com> writes:
> I just want to say that after coding Perl for over a year now, I just
> learned the difference between a global and a lexical variable. At least
> I think I understand.
>
> I have some code that I want to convert to mod perl, but I would also
> like it to work outside of mod perl.
You could use Apache::PerlRun instead of Apache::Registry as your
PerlHandler- your scripts would run just as if they were in a CGI
environment (without the overhead of forking and loading a perl
interpreter).
Essentially, Apache::Registry wraps your script inside a
package path_to_script;
use Apache;
sub handler {
# your script here
}
1;
block and executes
path_to_script::handler(Apache->request);
each time your script's url is called. That causes real
problems with code using file-scoped lexicals like this
#!/usr/bin/perl -wT
use strict;
use CGI;
my $q = new CGI; # file-scoped lexical
sub try {
# $q not an argument
my $var = $q->param('hi');
}
...
since it'll look like this to Apache::Registry
sub handler {
use strict;
use CGI;
my $q = new CGI; # was file-scoped lexical
sub try {
# bad closure effect now
my $var = $q->param('hi');
}
...
}
> I use a whole bunch of lexical variables in the code that
> are used in several subroutines. This works fine outside
> of mod perl, but since mod perl puts my code inside another
> subroutine, I get closure in places that I don't want it.
Right- like described above. If you can't recode it easily (like
wrapping your file-scoped lexicals inside a hash and passing around
a hashref), try using Apache::PerlRun instead. Better, you could
"get with the program" and rewrite your script as a mod_perl handler.
This shouldn't be too hard since you already know what's going on
with Apache::Registry.
> To fix this I figure I need to either use global variable,
That's not a fix- it'll most likely be worse than before.
> or pass all the variables to all of the functions. Passing all the variables
> seems like a lot of work, and too easy to make a mistake with.
Time to write your own handler, then :)
> There are about 30 variables that are shared by the subroutines.
IMHO, this was a design error. Coding this way prevents your
subroutines from being cut-and-paste reusable, so it's false laziness.
( It also keeps Apache::Registry from working right, but you already
knew that :)
> Can someone tell me if I am making a mistake using so many globals?
Yes, if you're using them just to be (falsely) lazy. No, if you're
using globals *because* they are global and you are making the
variables available for other packages (and possibly later Apache
requests) to use.
> I realize that lexical variables are a little faster, but I don't
> expect to overlap namespace with anyone.
It's difficult to place them in the proper namespace using
Apache::Registry unless you know how it creates package names
from url's. It's also *dangerous* unless you understand exactly
how persistence works in a mod_perl environment. Having variables
"destroyed" after leaving an enclosing block is usually desirable-
so if you decide to go the global route, be sure you make good use
of "local".
> Are there other considerations I should think about??
>
> I can't believe there's not a switch so that nested subroutines can
> share lexical variables. That would make life so much easier for people
> switching to mod perl. Is this a silly idea?
See
http://perl.apache.org/guide/porting.html
for a load of important and useful ideas.
HTH
--
Joe Schaefer
------------------------------
Date: Wed, 27 Dec 2000 01:52:33 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: converting code to mod perl (should I use globals?)
Message-Id: <slrn94iiva.9cd.tim@degree.ath.cx>
Alex Hart <news@#nospam#althepal.com> wrote:
> I have some code that I want to convert to mod perl, but I would also
> like it to work outside of mod perl.
> I use a whole bunch of lexical variables in the code that are used in
> several subroutines. This works fine outside of mod perl, but since mod
> perl puts my code inside another subroutine, I get closure in places
> that I don't want it.
You get closure? Are you sure it's "closure" you mean, or scope?
> To fix this I figure I need to either use global variable, or pass all
> the variables to all of the functions. Passing all the variables seems
> like a lot of work, and too easy to make a mistake with. There are about
> 30 variables that are shared by the subroutines.
By the time there are numerous functions and so many variables, I've
usually decided to use either an object structure, or a simple hash ref.
But keep in mind that:
: $global_var;
: my($lex_1, $lex_2, $lex_3);
:
: sub func1 { }
: sub func2 { }
: sub func3 { }
Only $global_var is global here. $lex_x are all lexical variables
with script scope and each $lex_x variable is visible in every sub.
In answer to your question, passing lots of variable is bad. Procedure
calls have always been one of the most expensive operations as far as
CPU time. For each call, each argument must be pushed on the stack
prior to calling, as well as numerous other preparations.
> Can someone tell me if I am making a mistake using so many globals? I
> realize that lexical variables are a little faster, but I don't expect
> to overlap namespace with anyone. Are there other considerations I
> should think about??
Uh oh. Another victim to the misconception that lexicals are faster than
globals. This was a thread a few months ago in which benchmarks showed
that globals were in fact slighter, but by no means significantly
faster than lexicals. ( local() is often the culprit; it's the slowest
of the three types of variables mentioned here)
> I can't believe there's not a switch so that nested subroutines can
> share lexical variables. That would make life so much easier for people
> switching to mod perl. Is this a silly idea?
I'm confused as to what you mean here. The following is valid:
: sub func1 {
: my $a = 7;
: # stuff
: sub func2 {
: $a++;
: }
: func2();
: }
And all of this code should compile under mod_perl. A simple 'use
strict' at the top of your script should clean up most potential
problems for mod_perl scripts. The majority of my CGIs will run
smoothly under mod_perl with no alteration. Don't think of mod_perl as
an obstacle; think of it as a pathway to freedom that simply asks you to
clarify yourself. =)
HTH
--
-Tim Hammerquist <timmy@cpan.org>
I don't have any solution, but I certainly admire the problem.
-- Ashleigh Brilliant
------------------------------
Date: 26 Dec 2000 14:14:46 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: count number of occurrences in string
Message-Id: <86wvcnlz2h.fsf@hawk.ce.mediaone.net>
>>>>> "LM" == Linc Madison <lincmad001@telecom-digest.zzn.com> writes:
LM> In article <1r4s0ed55p.fsf@video.bsd.uchicago.edu>, John Hunter
LM> <jdhunter@nitace.bsd.uchicago.edu> wrote:
>> >>>>> "Tad" == Tad McClellan <tadmc@metronet.com> writes:
>>
Tad> John Hunter <jdhunter@nitace.bsd.uchicago.edu> wrote:
>> >> What is the best way to count the number of times a specific
>> >> character occurs in a string.
>>
>>
Tad> $count = $addr =~ tr/@//;
>>
>> Perfect, thanks.
LM> Actually,
LM> $count = $addr =~ tr/@/@/;
LM> will achieve the same effect, but not alter the string.
Tad's method does not alter the string either...
[anm@eagle ~] cat tr.pl [0 pts/5]
#!/usr/bin/perl -wl
use strict;
my $str = "this is a test";
my $cnt = $str =~ tr/t//;
print $cnt;
print $str;
[anm@eagle ~] ./tr.pl [0 pts/5]
3
this is a test
[anm@eagle ~] [0 pts/5]
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Tue, 26 Dec 2000 18:07:53 GMT
From: aradia@aracnet.com
Subject: Re: creating a "TCP WAIT" process under inetd
Message-Id: <Z7526.288$LU6.127802@typhoon.aracnet.com>
In comp.lang.perl.moderated news.freed.com <news@freed.com> wrote:
I didn't *see* any followups to this, but my news server may just not have
them. So, apologies if someone already addressed this. =)
[snip]
> while (1) {
> my $sel = IO::Select->new();
> $sel->add(\*STDIN);
> $sel->can_read;
> while (<STDIN>) {
> # process a connection
> }
> }
[snip]
Why are you in a while(1){} loop?
> Each client will send multiple lines that need to be treated as a
> single unit; That's why I'm not just checking can_read() inside the
> inner loop; I have no way to tell that whether a line comes from the
> previous connection or a new one.
When you're running under inetd, you don't do any connection management
yourself, so your program only deals with a single connection, attached to
STDIN and STDOUT.
> I've been up many hours; if you find this message cryptic or
> incomplete, I apologize. And as always, thanks in advance for any
> light you might bring to bear on this problem.
I tend to just write IO::Socket servers, but this is an extremely basic
server that can be run under inetd:
#!/usr/bin/perl -w
use strict;
use IO::Handle;
autoflush STDOUT 1;
my $input = "";
until($input =~ /^exit/i)
{
$input = <STDIN>;
print "You typed: $input\n";
}
Depending on the format of those multiple lines, and what you're doing
with them, there are different ways of modifying the above to do whatever
it is that you're doing.
-- Sean...
#!/usr/bin/perl
$j=\$j;{$_=unpack(P24,pack(L,$j++));/Just Another Perl Hacker/?print:redo}
------------------------------
Date: Tue, 26 Dec 2000 19:01:15 -0600
From: "John Michael" <johnm@acadiacom.net>
Subject: declaring variables
Message-Id: <3a4941b3@news.acadiacom.net>
I am using this input routine to pull variables into a script at runtime.
It gives me the opportunity to add variables into the script at runtime
without changing the script.
sub assign_values {
my @array = @_;
my ($name,$value);
foreach (@array) {
chomp;
($name, $value) = split(/=/);
$$name = $value;
push (@vars,$name);
}}
If I want to run the script with
use strict;
How can I declare those variables so that they do not cause an error or do I
even have to?
Thanks in advance.
--
John Michael
------------------------------
Date: 26 Dec 2000 23:05:17 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Error from MIME::Lite
Message-Id: <slrn94i91d.mi8.abigail@tsathoggua.rlyeh.net>
Randy Harris (harrisr@bignet.net) wrote on MMDCLXXIV September MCMXCIII
in <URL:news:t4hqfsjbpbnj7f@corp.supernews.com>:
`' Abigail <abigail@foad.org> wrote in message
`' news:slrn94guj0.3un.abigail@tsathoggua.rlyeh.net...
`' > Randy Harris (harrisr@bignet.net) wrote on MMDCLXXIV September
`' MCMXCIII
`' > in <URL:news:t4gcgvl9orb148@corp.supernews.com>:
`' > `' The code and sub below are from MIME::Lite 2.104, file Lite.pm.
`' When it
`' > `' is run with the -w switch it generates the following warning:
`' > `'
`' > `' Unrecognized escape \s passed through at (eval 2) line 11
`' > `'
`' > `' Simply having "use MIME::Lite ;" in the program causes it to report
`' the
`' > `' warning. The warning is coming from this line:
`' > `'
`' > `' my $SEP = "(?:^\\s*|\\s*,\\s*)"; ### before elems in a
`' list
`'
`' > `' How can I correct this, or, should I simply ignore the warnings?
`' >
`' > Change the double quotes to single quotes.
`'
`' Should this error be reported to someone?
The author I presume.
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");
------------------------------
Date: Wed, 27 Dec 2000 08:56:02 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: FAQ 6.21: What's wrong with using grep or map in a void context?
Message-Id: <92ber4$dek@netnews.hinet.net>
> Both grep and map build a return list, regardless of their context.
This
> means you're making Perl go to the trouble of building up a return
list
> that you then just ignore. That's no way to treat a programming
> language, you insensitive scoundrel!
Hey, map and grep, you can save the trouble of building up a return list
when (not defined wantarray), right? Don't blame the programmers.
John Lin
------------------------------
Date: Tue, 26 Dec 2000 21:38:09 GMT
From: wendywds@my-deja.com
Subject: Help with searching flat files & CGI
Message-Id: <92b341$ae$1@nnrp1.deja.com>
I'm hoping I can get a nudge (or perhaps a shove) in the right
direction. Here's what I want to do:
I have a ton of pictures that I'd like to share with friends and
strangers who visit my site. (Using Tripod for this, because my ISP
doesn't allow CGI.) I have them organized in directories:
//wendywds.tripod.com/photos (top level-- nothing in here)
//wendywds.tripod.com/photos/20000117DennyEmerson (lots of .jpg files)
That's all that's there right now, but there will be more
subdirectories. Just practicing right now.
In each directory, I will place a .dat file with the same name as the
subdirectory that contains the filename, description, and keywords.
One line per image.
Example: 20000117DennyEmerson.dat
Appy_ditch.jpg||Appaloosa x TB over ditch at Grass Ridge Farm||cross
country horse
Appy_XC1.jpg||Appaloosa x TB on XC at Grass Ridge Farm||cross country
horse
I'm using a double piping symbol '||' as a delimiter.
I've swiped a webmonkey script that searches a text file, but I can
only get it to work if the text file is in the same directory as
the .cgi file.
open (DATA, "movies.dat");
my @data = <DATA>;
close (DATA);
This is probably more Unix than Perl, but how do I get it to open a
file that's in a different directory? I have to get it to back up one
level, then go down a different path. If I put in a path, it expects
to find it underneath cgi-bin where the script lives. I think.
I also have Matthew Wright's 'Simple Search' which currently searches
the *.html files. I think I can swipe the section that gathers up all
the html files and make it find the .dat files. Between both of these
scripts, I think I can get this to work eventually.
And once it does work, I should be able to build the page of links
using 1) My "domain" at tripod, plus /photos/ 2) the filename of
the .dat file (as the subdirectory) 2) the individual lines within that
file that had a match, the first part of that line being the filename.
if ($data[$i] =~ /-- $movie{'title'} --/i)
The webmonkey script is looking for an exact title within --
separators. I want to find the word or phrase they entered anywhere on
the line. Obviously I need to go brush up on regular expressions.
My first Perl/CGI project. Perhaps it's a bit ambitious...
I have the O'Reilly Perl CD Bookshelf coming... hopefully it will
arrive today. If what I'm asking is in there, just say so and I'll sit
on my hands until it gets here. (Impatient? Me?)
Thanks for any help or advice. Basically, does what I'm trying to do
sound reasonble? Am I going about it in a generally correct way, if
not THE most efficient way? And if something like this already exists
somewhere [free], please let me know! I found tons of search scripts,
but none that came as close as the two I'm working from.
Wendy in Chandler AZ
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 26 Dec 2000 19:00:44 GMT
From: richardstands@my-deja.com
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <92apsq$oq4$1@nnrp1.deja.com>
In article <jFg16.440$B9.170957824@news.frii.net>,
cfedde@fedde.littleton.co.us (Chris Fedde) wrote:
> In article <922rf9$g2m$1@nnrp1.deja.com>, <richardstands@my-
deja.com> wrote:
> >Hi all,
> >
> >I was working on a progress bar for an FTP upload and got all tangled
> >up in figuring the percentage and wound up using the modulus operator
> >(math is not my strong suit).
> >
>
> You are looking at a simple scaling problem. I'm not sure what
modulus
> will do for you. Here is a demo.
>
> use strict;
> use warnings;
>
> my $size = 3402292; # Size of 'file'
> my $width = 40; # size of the progress bar
> my $transfer = 0;
> $| = 1;
>
> while ($transfer < $size) {
>
> $transfer += rand(30);
>
> my $marker = $transfer * $width/$size;
> print "we've done this much: [".
> ("*" x $marker). (" " x ($width - $marker)). "]\r";
> }
>
> print "\n";
>
> chris
> --
> This space intentionally left blank
>
OK, I see where you are coming from with this, all except using the rand
() func that is.
Why I was using the modulus op is due to the fact that I was also
working with Tk::Progressbar & Tk::ProgressIndicator and found that
they both moved much faster if I only updated them when the increment
actually changed(in this case 10 units * 10 = 100%). I used modulus to
decide when I had reached an increment of exactly 10%; in the end this
was failing as it turned out to be unlikely that the increment would
ever be exactly 10, the way I was doing it(incrementing based on bytes
of the file being sent). I said math was not my strong suit ;o) Perhaps
I should get a job delivering mail.
-Rich
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 26 Dec 2000 23:12:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: heredoc within heredoc
Message-Id: <slrn94i9en.mi8.abigail@tsathoggua.rlyeh.net>
Joe Schaefer (joe+usenet@sunstarsys.com) wrote on MMDCLXXIV September
MCMXCIII in <URL:news:m3r92vaxf1.fsf@mumonkan.sunstarsys.com>:
** "John Lin" <johnlin@chttl.com.tw> writes:
**
** > parse(<<HTML,<<RULE,<<EMAIL);
** ^
** >
** > works, but
** >
** > parse(
** > <<HTML, # my boss asked me to separate
** > <<RULE, # them into 3 lines and add
** > <<EMAIL # comments to explain them
** > );
** ^
** Not a statement terminator- just a separator.
** Hence it's totally useless for telling perl
** when your statement has ended and the HERE-DOC's
** should begin. I think you're stuck leaving
** everything on one line until/unless perl developers
** can appreciate the advantage of having a statement
** terminator for situations like yours, or an even
** more convoluted and evil thing like:
Well, Perl doesn't have statement terminators; just statement
separators, making things more complicated.
** my $sth = $dbh->prepare(<<SQL)
** or die "prepare failed: $DBI::errstr: " . <<SQL;
**
** SELECT * FROM blah
** WHERE foo='bar'
**
** SQL
**
**
** which IMHO is preferable to
**
**
** my $sth = $dbh->prepare($_=<<SQL)
**
** SELECT * FROM blah
** WHERE foo='bar'
**
** SQL
** or die "prepare failed: $DBI::errstr: $_";
IMO, the following is much clearer, as it separates the query from the
mechanics of retrieving the results:
my $command = <<SQL;
SELECT * FROM blah
WHERE foo = 'bar'
SQL
my $sth = $dbh -> prepare ($command) or
die "Prepare failed: $DBI::errstr: $command";
Abigail
--
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: 26 Dec 2000 19:10:24 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: heredoc within heredoc
Message-Id: <m3elyubu6n.fsf@mumonkan.sunstarsys.com>
abigail@foad.org (Abigail) writes:
> Well, Perl doesn't have statement terminators; just statement
> separators, making things more complicated.
>
> Joe Schaefer (joe+usenet@sunstarsys.com) wrote on MMDCLXXIV September
> MCMXCIII in <URL:news:m3r92vaxf1.fsf@mumonkan.sunstarsys.com>:
>
> ** my $sth = $dbh->prepare(<<SQL)
> ** or die "prepare failed: $DBI::errstr: " . <<SQL;
> **
> ** SELECT * FROM blah
> ** WHERE foo='bar'
> **
> ** SQL
> **
> **
> ** which IMHO is preferable to
> **
> **
> ** my $sth = $dbh->prepare($_=<<SQL)
> **
> ** SELECT * FROM blah
> ** WHERE foo='bar'
> **
> ** SQL
> ** or die "prepare failed: $DBI::errstr: $_";
>
> IMO, the following is much clearer, as it separates the query from the
> mechanics of retrieving the results:
>
> my $command = <<SQL;
> SELECT * FROM blah
> WHERE foo = 'bar'
> SQL
>
> my $sth = $dbh -> prepare ($command) or
> die "Prepare failed: $DBI::errstr: $command";
My only gripe with this is that $command is probably
never needed beyond this piece of code. I often do
exactly what you recommend, and if I had multiple
$dbh->prepare lines I'd wind up reusing $command for
those as well.
I just don't think introducing a $command variable
for a one-line usage "should" be necessary.
--
Joe Schaefer
------------------------------
Date: 27 Dec 2000 00:36:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: heredoc within heredoc
Message-Id: <slrn94ied8.mi8.abigail@tsathoggua.rlyeh.net>
Joe Schaefer (joe+usenet@sunstarsys.com) wrote on MMDCLXXV September
MCMXCIII in <URL:news:m3elyubu6n.fsf@mumonkan.sunstarsys.com>:
() abigail@foad.org (Abigail) writes:
()
() > Joe Schaefer (joe+usenet@sunstarsys.com) wrote on MMDCLXXIV September
() > MCMXCIII in <URL:news:m3r92vaxf1.fsf@mumonkan.sunstarsys.com>:
() >
() > ** my $sth = $dbh->prepare(<<SQL)
() > ** or die "prepare failed: $DBI::errstr: " . <<SQL;
() > **
() > ** SELECT * FROM blah
() > ** WHERE foo='bar'
() > **
() > ** SQL
() > **
() > **
() > ** which IMHO is preferable to
() > **
() > **
() > ** my $sth = $dbh->prepare($_=<<SQL)
() > **
() > ** SELECT * FROM blah
() > ** WHERE foo='bar'
() > **
() > ** SQL
() > ** or die "prepare failed: $DBI::errstr: $_";
() >
() > IMO, the following is much clearer, as it separates the query from the
() > mechanics of retrieving the results:
() >
() > my $command = <<SQL;
() > SELECT * FROM blah
() > WHERE foo = 'bar'
() > SQL
() >
() > my $sth = $dbh -> prepare ($command) or
() > die "Prepare failed: $DBI::errstr: $command";
()
() My only gripe with this is that $command is probably
() never needed beyond this piece of code. I often do
() exactly what you recommend, and if I had multiple
() $dbh->prepare lines I'd wind up reusing $command for
() those as well.
()
() I just don't think introducing a $command variable
() for a one-line usage "should" be necessary.
If it's just a one-liner, why bother with a die message? Just use
RaiseError when making the connection. Furthermore, specially in
one-liners, $_ is used often - if it isn't "worth" using a variable,
is it "worth" sacrificing $_ for it (as your legal code does)?
If it's just a one liner, I wouldn't be using Perl at all.
echo "SELECT * FROM blah WHERE foo = 'bar'" | isql [options]
or
echo "SELECT * FROM blah WHERE foo = 'bar'" | mysql [option]
will do.
Abigail
--
print 74.117.115.116.32;
print 97.110.111.116.104.101.114.32;
print 80.101.114.108.32;
print 72.97.99.107.101.114.10;
------------------------------
Date: 26 Dec 2000 17:58:24 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Is there a standard, current Perl for Win32 (without ActivePerl?)
Message-Id: <92b7qg$646@junior.apk.net>
In article <3A42A39F.AE1DE430@animats.com>,
John Nagle <nagle@animats.com> wrote:
> Well, for one thing, ActivePerl isn't entirely open source.
>There are redistribution restrictions. Read the license at
>http://www.activestate.com/Products/ActivePerl/redistribution_info.html
>Whether those restrictions violate the GPL is a good question.
I don't think it's such a good question.
Whether those restrictions violate the Artistic License might be an
excellent question though.
------------------------------
Date: Tue, 26 Dec 2000 21:48:17 GMT
From: mrfreeze_2000@my-deja.com
Subject: Re: Net::DNS and NT Permissions (Should be IO::Socket and NT Permissions)
Message-Id: <92b3n0$p6$1@nnrp1.deja.com>
I don't think the module problem lies with Net::DNS anymore, and
instead lies with IO::Socket and/or IO::Socket::INET, as the following
script also fails:
print "Content-type: text/html\n\nHello!\n<BR>\n";
use IO::Socket;
my $sock = new IO::Socket::INET (
PeerAddr => '209.119.96.2',
PeerPort => '53',
Proto => 'tcp',
);
print "Could not create socket: $!\n" unless $sock;
print $sock "Hello there!\n";
close($sock);
It outputs the following:
Hello!
Could not create socket: Unknown error
So it looks like creating a socket is possibly having an issue with NT
permissions...I'm open to suggestions...Thanks!
In article <92adjj$fdi$1@nnrp1.deja.com>,
mrfreeze_2000@my-deja.com wrote:
> Anyone now what permissions are necessary to
> allow this module to work properly under Windows
> NT 4 Workstation w/SP6a? If I am logged in on the
> machine as an admin, my script returns the
> expected output, but if I attempted to access it
> via the web server running on my machine (PWS
> 4.0), I get something like the following:
>
> ;; query(bluestar.net, MX, IN)
> ;; send_tcp(209.119.96.2:53) (src port = 0)
> ;; ERROR: send_tcp: connection failed: Unknown
> error
> ;; send_tcp(209.119.96.3:53) (src port = 0)
> ;; ERROR: send_tcp: connection failed: Unknown
> error
>
> Since this script is run as the IUSR user on my
> machine by PWS, that is the only difference I can
> think of, since when I am logged into my machine,
> I have admin rights and can run the script
> normally. This is driving me up a wall... I'm
> pretty sure this is a permissions issue, would
> appreciate any insight anyone can provide.
>
> Stephen Leavitt
> stephen(underscore)j(underscore)
> leavitt@nospam.hotmail.com
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 27 Dec 2000 01:28:54 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: No embeding please!
Message-Id: <slrn94ihj1.9cd.tim@degree.ath.cx>
timothy <timothy@no.spam.here.aracnet.com> wrote:
> Well, I'm creating my first web enabled database and I would rather
> avoid embeding my PERL in my HTML or my HTML in my PERL.
You may not be able to get around embedding, but you might have a look
at HTML::Template on CPAN. In fact, you could just do a search on CPAN
with the keyword "HTML" and see what comes up! That's what it's there
for.
www.cpan.org: learn it, live it, love it. =)
HTH
--
-Tim Hammerquist <timmy@cpan.org>
The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.
-- Robert Oppenheimer
------------------------------
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 5202
**************************************