[12930] in Perl-Users-Digest
Perl-Users Digest, Issue: 340 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 2 20:07:25 1999
Date: Mon, 2 Aug 1999 17:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 2 Aug 1999 Volume: 9 Number: 340
Today's topics:
Re: Announcement: "CRAP" (Abigail)
Re: C++ codes. (Abigail)
Re: DBI - how to insert and retrieve BLOBs in Oracle 8i <rereidy@uswest.net>
File Permissions (NiteFever)
Re: Files exploding on me and I'm not sure why (Abigail)
Re: General question about CHMOD <cassell@mail.cor.epa.gov>
Re: General question about CHMOD (elephant)
Re: Goodbye clp.misc, Tad is checking out (was: why are (I R A Darth Aggie)
Re: How can I know what modules are installed on server makarand_kulkarni@my-deja.com
Re: HOW Do you use Perl to answer questions prompted fr (elephant)
Re: HOW Do you use Perl to answer questions prompted fr <cassell@mail.cor.epa.gov>
Re: How to access only last field of a split ? <cassell@mail.cor.epa.gov>
Re: How to compare two files and get the differences ? (Abigail)
Re: Invoing Perl script on Remote NT machine (Michael James OConnor)
Re: IP Validation (I R A Darth Aggie)
Re: IP Validation <dummkopf@debussy.ucsc.edu>
Re: Logical Construction <makkulka@cisco.REMOVETHIS.com>
Re: Newbie question about hashes (Abigail)
Re: Perl Begineer Question... (Abigail)
Re: perl Upload Triggering (Abigail)
Re: Search <cassell@mail.cor.epa.gov>
Re: Stopping output makarand_kulkarni@my-deja.com
Re: Syncing Domains in NT <carvdawg@patriot.net>
Re: Warrning with Variable <aqumsieh@matrox.com>
White Camel Awards <hal_mounce@amdahl.com>
Re: Win32 Perl won't display HTML <cassell@mail.cor.epa.gov>
Re: Win32 Perl won't display HTML (elephant)
Windows recursive copy? tsackett@iname.com
Re: Working Telnet Script Needed <cassell@mail.cor.epa.gov>
Re: Working Telnet Script Needed <carvdawg@patriot.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Aug 1999 18:20:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Announcement: "CRAP"
Message-Id: <slrn7qc9sp.rb1.abigail@alexandra.delanet.com>
Greg Bacon (gbacon@itsc.uah.edu) wrote on MMCLXII September MCMXCIII in
<URL:news:7o53t6$kiv$3@info2.uah.edu>:
&& In article <Pine.GSO.4.10.9908011503090.28810-100000@crusoe.crusoe.net>,
&& Jeff Pinyan <jeffp@crusoe.net> writes:
&& : http://www.pobox.com/~japhy/perl/crap
&&
&& Ahem! <URL:http://www.pobox.com/~japhy/perl/crap/>
Ahem! <URL:http://www.pobox.com/%7Ejaphy/perl/crap/>
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 2 Aug 1999 18:48:57 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: C++ codes.
Message-Id: <slrn7qcbi7.rb1.abigail@alexandra.delanet.com>
Parents (humpet@yesic.com) wrote on MMCLXII September MCMXCIII in
<URL:news:37A5FA79.DFF92735@yesic.com>:
<>
<> I need to keep some codes as a C++ class and a perl module. It will be
<> not comfortable to have two different source files. Are there any tools
<> to generate perl codes from C++ ones or to create C++ and perl from some
<> intermediate format?
<> What is the best way to solve this problem?
# define use /*
# define __END__ */
use strict;
... Your Perl Code here ...
__END__
... Your C++ Code here ...
HTH. HAND.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 02 Aug 1999 17:49:52 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: DBI - how to insert and retrieve BLOBs in Oracle 8i?
Message-Id: <37A62EA0.DB077524@uswest.net>
Simon Twigger wrote:
> Hi there,
>
> I'm writing a perl/CGI/web based application which is using an Oracle8i
> database to store assorted data. What I would like to be able to do is
> have people upload files to the database (eg. Excel, PDF, images, etc)
> where they would be stored and then served back for download or on-line
> viewing as required.
>
> At the moment I can get the data onto the server saved as a file on the
> disk, with a filename stored in the database. I then use the stored
> filename to create a link to the file saved on the local filesystem.
> What I would rather do is have the file stored completely in the
> database and not on the local filesystem, and have a link to a script
> that served the file up directly from the database. I have DBI up and
> running but I dont know how to go about inserting binary data into the
> database using DBI and similarly I dont know how to read it back out
> again to serve up to the browser in response to a request.
>
> Can anyone enlighten me on how to achieve this or point me towards any
> examples?
>
> Many thanks for any help!
>
> Simon.
>
> --
> --------------------------------------------------
> Simon Twigger, Ph.D.
> Laboratory for Genetic Research,
> Cardiovascular Research Center,
> Medical College of Wisconsin,
> 8701 Watertown Plank Road,
> Milwaukee, WI, 53226
>
> http://legba.ifrc.mcw.edu/~simont/
>
> tel. 414-456-4409 fax. 414-456-6516
> --------------------------------------------------
Look at the DBI docs and look for LongreadLen and LongTruncOK.
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
------------------------------
Date: Mon, 02 Aug 1999 23:52:03 GMT
From: abc@abc.net (NiteFever)
Subject: File Permissions
Message-Id: <37a63bda.8761183@news5.bellatlantic.net>
I'm writing a perl script that will check all of the directorys under
the /home directory to see if it has the following permissions:
drwx--x--x
And if it's not, to change it, the problem is, that I don't know what
is the octal form of this, like
-rwx------
would be 0700 with the chmod function. Any help would be great..
------------------------------
Date: 2 Aug 1999 19:03:59 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Files exploding on me and I'm not sure why
Message-Id: <slrn7qccec.rb1.abigail@alexandra.delanet.com>
John Borwick (John.Borwick@sas.com) wrote on MMCLXII September MCMXCIII
in <URL:news:37a7f30e.26882925@newshost.unx.sas.com>:
`` On Mon, 02 Aug 1999 15:47:59 GMT, vertigotwo@my-deja.com wrote:
``
`` [ snip explanation ]
`` >sub savedata{
`` > open(FILE, ">ff/playerindex") || IllegalRefresh("PlayerIndex file
`` >cannot be opened - $!");
`` > flock(FILE, 2) || IllegalRefresh("PlayerIndex cannot be flocked - $!");
`` > seek (FILE, 0, 2) || IllegalRefresh("PlayerIndex cannot be seeked -
`` >$!");
``
`` Why do you open for writing '>' instead of appending '>>'? Your
`` seek could then be removed.
> starts with wiping out the file, while >> keeps what's there. I wouldn't
say those are equivalent....
`` > foreach $elem (keys(%person)){
`` > $money{$elem}= int($money{$elem} * 100) /100;
``
`` isn't int($money{$elem} * 100)/100; the same as int($money{$elem}) ?
$ perl -wle '$foo = 1815 / 73; print int ($foo * 100) / 100; print int $foo'
24.83
24
$
`` > print FILE "---\n";
`` > print FILE "$person{$elem}\n";
`` > print FILE "$password{$elem}\n";
`` > print FILE "$lastplay{$elem}\n";
`` > print FILE "$points{$elem}\n";
`` > print FILE "$money{$elem}\n";
`` > print FILE "$inventory{$elem}\n";
`` > print FILE "$playnum{$elem}\n";
`` > print FILE "$mailbool{$elem}\n";
`` > print FILE "$address{$elem}\n";
`` > print FILE "$hoursbtw{$elem}\n";
`` > print FILE "$mailday{$elem}\n";
`` > print FILE "$awards{$elem}\n";
`` > print FILE "$penalties{$elem}\n";
`` > print FILE "$salary{$elem}\n";
`` > print FILE "$lastsignon{$elem}\n";
`` > print FILE "$karma{$elem}\n";
`` > print FILE "$imps{$elem}\n";
`` > print FILE "$bonusp{$elem}\n";
``
`` I'm sure it's a bad idea, but this particular code makes me want to
`` suggest symbolic references to reduce typing.
No. Instead of having a gazillion hashes each indexed on $elem, (s)he should
have a toplevel hash indexed on $elem, with values hashes whose keys are
person, password, lastplay, points, etc.
And (s)he should use a here document.
Or:
my %info = %{$toplevel_hash {$elem}};
{local $" = local $\ = "\n";
print FILE "---\n";
print @info {qw {person password lastplay points money inventory playnum
mailbool address hoursbtw mailday awards penalties salary
lastsignon karma imps bonusp}};
}
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 02 Aug 1999 16:46:37 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: General question about CHMOD
Message-Id: <37A62DDD.EEC83FB7@mail.cor.epa.gov>
llornkcor@earthlink.net wrote:
>
> ahh- but this DOES have something to do with perl. You must chmod ANY
> perl script to get it to run on unix systems, right???
No. Not if you run the program like this:
perl proggiename
Umm, do you think that this is more related to: (1) Perl, or
to (2) security, or to (3) web-authoring, or to (4) general
unix issues? I would peg this as clearly more relevant to
#2 or #3, and hence a better topic for other newsgroups.
If you feel that any connection whatsoever to Perl is enough
to make it relevant to this newsgroup, then do you also feel
that - since it relates to words - it should be posted in
alt.english? That - since it relates to programming topics -
it should be posted in comp.programming?
> anyway- to kindly answer your question, chmod 777 IS a security risk,
> giving read, write, and execute permission to EVERYONE in the whole
> world. That means, anyone could delete any PERL scripts. chmod 775 is
> better, and chmod 755 even better, depending on just who you are.
I'm not sure this is the best advice you could give.
Have you looked at the HTML Security FAQ and the CGI
Security FAQ to see what they have to say? There are
pointers to them in the Perl FAQ.
> "Donboy" <webmaster@roleplayinggames.net> writes:
[some stuff I snipped]
BTW, you could please put your replies *after* the the phrases
to which you are responding? It will be a win-win proposition.
Others will be better able to follow the threads. You will
be happier because newsgroup pedants cease calling you bad
names for ignoring Usenet guidelines.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 3 Aug 1999 09:57:59 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: General question about CHMOD
Message-Id: <MPG.1210db8f19113569989bb8@news-server>
llornkcor@earthlink.net writes ..
>ahh- but this DOES have something to do with perl. You must chmod ANY
>perl script to get it to run on unix systems, right???
nope .. you can pass any readable file to the perl interpreter and it
will run it .. you only need the execute bit set for the shebang to work
even in that case .. assuming a 022 umask (default on most systems) if
the file is opened with a 0777 mode then you'll have a 0755 mode on that
file - no chmod required
as you can see .. this is a UNIX question
>anyway- to kindly answer your question, chmod 777 IS a security risk,
>giving read, write, and execute permission to EVERYONE in the whole
>world. That means, anyone could delete any PERL scripts.
now you're really pissing me off .. this may be polite but it's WRONG ..
777 on a file does not give someone permission to delete that file .. far
worse - it gives global permission to change the file
to delete a file you need write access to the directory that the file is
in !
also .. when you say 'anyone' and 'whole world' you seem to be forgetting
that any would be hacker would still need access to the server .. either
via FTP or Telnet or some other daemon .. or - far more likely - someone
else with an account on the same machine
> chmod 775 is
>better, and chmod 755 even better, depending on just who you are.
it doesn't depend on who they are as to whether 755 is better than 775 ..
it's better if the server has more than this one user in that user's
group .. and more importantly - there's no reason not to use 755
as was said before .. this was not a perl question .. it was a UNIX
question
oh yeah .. I've just been reminded (got to the end of your post and found
what you were following up) .. don't be lazy - post your followup AFTER
the original - or better still interleave it
--
jason - remove all hyphens for email reply -
------------------------------
Date: 2 Aug 1999 23:21:39 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Goodbye clp.misc, Tad is checking out (was: why are you so harsh to this guy ?)
Message-Id: <slrn7qca48.rec.fl_aggie@thepentagon.com>
On Mon, 2 Aug 1999 15:31:30 -0700, Larry Rosler <lr@hpl.hp.com>, in
<MPG.120fbc209b73014b989da0@nntp.hpl.hp.com> wrote:
+ In article <slrn7qc5pj.r99.fl_aggie@thepentagon.com> on 2 Aug 1999
+ > And thanks for all the fish.
+ Don't you mean 'fishing lessons'? :-(
Well, of course. It was a stylistic consession to a book title. If
memory serves, that was the last thing the dolphins told the humans
before abandoning Earth to the Vogons.
Hmmm...does Tad know something we don't?
James
------------------------------
Date: Mon, 02 Aug 1999 23:23:05 GMT
From: makarand_kulkarni@my-deja.com
Subject: Re: How can I know what modules are installed on server?
Message-Id: <7o598f$dld$1@nnrp1.deja.com>
--
To diagnose this -- try dumping contents of @INC and %INC.
You may want to add additional directories to @INC if
perl is not looking into those dirs to find the .pm files.
Do this inside a BEGIN { } block.
The other thing you could do is run
the below two commands..
setenv PERL_DL_DEBUG 255
perl -e 'use Modulename.pm;'
and look at the messages emitted. If you
do not have access to the machine tell
your sysadmin to do this.
--
> How can I tell what modules are installed on a server? How can I
replicate
> the library enviroment in my machine so it is the same as on the
server so I
> won't run into these type of complications?
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 3 Aug 1999 09:31:44 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: HOW Do you use Perl to answer questions prompted from a ksh script
Message-Id: <MPG.1210d56f384adec989bb7@news-server>
Greg Guerin writes ..
>I am trying to use perl to answer questions that a ksh script is
>generating. The ksh script will be started within the perlscript and
>then the question/answers begin. Any ideas on how to do this would be
>most appreciated. Thank you.
use Open2 from the IPC standard module to open both read and write
handles to your ksh script .. then read and write the those handles as
required
perldoc IPC::Open2
--
jason - remove all hyphens for email reply -
------------------------------
Date: Mon, 02 Aug 1999 16:37:51 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: HOW Do you use Perl to answer questions prompted from a ksh script
Message-Id: <37A62BCF.807A644B@mail.cor.epa.gov>
Greg Guerin wrote:
>
> Hi,
>
> I am trying to use perl to answer questions that a ksh script is
> generating. The ksh script will be started within the perlscript and
> then the question/answers begin. Any ideas on how to do this would be
> most appreciated. Thank you.
No idea. Well, no clear idea. Can you be a little more
specific? Can you show what you mean in a Perl program of
less than 30 lines? Why do you need to do this in a shell
script launched from a perl script, rather than solely in
ksh or solely in Perl?
There are a number of ways to read program output in Perl,
but it's hard to tell what you have in mind here. You
might start by reading:
perldoc system
perldoc qx
perldoc open
perldoc fork
One or more of these is probably what you want.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 02 Aug 1999 16:31:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to access only last field of a split ?
Message-Id: <37A62A55.47C87020@mail.cor.epa.gov>
Sawant Sachin wrote:
>
> Hi,
> $line = "word.10.word.20.30.40.50";
> $scalar = ( reverse split '[.]',$line)[0]; # last element of split line
>
> Above will work !!
Yes, as it would if you backwhacked the period. But that
doesn't change the fact that this is not an efficient way
to handle the problem. A better answer was posted elsewhere
in this thread, using the index -1 to get the last element
of the split().
BTW, please post according to official Usenet guidelines,
placing your replies *after* the phrases to which you are
responding. Others will be happier with you, and you will
be happy that no one is calling you bad names.
[snip of Larry's post which pointed out that the original
suggestion failed because '.' is a regex metacharacter]
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 2 Aug 1999 18:14:26 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to compare two files and get the differences ?
Message-Id: <slrn7qc9he.rb1.abigail@alexandra.delanet.com>
Yeong Mo/Director Hana co. (factory@factory.co.kr) wrote on MMCLXII
September MCMXCIII in <URL:news:7o5128$cp5$1@news1.kornet.net>:
@@ With your solution, it going to be work.
@@ However, I have no idea hwo to handle the two lines.
@@ my $all = "?????";
@@ my $takeout = "?????";
@@ Would you please give me more directions ?
Here's a hint: hire someone with a clue.
@@ Thank you in advance.
@@
@@ The following code is what I am trying;
@@ open(FILE, "$page_dir/link/data/categories.backup") || die "I can't open
@@ that file of $dbdata\n";
@@ flock (FILE,1) or die "can't lock index file\n";
@@ @lines = <FILE>;
@@ close(FILE);
@@ $sizelines = @lines;
@@ for ($i=0;$i<$sizelines;$i++) {
@@ ($f1, $categorybackup, $f2, $f3, $f4, $f5, $f6, $f7) = split ('\|',
@@ $lines[$i]);
@@ $catall= "$categorybackup,";
@@ }
Well, if that's what you want, why not:
open FILE, "$page_dir/link/data/categories.backup" or
die "I can't open that file of $dbdata\n"; # What's $dbdata, and why
# isn't there a $!?
flock FILE, 1 or die "Cannot lock index file\n"; # Where's the $!?
my $line;
1 while $line = <FILE>;
my $catall = ((split '\|', $line, 3) [1]) . ",";
After all, you're discarding everything but the result of the last line.
Putting in everything in an array is inefficient if you're going to
process the lines one by one anyway. And do use Perl idiom instead of
C idiom to loop over arrays. If you want C - you know where to get it.
But I think you want something else. What, that remains totally unclear.
Please, consider hiring someone with programming experience.
@@ use strict;
@@
@@ my $all = "";
@@ my $takeout = "";
@@
@@ my %takeout;
@@ @takeout{split /,\s*/ => $takeout} = ();
Since $takeout is equal to "", why don't you just write:
my %takeout = ("" => undef);
Or perhaps you want something else?
@@ my $remain = join ', ' => grep !exists $takeout{$_} =>
@@ split /,\s*/ => $all;
@@ print "$remain\n";
Well, given that $all equals "", a split will result in (""), which happens
to be the only key in %takeout, so it's filtered out. Hence, $remain becomes
"", and all the print does is printing a newline.
I doubt that is what you want.
What you do want is to hire someone with a clue.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 02 Aug 1999 23:41:16 GMT
From: ltcdrmikej@aol.comno.spam (Michael James OConnor)
Subject: Re: Invoing Perl script on Remote NT machine
Message-Id: <19990802194116.17086.00006087@ng-fs1.aol.com>
Well, last time I saw this error message, it was right after I had FTPed my
file in. Eliminated the carriage returns that had somehow appeared, and it
worked fine. I just used backspace, but if you want a quick and easy clean-up
script, just have something loop through the file (while(<FILEIN>)) and run a
substitution of a blank for the carriage return.
-Mike-
------------------------------
Date: 2 Aug 1999 23:24:13 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: IP Validation
Message-Id: <slrn7qca93.rec.fl_aggie@thepentagon.com>
On Mon, 02 Aug 1999 15:23:21 -0700, Helmut Katzgraber
<dummkopf@debussy.ucsc.edu>, in <37A61A59.34E943B6@debussy.ucsc.edu>
wrote:
+ sorry if i did not post a complete solution.
A complete solution would be rather long and monsterous, I think, because
of all the different cases.
James
------------------------------
Date: Mon, 02 Aug 1999 16:39:16 -0700
From: Helmut Katzgraber <dummkopf@debussy.ucsc.edu>
Subject: Re: IP Validation
Message-Id: <37A62C24.2BF7579@debussy.ucsc.edu>
> A complete solution would be rather long and monsterous, I think, because
> of all the different cases.
>
> James
which is why i did not post it....
cheers, h.
--
-----------------------------------------------------------------
Helmut G. Katzgraber mail: dummkopf@debussy.ucsc.edu
Physics Department, Kerr Hall http://debussy.ucsc.edu/~dummkopf
University of California Phone: (+1) 831-459-4762
Santa Cruz, CA 95064, USA Fax: (+1) 831-459-3043
-----------------------------------------------------------------
------------------------------
Date: Mon, 02 Aug 1999 16:44:12 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: Logical Construction
Message-Id: <37A62D4C.95A714F9@cisco.REMOVETHIS.com>
Write a sub that will return all
elements that you want to loop
on in an array.
@array = &fetch_all_elements();
foreach $element_of_array ( @array )
{
Process(X) ;
}
Samay wrote:
>
> Well, yes that's exactly what I want to do.
> the only problem is that MY foreach construct is very long.
> so, I just want to put it in some type of subroutine and
> whenever I call, I just want to get the next item.
------------------------------
Date: 2 Aug 1999 18:33:29 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Newbie question about hashes
Message-Id: <slrn7qcal6.rb1.abigail@alexandra.delanet.com>
Niek Slatius (nslatius@dds.nl) wrote on MMCLXII September MCMXCIII in
<URL:news:37A60330.43A938C@dds.nl>:
..
.. In my script I've a hash called %FORM. This thread implements all names
.. from my HTML form with it's corresponding values.
.. So for instance: $FORM{'name'} is John. What I want to do is lowercase
.. all values of this hash.
Didn't the section in the manpage about values give a big hint?
.. I started of trying this code:
..
.. foreach values %FORM{
.. $FORM{$a} = lc $FORM{$a};
.. }
..
.. No good :'-(
Indeed. What did you try after Perl told you about the syntax error?
.. I've tried this code:
..
.. foreach values %FORM ($value){
.. $value = lc $value;
.. }
..
.. That didn't work either :'-(
Indeed. Another syntax error. Clearly, after getting the first one, you
didn't bother looking up the syntax of foreach, did you?
.. What a'm I missing here?
The manual.
.. Don't tell me I need to put the values of %FORM
.. in an array first, then lowercase those values and then put 'em back in
.. a hash again please (except of course if that's the only solution) ;-)
No you don't. But what you do need to do is to read the manual.
.. Thanx in advance for any support.
.. BTW if it is in the FAQ (but not in clear simple English) please
.. redirect me if you would. My native language is not English you see ;-)
.. so I sometimes have trouble figuring out what words mean (like
.. 'iteration'... although I have a clue as to what it probably means).
'iteration' is 'iteratie' in Dutch. That's not that different, is it?
Abigail
--
perl -wlpe '}$_=$.;{' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 2 Aug 1999 18:35:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Perl Begineer Question...
Message-Id: <slrn7qcao8.rb1.abigail@alexandra.delanet.com>
Jimmy (c6635500@comp.polyu.edu.hk) wrote on MMCLXIII September MCMXCIII
in <URL:news:37A6A2BE.99DF2DB9@comp.polyu.edu.hk>:
**
** if length(trim($A)) == 0 then {
** put null string to variable B, the length of null string is
** equal to $no_of_space value
** }
**
** How can I implement the above requirements in Perl?
x
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 2 Aug 1999 18:17:07 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: perl Upload Triggering
Message-Id: <slrn7qc9mh.rb1.abigail@alexandra.delanet.com>
nigh_postal (nigh_postal@my-deja.com) wrote on MMCLXII September MCMXCIII
in <URL:news:7o4k6n$tg1$1@nnrp1.deja.com>:
%% *chuckle* My question is whether or not I should use perl or javascript
%% to try and attempt this. From your response I would have to assume
%% java-script :P
If it's important to you that a significant percentage of your visitors
who are able to use file upload now no longer will be because of your
actions, go ahead and show your cluelessness with javascript.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 02 Aug 1999 16:27:34 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Search
Message-Id: <37A62966.101EBDFA@mail.cor.epa.gov>
Jimtaylor5 wrote:
>
> foreach $searchword (@the_list) {
> if ($searchline =~ /\b$searchword/i) {
> $matchit = 1;
> }
Oogh. If you want to search for a string, use a hash
instead. If you read through the FAQ, you'll see some
helpful suggestions along these lines.
>
> Problem is, if I search "book" this matches bookcase,
> bookends, Booker T. Washington, etc.
Right. But *not* 'cookbook' or 'cookbooks'. The \b in
front makes the regex start at a word boundary. So you
could put a \b right after $searchword and...
But then you won't be able to match 'books'.
> Or if I search "Cook Book"
> it doesn't pick up book. How would I make this example match
Now I just don't believe you. I tried it myself, and if
this is your real code, it would indeed match when $searchline
equals "Cook Book". Are you doing something else which you're
not showing us? Or is this not your real code, cut-and-pasted
into the post?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 02 Aug 1999 23:10:15 GMT
From: makarand_kulkarni@my-deja.com
Subject: Re: Stopping output
Message-Id: <7o58gh$d73$1@nnrp1.deja.com>
Code snippet to illustrate how it cud be done.
#!/usr/local/bin/perl5 -w
my $show_calls = 0; # how many times was show() called.
my $show_throttle = 0; # 0 = off and 1 = on , show pauses after 5
invocations..
my $read_value ;
sub show
{
$show_calls++ ;
print " xxx \n " ;
$read_value = <STDIN> if ( $show_throttle != 0 && ( $show_calls %
5) == 0 )
}
while (1)
{ show() } ;
==
However you will have
print shift;
instead of
print " xxx \n " ;
Be careful while using "print shift;"; Do you know what you are doing ?
Hope this helps.
> sub show
> {
> print shift;
> }
>
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 02 Aug 1999 19:45:56 -0400
From: HC <carvdawg@patriot.net>
Subject: Re: Syncing Domains in NT
Message-Id: <37A62DB4.B5987BC6@patriot.net>
Use Win32::Lanman. Dave Roth has a copy of it at his FTP site (ftp.roth.net),
as well as a newsgroup for it (news.roth.net). For the Permissions solution,
use
Dave's Win32::Perms module.
Paul Napolitano wrote:
> Does anyone know of a way to synchronize an NT domain with a Perl Script?
> I've looked thru every Win 32 Module and couldn't find a thing. What I'm
> trying to do is write an account creation script that also automatically
> adds permissions to the newly created home directory. I'm having a problem
> giving permissions to the newly created user to his home directory when the
> script runs. It seems to be a timing issue with the account taking a few
> minutes after it's created before I can give this account any directory
> permissions. Any suggestions?
>
> -Paul
>
> --
> Paul Napolitano, MCSE
> System Administrator III
> University of Michigan
> College of Literature, Science, & Arts
> 1007 East Huron Ann Arbor, MI. 48104-1690
> paulnap@umich.edu
------------------------------
Date: Mon, 2 Aug 1999 18:08:51 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Warrning with Variable
Message-Id: <x3y1zdlomx9.fsf@tigre.matrox.com>
Samay <anonymous@web.remarq.com> writes:
> I read Perldoc -q SIG to see how nicely clousers are used.
> and the other ways of using SIG.
>
> It prompted to me to check %SIG.
> and to my surprise "__WARN__" was not there..
You sure???
From perlvar:
%SIG $SIG{expr}
The hash %SIG is used to set signal handlers for
various signals. Example:
............ [snip 3 or so screenfuls
............ of relevant, useful discussions]
Certain internal hooks can be also set using the
%SIG hash. The routine indicated by $SIG{__WARN__}
is called when a warning message is about to be
printed. The warning message is passed as the first
argument. The presence of a __WARN__ hook causes
the ordinary printing of warnings to STDERR to be
suppressed. You can use this to save warnings in a
variable, or turn warnings into fatal errors, like
this:
local $SIG{__WARN__} = sub { die $_[0] };
eval $proggie;
It is very easy to check for a word in a file .. perhaps you should do
that when you want to check for a word in a file :)
> I also read perlipc
>
> How does this works?
How does what work? What are you exactly trying to do?
Perhaps you need to look at perlfaq7, which answers the following
question:
How can I catch accesses to undefined
variables/functions/methods?
The answer also traps warnings using $SIG{__WARN__}.
To make life a bit simpler for me, I have a command called "podgrep"
which is actually an alias:
alias podgrep 'grep "\!*" /opt/GNUperl5.004_04/lib/pod/*.pod'
If I want to look up any keyword, I just use it to point me to the
correct POD in seconds. I suggest you do the same. Oh, this is only
on *nix machines of course ..
More generically, you can do something like:
% perl -wne 'BEGIN { $k = shift @ARGV; @ARGV = glob \
q(/opt/GNUperl5.004_04/lib/pod/*.pod)} \
print "$ARGV: $_" if /$k/' argument_to_search_for
Actually, this has the added advantage of being able to set
"argument_to_search_for" to any valid Perl regexp ...
hmmmm...
HTH,
Ala
------------------------------
Date: Mon, 02 Aug 1999 16:59:53 -0700
From: Hal Mounce <hal_mounce@amdahl.com>
Subject: White Camel Awards
Message-Id: <37A630F9.26AF9893@amdahl.com>
I stumbled across http://www.perl.com/pace/pub/whitecamel/newindex.html
and was about to nominate someone when I noticed the blank for
"Company:" on the form.
Is this a legitimate award or just a scam to collect marketing data?
Hal
------------------------------
Date: Mon, 02 Aug 1999 16:17:44 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Win32 Perl won't display HTML
Message-Id: <37A62718.4AD47C8A@mail.cor.epa.gov>
Willy Paine wrote:
>
> I have tried two NT machines: one is NT 4.0 service pack 3 with IIS 4.0
> (Option Pack) and Windows 2000 beta 3. I installed both machines with
> ActivePerl version build 518.
>
> I have tried several procedure on setting up environment included
> http://support.microsoft.com/support/kb/articles/Q150/6/29.asp but this is
> probably out of date.
As far as I know, that is the most recent post.
> Well, it works fine with command level but it won't display HTML output on
> web browser.
>
> I feel very frustrated with Win32 Perl. Can you help me how to make HTML
> display from running perl.
I'm sorry, but the problem is still the *server*, not the script
language. You have to convince IIS to use something besides
VBScript and JScript and JavaScript. If you carefully followed
the direction in the MS KB, then this newsgroup isn't the place
to be asking. You'll have to transfer your questions to a
newsgroup about the IIS servers.
Either that, or switch to Apache.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 3 Aug 1999 09:15:11 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Win32 Perl won't display HTML
Message-Id: <MPG.1210d18742250e3989bb6@news-server>
Willy Paine writes ..
>I have tried two NT machines: one is NT 4.0 service pack 3 with IIS 4.0
>(Option Pack) and Windows 2000 beta 3. I installed both machines with
>ActivePerl version build 518.
an unusually good start to your post .. specifying the environment
explicitly
>I have tried several procedure on setting up environment included
>http://support.microsoft.com/support/kb/articles/Q150/6/29.asp but this is
>probably out of date.
not out of date .. just only for IIS 1.0, 2.0 and 3.0 (as it says on the
second line of the article)
>Well, it works fine with command level but it won't display HTML output on
>web browser.
"won't display" .. uh ohh .. the alarm bells are ringing .. it will not
display HTML ? .. so what does it display ? .. or do you mean that it
will not display anything ? .. or is there actually an error message ? ..
or or or........
>I feel very frustrated with Win32 Perl.
so you decided to share that frustration with the usenet community ..
well you've succeeded - your post is also very frustrating
> Can you help me how to make HTML
>display from running perl.
seeing as there is no mention of them .. I'm going to take a wild stab in
the dark and guess that you haven't read the beautiful ActiveState
documentation .. fully prepared for you in lovely HTML format - ready to
browser through with your web browser
you may want to afford a glance to perlwin32faq6 (Web Server Config)
which (amazingly) has this question asked and answered - in 13 easy steps
--
jason - remove all hyphens for email reply -
------------------------------
Date: Mon, 02 Aug 1999 23:47:50 GMT
From: tsackett@iname.com
Subject: Windows recursive copy?
Message-Id: <7o5an3$eij$1@nnrp1.deja.com>
I can't imagine this question hasn't been covered before, but I haven't
been able to track down any useful information.
I'm writing a script that will run on Win95 and WinNT4 machines. It
needs to copy a directory from a server to a local machine. Is there a
perl function that will let me do this?
I gather that I could use the DOS function xcopy, but my some
of my directory paths use "/" (forward-slash) as seperators, and I'd
rather not have to mess with these just to make a copy.
So, does anyone know the best way to do a recursive copy in Perl for
Windows?
-Tom Sackett
tsackett@adobe.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 02 Aug 1999 16:33:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Working Telnet Script Needed
Message-Id: <37A62AE0.180B6469@mail.cor.epa.gov>
Scott Sanbeg wrote:
>
> Hello All,
>
> Does anyone have a pointer, or code, for the following? What I need is any
> *working* Perl script that simply works from a NT command prompt, logs into
> a variety of UNIX servers (one at a time or multiple boxes), issues commands
> (e.g. 'uname -a'), captures that data to a local disk, and logs off.
If you're looking for a script, rather than writing one yourself,
then you may be in the wrong place. You will probably have much
better luck searching the web using one of the major search
engines like Lycos or Alta Vista. Just be sure to include all
the keywords you want, so you don't get too many useless hits.
HAND,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 02 Aug 1999 19:52:29 -0400
From: HC <carvdawg@patriot.net>
Subject: Re: Working Telnet Script Needed
Message-Id: <37A62F3D.FB6E317A@patriot.net>
> > Does anyone have a pointer, or code, for the following? What I need is any
> > *working* Perl script that simply works from a NT command prompt, logs into
> > a variety of UNIX servers (one at a time or multiple boxes), issues commands
> > (e.g. 'uname -a'), captures that data to a local disk, and logs off.
>
> If you're looking for a script, rather than writing one yourself,
> then you may be in the wrong place. You will probably have much
> better luck searching the web using one of the major search
> engines like Lycos or Alta Vista. Just be sure to include all
> the keywords you want, so you don't get too many useless hits.
Wow, Dave! You don't have anything to contribute, so you hammer the guy!
I know, I know, you're going to reply with something along the lines of "we're
not required to give a response" or something similarly witless.
If I had the code to do this, I would make it available...in fact, I am working on
such
a project right now...telnetting to Un*x boxes from NT. I have example of other
snippets of code that I have made freely available.
To Scott...Dave does not speak for everyone on the 'groups. He's a 'govvie'.
What's your timeframe for this...if and when I get my own code up and working, I'd
be glad to share it...
C
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 340
*************************************