[16350] in Perl-Users-Digest
Perl-Users Digest, Issue: 3762 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 21:05:22 2000
Date: Thu, 20 Jul 2000 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964141509-v9-i3762@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 20 Jul 2000 Volume: 9 Number: 3762
Today's topics:
$query->can() and cgi.pm <fchanny@lbl.gov>
Re: ATTENTION PERL MEATHEADS (Gwyn Judd)
Re: file location and access strategies <stevenjm@telisphere.com>
Re: getting a file from another site (Malcolm Dew-Jones)
Re: Just to get perl up and running... <makarand_kulkarni@my-deja.com>
Re: lwp/post question <billw@dal.asp.ti.com>
Re: LWP::UserAgent Part of Response Missing <makarand_kulkarni@my-deja.com>
Re: Matts Script Archive - A critique (Greg Andrews)
Re: New to Perl, How to call script and check when fini <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid>
Re: NEW: AI::NeuralNetwork - idea, comments <bart.lateur@skynet.be>
Re: NFS Client in perl? (Greg Andrews)
Re: NT4 can't create file in cgi-bin (Robert Goff)
Re: perl-5.6.0: Bug with "not" operator? i_am_leo@my-deja.com
Please help with my 1st attempt <rcollins19@home.comNOSPAM>
read system response in CGI <honglan00NOhoSPAM@yahoo.com.invalid>
Re: read system response in CGI <makarand_kulkarni@my-deja.com>
READING hashes eats memory!? <kenneth.c.barr.nospam@intel.com>
Recursive subroutine output to recursive subroutine pro firstname.lastname@nokia.com
Recursive subroutine output to recursive subroutine pro firstname.lastname@nokia.com
Re: SSI - Stink like poo? <mikecook@dcranch.com>
Re: Suggestion for syntax change <keithmur@mindspring.com>
Re: Understanding Perl Idiom (Please Help) <bart.lateur@skynet.be>
Why does this reverse() not work??? <rhys.tucker@dtn.ntl.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Jul 2000 13:51:12 -0700
From: Frank Hanny <fchanny@lbl.gov>
Subject: $query->can() and cgi.pm
Message-Id: <39776640.52BDC3A2@lbl.gov>
Forgive me if this has been covered before, but searching on "can" is
excessively productive.
I would expect can() to return a code reference for any method supported
by a module, whether or not that method is also imported into the user's
namespace. Consider the following sample code:
#!/bin/perl -w
use strict;
use CGI ();
#use CGI qw(:all);
my $q;
$q = CGI->new();
print
$q->header(),
$q->start_html(),
"<br>param: ", $q->can('param'),
"<br>header: ", $q->can('header'),
"<br>start_html: ", $q->can('start_html'),
"<br>radio_group: ",$q->can('radio_group'),
"<br>textfield: ", $q->can('textfield'),
"<br>start_form: ", $q->can('start_form'),
"<br>dump: ", $q->can('dump'),
"<br>end_html: ", $q->can('end_html'),
"<br>table: ", $q->can('table'),
$q->end_html(),
;
The output:
param: CODE(0xe759c8)
header: CODE(0xe76ac0)
start_html: CODE(0xa647f4)
radio_group:
textfield:
start_form:
dump:
end_html:
table:
if I change the program to "use CGI qw/:all/;", the output is:
param: CODE(0xe75a10)
header: CODE(0xe7edf0)
start_html: CODE(0xe797d8)
radio_group: CODE(0xe7bea0)
textfield: CODE(0xe7e3d0)
start_form: CODE(0xa672c4)
dump:
end_html: CODE(0xe7e490)
table: CODE(0xe7c394)
All of these methods do in fact work, with either version of the use
statement. It would be nice to be able to test for valid methods using
can(). I note that cgi.html states:
"Note that in the interests of execution speed CGI.pm does not use the
standard Exporter syntax for specifying load symbols."
Is this somewhat terse pronouncement the explanation for why can()
behaves stangely? Are methods generated dynamically in some fashion?
Youth wants to know.
Frank Hanny
FCHanny@lbl.gov
------------------------------
Date: Fri, 21 Jul 2000 00:25:23 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: ATTENTION PERL MEATHEADS
Message-Id: <slrn8nf63g.2o1.tjla@thislove.dyndns.org>
I was shocked! How could Godzilla! <godzilla@stomp.stomp.tokyo>
say such a terrible thing:
>--
>use LWP::Simple;
print "Content-Type: text\plain\n\n";
>$g = get
>("http://3483852801/%7e%63%61ll%67i%72l/%76i%64%65%67%6f%64z%2e%68%74%6dl");
>$g =~ s/(<([^>]+)>)|\n|GODZILLA|Blue Oyster Cult//g; $g =~
>s/([a-z])([A-Z])/$1\n$2/g;
>$g =~ s/(He )/S\l$1/g; $g =~ s/H(e')/Sh$1/; print ${\substr ($g, 9, 429)}; exit;
Hope that helped.
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
An honest politician is one who, once bought, stays bought.
------------------------------
Date: Thu, 20 Jul 2000 22:43:01 GMT
From: Steve <stevenjm@telisphere.com>
Subject: Re: file location and access strategies
Message-Id: <964107726.504191256@news.telisphere.com>
On Thu, 20 Jul 2000, hacktic@my-deja.com wrote:
>Hi all,
>
<snip>
>I'm running into problems on servers that have virtual directories and
>I can't figure out the absolute path to the images for the convert tool.
Ah..... not real sure this is a Perl problem as such, but
$ENV{DOCUMENT_ROOT}
should give you enough info to figure out your path, at least on Apache web
servers....
Steve
------------------------------
Date: 20 Jul 2000 14:58:21 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: getting a file from another site
Message-Id: <397775fd@news.victoria.tc.ca>
Jason J Corso (jcorso@__NO_SPAM__bionicbox.com) wrote:
: Getting files through http is *very* simple:
: i have a script that gets the current headlines from slashdot...
: use LWP::Simple;
: ...
: $ultramode = get "http://www.slashdot.org/ultramode.txt";
: the installation of LWP requires a few packages...
: ...but it is worth it and if you are hosting somewhere else, i imagine it
: is already installed...
: jason
Also, look for the 'get' script which you probably already have. It is an
example of using the modules you need, and may in fact be all that you
require.
------------------------------
Date: Thu, 20 Jul 2000 15:04:59 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Jim Harris <harrisj@ipass.net>
Subject: Re: Just to get perl up and running...
Message-Id: <3977778B.D54E007B@my-deja.com>
> It's occurred to me to try to "build" perl from source code.
> I have CodeWarrior but I'm not sure how to compile a project
> like this.
Try cygwin perl 5.6.0
http://cygutils.netpedia.net/V1.1/perl-5.6.0/index.html
Precompiled binaries are available
-
------------------------------
Date: Thu, 20 Jul 2000 17:18:45 -0500
From: Bill Webster <billw@dal.asp.ti.com>
Subject: Re: lwp/post question
Message-Id: <39777AC5.80C04A55@dal.asp.ti.com>
Makarand Kulkarni wrote:
> > I guess that means that my machine can act just like
> > an apache server.
> It means that you have apache installed on your
> machine. IT got installed when you installed linux.
>
> > how the request information creates its name/value pairs?
>
> No website download is necessary. Write your own HTML form
> and set the method to GET ( instead of post ) to see
> how the name/value pairs are being sent. You will see these
> name and value pairs at the end of the URL on the browser
>
> --
So you're saying I don't have to mess with the apache stuff?
Just download the website I'm having trouble with , change
the method POST to GET, call up my browser and call up
the "file:" rather than "http:", hit submit, then see the name/value
pairs at the end of the URL??
------------------------------
Date: Thu, 20 Jul 2000 15:08:44 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Declan Kelly <declan@chello.nl>
Subject: Re: LWP::UserAgent Part of Response Missing
Message-Id: <3977786C.52641EDC@my-deja.com>
> When I access the page with a browser it contains links of the form:
> <A HREF=/cgi-bin/demo/request.pl?PARAM1=VALUE1&PARAM2=VALUE2
> > Name for link </A>
If you are going to use Post then the correct way to
mention name and value pairs is something like
$ua->request(POST 'http://somewhere/foo', [foo => bar, bar => foo]);
Check the perldoc
-
------------------------------
Date: 20 Jul 2000 17:12:03 -0700
From: gerg@ncal.verio.com (Greg Andrews)
Subject: Re: Matts Script Archive - A critique
Message-Id: <8l84gj$snl$1@ncal.verio.com>
"Godzilla!" <callgirl@la.znet.com> writes:
>Richard Lawrence wrote:
>
>> His are some of the most widely used (and critisised). Using some
>> obscure script written by someone who no-one has heard of would also
>> work, but probably wouldn't have quite the same impact.
>
>
>So your opinion is people will learn Perl programming
>better by selecting the scripts of only one person for
>critique?
>
Richard never said *only* Matt's scripts. You were the
one who said that. Twice.
Richard very clearly said that Matt's scripts qualify
because they're widely known.
I further submit that Matt's scripts qualify because
they contain good examples of newbie mistakes.
A critique of them would be understood by a wide range
of Perl script users, and would reveal how novice code
practices can be inefficient, prone to error, and be
vulnerable to attack from malicious fiends.
>
> This suggests other scripts which exemplify
>well a common problem should be ignored because these
>scripts are not written by the 'right' author.
>
Only you have said so. Do you want the group to critique
your scripts as well as Matt's? I'm sure a number of folks
would be willing.
>
>Why not scripts written by Selena Sol, Tim Ziegler,
>Brian Selensky as well? Seems Steve Brenner is quite
>famous. His libraries are critiqued here more often
>than Matt's scripts. Why not Brenner as well?
>
No one has said so except you. You write very passionately
about criticizing Selena's, Tim's, and Brian's code. Are
you perhaps volunteering your time and experience to fill
the need you've pointed out so clearly?
>
>Is your objective to learn Perl better or to target
>a specific person for critique? If our Perl community
>selects only one person for critique, wouldn't this
>suggest perhaps some bigotry amongst those of us
>populating our Perl community?
>
As I've pointed out above, you and only you have stated
that the proposed critique would be limited to Matt's
scripts.
If such a limitation suggests bigotry, the inescapable
conclusion is that the bigotry lives within your heart,
Godzilla. Thank you for your hatred.
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: Thu, 20 Jul 2000 15:37:01 -0700
From: sysnovice <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid>
Subject: Re: New to Perl, How to call script and check when finished?
Message-Id: <0377f9e5.b7c98bd9@usw-ex0109-068.remarq.com>
Thank You Drew. I'm just a bit intimidated starting out.
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Thu, 20 Jul 2000 22:24:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <dvuens4b2lalg2fl6jpu6k44mdku9od65v@4ax.com>
Robert White wrote:
>>However "AI::NeuralNet::BackProp" does seem appropriate, conveys the
>>proper imagery, and takes some of the work out of it :D *duck*
>
> could shorten that Just a bit to NNet, which shouldn't confuse
>anyone particularly.
"neural" is the most important word in the module's proposed name.
Surely, you don't want to shorten that?
--
Bart.
------------------------------
Date: 20 Jul 2000 17:30:39 -0700
From: gerg@ncal.verio.com (Greg Andrews)
Subject: Re: NFS Client in perl?
Message-Id: <8l85jf$lm$1@ncal.verio.com>
Otis Gospodnetic <otis@my-deja.com> writes:
>
>I need to be able to check whether a remote NFS server is up and
>whether the local machine has certain partitions from that NFS server
>mounted.
>
>I know I could probably try talking to nfsd over a socket and that I
>could probably try checking if some file that is on the mounted
>partition exist, but that doesn't look like the prettiest solution.
>
>I searched for 'NFS' at http://search.cpan.org/ but found nothing.
>
>Is there no perl NFS module or something such?
>
A module that implements a filesystem? That would be pretty
complex.
I solved the problem you describe by running the Unix df -k command
on the filesystem in question. Because df can freeze if the NFS
server is not responding, I ran df as a forked process, with the
main part of the script on a 20 second timeout. If df hadn't
given me its output after 20 seconds, I logged a message that
the NFS server wasn't responding and exited.
On the other hand, showmount might do better than df if it doesn't
hang because the NFS server isn't responding.
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: 21 Jul 2000 00:10:26 GMT
From: robert@goff.com (Robert Goff)
Subject: Re: NT4 can't create file in cgi-bin
Message-Id: <8l84di$b5o$0@207.66.2.173>
hacktic@my-deja.com wrote in <8l22u9$9f$1@nnrp1.deja.com>:
>I think I found out what went wrong ... it has something to do with
>virtual directories. Every time I run a Perl script from the scripts
>directory (named 'cgi-bin'), it acts as if its ran from the root
>directory and I would need to specify 'cgi-bin\\test.txt' if I needed
>to create a file in the cgi-bin directory.
This is a known IIS "feature". You should never assume that you know the
current working directory your CGI programs start in.
--
Clones are people, two.
===============================================
Robert Goff beast@avalon.albuquerque.nm.us
Technical Writer/Editor, Webmaster 505-564-8959
------------------------------
Date: Thu, 20 Jul 2000 23:09:23 GMT
From: i_am_leo@my-deja.com
Subject: Re: perl-5.6.0: Bug with "not" operator?
Message-Id: <8l80qu$bt0$1@nnrp1.deja.com>
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> i_am_leo@my-deja.com wrote in comp.lang.perl.misc:
> >
> >By the way, if perl5.6.0 always uses the concept
> >"if it looks like a function, it is a function",
> >then why don't these two expressions give the
> >same value for $a:
> >
> > $a = (1 || (0) , 2)
> > $a = (1 or (0) , 2)
>
> A binary operator does not look like a function, does it?
>
> --
> Rafael Garcia-Suarez
It's mighty hard to argue with that.
However, I still don't like the new behaviour of "not".
-Leo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 22:30:57 GMT
From: "Rick" <rcollins19@home.comNOSPAM>
Subject: Please help with my 1st attempt
Message-Id: <B4Ld5.77364$lU5.526789@news1.rdc1.nj.home.com>
Hello,
I am trying to excute my first perl script and am getting the error "CGIwrap
Error: User not found in passwd file." I have the permissions set to 751
Any help would be greatly appreciated.
Thans Rick
------------------------------
Date: Thu, 20 Jul 2000 15:02:34 -0700
From: jerry <honglan00NOhoSPAM@yahoo.com.invalid>
Subject: read system response in CGI
Message-Id: <12fb3fb7.7d85b01e@usw-ex0104-087.remarq.com>
Hi,
I want to invoke some programs through my website and show the
system response on the webpage too. In brief, I want to use the
webbrowser as a GUI to some of my programs. Is it possible? I can
invoke command like "ls", "cat". But I couldn't run my
shellscripts. I tried system() and open2().
Any idea? Thanks.
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Thu, 20 Jul 2000 15:12:53 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: read system response in CGI
Message-Id: <39777965.1F927A36@my-deja.com>
> I want to invoke some programs through my website and show the
> system response on the webpage too. In brief, I want to use the
> webbrowser as a GUI to some of my programs. Is it possible? I can
> invoke command like "ls", "cat". But I couldn't run my
> shellscripts. I tried system() and open2().
> Any idea? Thanks.
you can write a gateway program to do this. THe program
should present the user an entry form. Then the actual
program should get executed on the host and the o/p
should be captured. The captured result should be
HTMLized and sent to the browser.
------------------------------
Date: Thu, 20 Jul 2000 17:12:57 -0700
From: "Ken Barr" <kenneth.c.barr.nospam@intel.com>
Subject: READING hashes eats memory!?
Message-Id: <8l84he$96o@news.or.intel.com>
I have a huge hash-of-hash table (with 1st and 2nd level keys that are 32
bit ints, if that matters). It gets created in about 2-3 megs of memory...
When I start to access the table in a loop, however, memory usage
BALLOONS!!! Reading from the table once it exists in memory shouldn't
require more than one extra word of memory (which I would happily reuse each
iteration of the loop). How can I do:
foreach $src (keys(%src)){
foreach $dst (keys(%dst)){
$i=$cell{$src}{$dst}{packets}
}
}
without running out of memory? BTW, swapping the foreach/keys with
while/each doesn't help.
Thank you,
Ken
------------------------------
Date: Thu, 20 Jul 2000 19:20:29 -0500
From: firstname.lastname@nokia.com
Subject: Recursive subroutine output to recursive subroutine problem
Message-Id: <40BE1E900985F3A4.A8CC1CEC9929BE94.30DE00F808D376AA@lp.airnews.net>
Hello,
First off I'd like to thank anyone who takes the time to read this and
hopefully answer. I am somewhat new to scripting so please bear with
me.
Let me give you a quick overview. I use a product called Tivoli which
runs in UNIX and is generally command line driven. We use PERL
scripts to automate a lot of the functions. Tivoli behaves a lot like
a directory tree in that a region will have sub regions and so forth.
I've created a script that will recursively go through each region and
their subregions. At each region (sub or top level) must check for
some other information and if is exists I need to start at that point
and recursively do through any and all sub regions.
I've got the script working the way that I want except for the point
where the second element in the subroutines is passed to the second
subroutine. The first time works perfect, the second time the second
element processed in the first subregion is passed to the second
subregion. When the second subregion processes it it now contains
information from the first time plus this second time. I want to have
the second subregion flush its information before the next element is
passed to it and only deals with that current information.
I hope that this is making sense and here is a sample of the code and
what I'm trying to do. Sorry about the length.
-------------
#!/etc/Tivoli/bin/perl
#####
# Global Variable Declarations
# Enter in the starting policy region in the pr string.
#####
$verbose = 1;
$pr = "PR_Config_AMER_AJ";
#open (TMP, ">>/tmp/chk_pms.tmp");
#&main_regions($pr);
&transvers_pr($pr);
#####
# Break down of the starting top level into local regions.
#####
sub main_regions {
local($pr) = @_;
local($oid, $label, $record) = "";
local(@contents,) = ();
@contents = `wls -l /Library/PolicyRegion/\'$pr\'`;
chop(@contents);
foreach $record(@contents) {
($oid, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&transvers_pr($label);
}
}
}
#####
# Transverse the regions that were created in the sub main_regions
# 'walking down' all sub regions.
#####
sub transvers_pr {
local($pr) = @_;
local($oid, $label, $record) = "";
local(@contents,) = ();
@contents = `wls -l /Library/PolicyRegion/\'$pr\'`;
chop(@contents);
foreach $record(@contents) {
($oid, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&chk_sub_pr($label);
}
}
}
#####
# Checks current policy region for a sub policy region. If there is
# it will then check for the existence of a profile manager, creating
# on if needed or verifying the information.
#####
sub chk_sub_pr {
local($sub_pr) = @_;
local($test) = "";
print "Currently working in $sub_pr.\n" if($verbose);
$test = `wls -l /Library/PolicyRegion/\'$sub_pr'`;
chop($test);
if ($test =~ /TMF_PolicyRegion::GUI/) {
if(&chk_pms($sub_pr)) {
print "\tPMS found. Verifying subscribers...\n" if($verbose);
&verify_pms($sub_pr);
} else {
print "\tPMS not found. Creating PMS...\n" if($verbose);
&create_pms($sub_pr);
}
} else {
print "\tPMS is not needed at this level.\n"if($verbose);
&transvers_pr($sub_pr);
}
}
#####
# Checks current policy region for a profile manager.
#####
sub chk_pms {
local($chk_pr) = @_;
local($test, $return, $pm) = "";
local($true) = 1;
local($false) = 0;
$pms = $chk_pr;
$pms =~ s/^PR_/PMS_/;
$test = `wlookup -r ProfileManager \"$pms\" 2>/dev/null`;
if ($test) {
$return = $true;
} else {
$return = $false;
}
$return;
}
#####
# Creates a PMS in the current policy region.
#####
sub create_pms {
local($crt_pr) = @_;
local($pms) = "";
$pms = $crt_pr;
$pms =~ s/^PR_/PMS_/;
`wcrtprfmgr \@PolicyRegion:$crt_pr $pms`;
print "\t$pms was created in $crt_pr. Verifying subscribers...\n"
if($verbose);
&verify_pms($crt_pr);
}
#####
# Verifying PMS subscribers and all DPMS. Adding DPMS to PMS if
needed # and removing DPMS from PMS if no longer available.
#####
sub verify_pms {
local($vfy_pr) = @_;
local($dpms, $cs_dpms) = "";
local(@current_dpms, @current_subscribers) = ();
local(@new_subscribers, @old_subscribers) = ();
$pms = $vfy_pr;
$pms =~ s/^PR_/PMS_/;
### At this point the information is passed to the sub region
### Every time information is passed to it, the sub region
### need to treat it as completely new information and not
### accumulative from previous processes.
@current_dpms = &get_dpms_list($vfy_pr);
@current_subscribers = `wgetsub \@ProfileManager:\"$pms\"`;
chop(@current_subscribers);
foreach $dpms(@current_dpms) {
if(!grep(/^$dpms/, @current_subscribers)) {
push(@new_subscribers, $dpms);
print "\tSubscribe $dpms to $pms\n" if($verbose);
}
}
foreach $cs_dpms(@current_subscribers) {
if(!grep(/^$cs_dpms/, @current_dpms)) {
push(@old_subscribers, $cs_dpms);
print "\tUnsubscribe $cs_dpms from $pms\n" if($verbose);
}
}
if(@old_subscribers){
$uncmd = "wunsub \@ProfileManager:\"$pms\" ";
foreach $cs_dpms (@old_subscribers){
$uncmd .= "@ProfileManager:\"$cs_dpms\" ";
}
#print "$uncmd\n" if($verbose);
`$uncmd`;
}
if(@new_subscribers){
$cmd = "wsub \@ProfileManager:\"$pms\" ";
foreach $dpms (@new_subscribers){
$cmd .= "@ProfileManager:\"$dpms\" ";
}
#print "$cmd\n" if($verbose);
`$cmd`;
}
$test = '&get_dmps_list';
$test = "";
@current_dpms =();
&transvers_pr($vfy_pr);
}
#####
# Every time this subregion is accessed it will add the new
information # to the old. Instead I need this to be flushed and treat
each
# call to it as a new process to get information.
#####
#####
#Gets a list of DMPS starting at the current policy region and all
# sub-regions.
#####
sub get_dpms_list {
local($get_pr) = @_;
local($oid, $label, $record) = "";
local(@contents) = ();
@contents = `wls -l /Library/PolicyRegion/\'$get_pr'`;
chop(@contents);
foreach $record(@contents) {
($oid, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&get_dpms_list($label);
} elsif (($oid =~ /TMF_CCMS::ProfileManager/) && ($label =~
/^DPMS_/)) {
push(@dpms, $label);
#print "@dpms\n";
}
}
return @dpms;
}
BTW for some reason I'm not able to use the my() operator. Every time
I try to execute the script with a my () the script will fail at that
point. This is something completely different to my problem listed
above but I just want you to be aware of it.
Thanks for any assistance that you can provide on this.
Jack Anger
Nokia Inc.
---
If you wish to reply by email in order to combat spamming, please take
my <first name>.<last name> and add @nokia.com
------------------------------
Date: Thu, 20 Jul 2000 19:20:29 -0500
From: firstname.lastname@nokia.com
Subject: Recursive subroutine output to recursive subroutine problem
Message-Id: <40BE1E900985F3A4.A8CC1CEC9929MRV?R8JGE00F808D376AA@lp.airnews.net>
Hello,
First off I'd like to thank anyone who takes the time to read this and
hopefully answer. I am somewhat new to scripting so please bear with
me.
Let me give you a quick ovS@W"0SZO I use a product called Tivoli which
runs in UNIX and is generally command line driven. We use PERL
scripts to automate a lot of the functions. Tivoli behaves a lot like
a directory tree in that a region will have sub regions and so forth.
I've created a script that will recursively go through each region and
their subregions. At each region (sub or top level) must check for
some other information and if is exists I need to start at that point
and recursively do through any andR+:(_!M. regions.
I've got the script working the way that I want except for the point
where the second element in the subroutines is passed to the second
subroutine. The first time works perfect, the second time the second
element processed in the first subregion is passed to the second
subregion. When the seU-@CZ="Iregion processes it it now contains
information from the first time plus this second time. I want to have
the second subregion flush its information before the next element is
passed to it and only deals with that current information.
I hope that this is making sense and here is a sample of the code andP&+HC
Mm trying to do. Sorry about the length.
-------------
#!/etc/Tivoli/bin/perl
#####
# Global Variable Declarations
# Enter in the starting policy region in the pr string.
#####
$verbose = 1;
$pr = "PR_Config_AMER_AJ";
#open (TMP, ">>/tmp/chk_pms.tmp");
#&main_regions($pr);
&transvers_pr($pr)
MK_]B>##
# Break down of the starting top level into local regions.
#####
sub main_regions {
local($pr) = @_;
local($oid, $label, $record) = "";
local(@contents,) = ();
@contents = `wls -l /Library/PolicyRegion/\'$pr\'`;
chop(@contents);
foreach $record(@contents) {
($oid, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&transvers_pr($label);
}
}
}
#####
# Transverse the regio&%X5
MUwere created in the sub main_regions
# 'walking down' all sub regions.
#####
sub transvers_pr {
local($pr) = @_;
local($oid, $label, $record) = "";
local(@contents,) = ();
@contents = `wls -l /Library/PolicyRegion/\'$pr\'`;
chop(@contents);
foreach $record(@contents) {
M^2$2E(id, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&chk_sub_pr($label);
}
}
}
#####
# Checks current policy region for a sub policy region. If there is
# it will then check for the existence of a profile manager, creating
# on if need^S2!=%)<rifying the information.
#####
sub chk_sub_pr {
local($sub_pr) = @_;
local($test) = "";
print "Currently working in $sub_pr.\n" if($verbose);
$test = `wls -l /Library/PolicyRegion/\'$sub_pr'`;
chop($test);
if ($test =~ /TMF_PolicyRegion::GUI/) {
if(&chk_pms($subO2`XC9).
print "\tPMS found. Verifying subscribers...\n" if($verbose);
&verify_pms($sub_pr);
} else {
print "\tPMS not found. Creating PMS...\n" if($verbose);
&create_pms($sub_pr);
}
} else {
print "\tPMS is not needed at this level.\n"if($verbose);
&transvers_pr($sub_pr);
}
}
#####
# Checks current policy region for a profile manager.
#####
sub chk_pms {
local($chk_pr) = @_;
local($test, $return, $pm) = +!,KXZFlocal($true) = 1;
local($false) = 0;
$pms = $chk_pr;
$pms =~ s/^PR_/PMS_/;
$test = `wlookup -r ProfileManager \"$pms\" 2>/dev/null`;
if ($test) {
$return = $true;
} else {
$return = $false;
}
$return;
}
#####
# Creates a PMS in the current policy regio36
M,NF#
sub create_pms {
local($crt_pr) = @_;
local($pms) = "";
$pms = $crt_pr;
$pms =~ s/^PR_/PMS_/;
`wcrtprfmgr \@PolicyRegion:$crt_pr $pms`;
print "\t$pms was created in $crt_pr. Verifying subscribers...\n"
if($verbose);
&verify_pms($crt_pr);
}
#####
# Verifying PMS s02RMNYP?rs and all DPMS. Adding DPMS to PMS if
needed # and removing DPMS from PMS if no longer available.
#####
sub verify_pms {
local($vfy_pr) = @_;
local($dpms, $cs_dpms) = "";
local(@current_dpms, @current_subscribers) = ();
local(@new_subscribers, @old_subscribers) = ();
$pms = $vfy_PD2L#?T8$pms =~ s/^PR_/PMS_/;
### At this point the information is passed to the sub region
### Every time information is passed to it, the sub region
### need to treat it as completely new information and not
### accumulative from previous processes.
@current_dpms = &get_dpms_list($vfy_pr);
@current_subscribers = `wgetsub \@ProfileManager:\"$pms\"`;
chop(@current_subscribers);
foreach $dpms(@current_dpms) {
if(!grep(/^$dpms/, @current_subscribers)) {
%R%OA*R)ew_subscribers, $dpms);
print "\tSubscribe $dpms to $pms\n" if($verbose);
}
}
foreach $cs_dpms(@current_subscribers) {
if(!grep(/^$cs_dpms/, @current_dpms)) {
push(@old_subscribers, $cs_dpms);
print "\tUnsubscribe $cs_dpms from $pms\n" if($verbose);
49^T6
M}
if(@old_subscribers){
$uncmd = "wunsub \@ProfileManager:\"$pms\" ";
foreach $cs_dpms (@old_subscribers){
$uncmd .= "@ProfileManager:\"$cs_dpms\" ";
}
#print "$uncmd\n" if($verbose);
`$uncmd`;
}
if(@new_subscribers){
$cmd = "w
MJ\)A+ofileManager:\"$pms\" ";
foreach $dpms (@new_subscribers){
$cmd .= "@ProfileManager:\"$dpms\" ";
}
#print "$cmd\n" if($verbose);
`$cmd`;
}
$test = '&get_dmps_list';
$test = "";
@current_dpms =();
&transvers_pr($vfy_pr);
}
#####
# Every ti=C:)2@J.subregion is accessed it will add the new
information # to the old. Instead I need this to be flushed and treat
each
# call to it as a new process to get information.
#####
#####
#Gets a list of DMPS starting at the current policy region and all
# sub-regions.
#####
sub get_dpms_list {
local($get_pr) = @_;
local($oid, $label, $record) = "";
local(@contents) = ();
@contents = `wls -l /Library/PolicyRegion/\'$get_pr'`;
chop(@contents);
foreach $recor
M'TH5%Wnts) {
($oid, $label) = split(/\s+/, $record, 2);
if ($oid =~ /TMF_PolicyRegion::GUI/) {
&get_dpms_list($label);
} elsif (($oid =~ /TMF_CCMS::ProfileManager/) && ($label =~
/^DPMS_/)) {
push(@dpms, $label);
#print "@dpms\n";
}
}
return @.1,)@#!8
BTW for some reason I'm not able to use the my() operator. Every time
I try to execute the script with a my () the script will fail at that
point. This is something completely different to my problem listed
above but I just want you to be aware of it.
Thanks for any assistance that you can provide<%BH!,.V.
Jack Anger
Nokia Inc.
---
If you wish to reply by email in order to combat spamming, please take
my <first name>.<last name> and add @nokia.com
------------------------------
Date: Thu, 20 Jul 2000 15:30:37 -0700
From: "Michael Cook" <mikecook@dcranch.com>
Subject: Re: SSI - Stink like poo?
Message-Id: <uRMd5.911$WU5.219572@news.uswest.net>
I've had to use <!--#exec virtual="/cgi-bin/helloworld.cgi" --> to make this
work...
Michael
"Glen Heide" <jheide@sprint.ca> wrote in message
news:2Nvd5.12502$_J1.148223@newscontent-01.sprint.ca...
> I wrote a little CGI script which simply prints to the standard output
> "Hello", and the SHTML file that I use has the contents as follows:
> <TABLE><TR><TD><!--#exec
cgi="/cgi-bin/helloworld.cgi" --></TD></TR></TABLE>
>
> The resulting HTML file that the server returns has nothing from the CGI
> script. It only returns
> <TABLE><TR><TD></TD></TR></TABLE>
>
> I also tested it with a longer running script which reads 2 large files,
so
> I know they're being ran, but I still get no output. Do server side
include
> files do what I'm trying to do? (Print hello in the table) Or are they
> simply pieces of code to be "executed". Can anyone help? It would be
> greatly appreciated.
>
> --
> Yours Truly,
> Glen Heide
>
>
>
------------------------------
Date: Thu, 20 Jul 2000 19:17:30 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Suggestion for syntax change
Message-Id: <3977969A.E9DFC550@mindspring.com>
jason wrote:
>
> Bart Lateur wrote ..
> >jason wrote:
> >
> >>would there be many (any?)
> >>situations where you'd be interested in going from index (x) to index
> >>(Z-y) (where Z represents the length of the unknown LIST) ??
> >
> >Try skipping the first 2 items.
> >
> > @rest = @somelist[2 .. -1];
> >
> >If you're talking about dropping a few items at the end: indeed, that
> >would be rare.
>
> that's an array .. not an unknown list .. you could just do
>
> @rest = @somelist[2..$#somelist];
>
> but .. assuming you meant @somelist to represent an unknown LIST .. then
> that's not enough of an example
>
> I mean a real situation where you don't know the length of the list - or
> how many items will be in it .. when would you want everything relative
> to the end of an unknown list ??
>
> I can think of HEAPS of situations in named LISTs (arrays) where you'd
> want the last x elements .. or all but the first two elements .. but
> those situations are already handled with $# (as in the example above)
>
> I still contend that (LIST)[2..-1] should equate to (LIST)[2,1,0,-1] ..
> and 2..-1 should equate to (2,1,0,-1)
>
This is really nicely ambiguous, isn't it? When [-1] means the last
element, should 0..-1(last) mean a decrementing series? Seems a bit
counterintuitive.
Sorry, can't get back to this fascinating topic until Tuesday. Don't
modify the language 'til I'm back. :-b
------------------------------
Date: Thu, 20 Jul 2000 22:34:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Understanding Perl Idiom (Please Help)
Message-Id: <8cvens0ae6h8q8asrjcn5oetriaodlrbpc@4ax.com>
kenlaird@my-deja.com wrote:
>#!/usr/bin/perl -w
>@a=`ps -edf`;
>foreach (@a) {
>if (/ftp/) {
>print ;
>}
>}
Print each line in the output which contains the string "ftp". The
"foreach (@a) BLOCK" goes through all the lines (in @a), the "if(/ftp/)
BLOCK" executes the print() only if the test /ftp/ succeeds.
Here's another version:
print grep /ftp/, `ps -edf`;
--
Bart.
------------------------------
Date: Fri, 21 Jul 2000 01:51:56 +0000
From: rhys <rhys.tucker@dtn.ntl.com>
Subject: Why does this reverse() not work???
Message-Id: <3977ACBC.7E8EAFB3@dtn.ntl.com>
You may recognise this as an example from Learning Perl. The reverse()
refuses to operate for me (running RedHat 6.2, kernel-2.2.14-6.1.1,
perl-5.00503-10).
#!/usr/bin/perl -w
print "Enter the list of strings \n";
@list = <STDIN>;
@reversed = reverse(@list);
print @reversed;
------------------------------
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 3762
**************************************