[7388] in Perl-Users-Digest
Perl-Users Digest, Issue: 1013 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 11 19:07:15 1997
Date: Thu, 11 Sep 97 16:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 11 Sep 1997 Volume: 8 Number: 1013
Today's topics:
Re: A simpler perl question. <aaron@soltec.net>
Add elements to %hash (Jan Gruber)
Re: Add elements to %hash (John Dallman)
Re: Add elements to %hash (John Dallman)
Re: Add elements to %hash <arnej@fc.hp.com>
Re: backreferences and /i in regex (Ilya Zakharevich)
Execution speed, looping <stevearm@ix.netcom.com>
Re: Execution speed, looping <doug@tc.net>
Re: flock in Win32? <camerond@mail.uca.edu>
Re: Getting started with ODBC.pm on MSsql6.5 (Parillo)
Re: grepping for parens (Andrew M. Langmead)
Help with Perl <dana@wicksend.com>
Re: How to connect to Oracle database <amit@csd.sgi.com>
Re: How to email text file (Gerry Buzzell)
Re: Limits in Perl 5 on array sizes ??? <rjo100@york.ac.uk>
Re: Loading modules or subroutines at execution (Mike Stok)
Re: manipulating chars inside strings? (Tad McClellan)
Re: NET::NNTP Woes <blb@fedex.com>
Re: Perl DBM file (Rex Fowler)
Re: Perl on SunOS question (Mike Stok)
Re: pipe in the mailer <rjo100@york.ac.uk>
Problem importing vars from package <foo@bar>
Re: Problem importing vars from package <fawcett@SPAMLESS.nynexst.com>
Problem with a printer -- and maybe a perl monitor demo <cknox@crl.crl.com>
Re: Problems using typeglobs to export arrays (Andrew M. Langmead)
script to change htpasswd (William Hall)
send values from form, read html result, not display it <jaydee@worsdall.demon.co.uk>
Re: Strip spaces in filenames (John L. Allen)
Three questions related to SNMP, external task handling (Christian Dinten)
Re: where's gunzip and tar for dos/win? <rjo100@york.ac.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Sep 1997 20:14:08 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Re: A simpler perl question.
Message-Id: <01bcbeef$423286c0$b5910a9f@aurora.cna.com>
I have been reading this with interest
and learned a bit as well
but my question
along these same lines
is
how do you get it to spit out the file names recursively
What I have (using the knowledge gained here) is a listing of the files in
that directory but I also want a listing of allt he files below the
directories, etc.
Ritchard Shadian <rshadian@hawaii.edu> wrote in article
<Pine.GSO.3.95q.970909161209.15260A-100000@uhunix1>...
> Another really easy UNIX way is:
>
> chop(@files = `ls mydirectory`)
> foreach $file (@files) {..};
> --
> Ritchard
>
> On 6 Sep 1997, OrdwayNet Webmaster wrote:
>
> > I have a directory full of files. Lets say that I want to add
something to
> > each one of those files. How would I do it?
> >
> > I think it would be something like this, but it isn't enough-
> >
> > foreach $file
> >
> > print "bla bla"\n";
> >
> > How do I make $file mean every file in the dir.
>
>
>
------------------------------
Date: Thu, 11 Sep 1997 19:43:07 GMT
From: jgr@tpnet.de (Jan Gruber)
Subject: Add elements to %hash
Message-Id: <341848d2.1178563@eunetnews.germany.eu.net>
Hi all !
How do i push new elements to this %hash.
%hash ( user => password);
push %hash, ($user,$password) doesnt work
The compiler complains with: type of arg .....
I have tried several versions, nothing worked.
i did RTFM and lots of books, didnt find anything.
TIA
Jan
------------------------------
Date: 11 Sep 1997 21:49:14 GMT
From: jgd@cix.co.uk (John Dallman)
Subject: Re: Add elements to %hash
Message-Id: <memo.19970911224233.20367A@jgd.compulink.co.uk>
In article <341848d2.1178563@eunetnews.germany.eu.net>, jgr@tpnet.de (Jan
Gruber) wrote:
> How do i push new elements to this %hash.
> %hash ( user => password);
> push %hash, ($user,$password) doesnt work
You can't. Push, pop, shift and unshift are not a meaningful concepts on
hashes. Hashes don't have an ordering for those functions to put elements
onto the ends of. You can add elements to a hash with
$hash{$user}=$password;
and remove them with
delete( $hash{$user});
---
John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked:
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for
NT/Win 95 can be found at http://www.activeware.com, with an excellent FAQ
file at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
and no, I don't have the slightest idea what's wrong with your CGI script.
Try http://www.perl.com/perl/faq/idiots-guide.html
------------------------------
Date: 11 Sep 1997 22:05:08 GMT
From: jgd@cix.co.uk (John Dallman)
Subject: Re: Add elements to %hash
Message-Id: <memo.19970911225815.2175A@jgd.compulink.co.uk>
In article <341848d2.1178563@eunetnews.germany.eu.net>, jgr@tpnet.de (Jan
Gruber) wrote:
> How do i push new elements to this %hash.
> %hash ( user => password);
> push %hash, ($user,$password) doesnt work
You can't. Push, pop, shift and unshift are not a meaningful concepts on
hashes. Hashes don't have an ordering for those functions to put elements
onto the ends of. You can add elements to a hash with
$hash{$user}=$password;
and remove them with
delete( $hash{$user});
---
John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked:
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for
NT/Win 95 can be found at http://www.activeware.com, with an excellent FAQ
file at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
and no, I don't have the slightest idea what's wrong with your CGI script.
Try http://www.perl.com/perl/faq/idiots-guide.html
------------------------------
Date: Thu, 11 Sep 1997 16:37:06 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
To: Jan Gruber <jgr@tpnet.de>
Subject: Re: Add elements to %hash
Message-Id: <34187292.114C@fc.hp.com>
Jan Gruber wrote:
> Hi all !
> How do i push new elements to this %hash.
> %hash ( user => password);
> push %hash, ($user,$password) doesnt work
> The compiler complains with: type of arg .....
Well, my first reaction is, since "push" is a stack
operation, why are you trying to use a hash as a
stack (seems like it wouldn't work...)
So, to answer your question, I'd do something
wacky like:
$hash{$user} = $password;
Hope this helps!
Arne
------------------------------
Date: 11 Sep 1997 19:14:37 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: backreferences and /i in regex
Message-Id: <5v9fut$ma6@agate.berkeley.edu>
In article <slrn61fd7s.itu.tom@mitra.phys.uit.no>,
Tom Grydeland <tom@mitra.phys.uit.no> wrote:
> > You can have both with the RE jumbo patch (should be merged in some
> > numbered Perl version some time very soon).
> > /(?i)(friend)\s+\1/; # Gives 2 now and later
> > /((?i)friend)\s+\1/; # Undefined now (and gives 2),
> > # later will give 1
>
> Are you telling me that ((?i)re) means/will mean case insensitivity for
> just a part of a pattern?
Yes.
> Interesting. Will the same apply to
> ((?m)re), ((?s)re) etc?
I would not be sure until the test suite contains a test. Care to
contribute a couple? Looks like "a simple one" t/op/regexp.t cannot
deal with multiline strings, so it should be of standard style,
cmp. t/op/pat.t.
But the intention was for these to work.
Ilya
------------------------------
Date: Thu, 11 Sep 1997 15:13:37 +0100
From: "stevearm@ix.netcom.com" <stevearm@ix.netcom.com>
Subject: Execution speed, looping
Message-Id: <3417FC91.29053F77@ix.netcom.com>
Loops in perl seem to run much slower than in C. This
for loop: for ( $i=0;$i<10000000;$i++) { } takes over
20 seconds to run on a pentium II. In C it takes less than
a second. There seems to be even more difference on a
sparcII. The C code runs about the same, and after letting
the perl code run for over a minute, I hit ctrl-c.
Is there really this much difference? Is there a way to make
loops run faster in perl. I was hoping to port all of my C++
programs to perl. I could stand a 20-50% hit in performance,
but not this much. Any ideas? Thanks
------------------------------
Date: 11 Sep 1997 16:16:12 -0400
From: Douglas McNaught <doug@tc.net>
To: "stevearm@ix.netcom.com" <stevearm@ix.netcom.com>
Subject: Re: Execution speed, looping
Message-Id: <m2202vmws3.fsf@ono.tc.net>
[mailed and posted]
"stevearm@ix.netcom.com" <stevearm@ix.netcom.com> writes:
> Loops in perl seem to run much slower than in C. This
> for loop: for ( $i=0;$i<10000000;$i++) { } takes over
> 20 seconds to run on a pentium II. In C it takes less than
> a second. There seems to be even more difference on a
> sparcII. The C code runs about the same, and after letting
> the perl code run for over a minute, I hit ctrl-c.
>
> Is there really this much difference? Is there a way to make
> loops run faster in perl. I was hoping to port all of my C++
> programs to perl. I could stand a 20-50% hit in performance,
> but not this much. Any ideas? Thanks
This is a pretty useless benchmark. There's a lot more loop overhead
in Perl, true. But if you're doing real work, the loop overhead is
generally not a big issue, especially if you're reading a file and
spending most of your wall time waiting for disk i/o. If you're
writing numerical analysis code, stick to C++ for sure; otherwise Perl
may very well fill your needs. Without knowing what your code does
it's hard to say how big a performance hit you will take.
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: Thu, 11 Sep 1997 16:45:31 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: flock in Win32?
Message-Id: <3418667A.9DC8B8DA@mail.uca.edu>
Petri Backstrom wrote:
> Cameron Dorey wrote:
> >
> > Is there any way to simulate/substitute/work around the flock()
> function
> > in Win32 Perl? <snip>
> flock() most definitely is "there" on Win32 (at least on
> Windows NT).
>
> If it isn't "there" for you (or the Perl release you happen
> to have - did you try? ;-), then get a newer release:
>
> The ActiveState/ActiveWare port known as Perl for Win32:
>
> http://www.activestate.com
>
> The "core" Perl release/build for Win32 platforms:
>
> http://www.perl.com
>
> regards,
> ...petri.backstrom@icl.fi
> ICL Data Oy
> Finland
Petri, I'm using Sarathy's port 5.004.01, not the ActiveState port
(5.3-whatever). But, Im using a Win95 machine, not WinNT, and this
apparently makes the difference. (program gives a message similar to
"flock() not implemented in this installation(?)".
Stuart, I'm now trying a semaphore (flag) file, and I get over this
problem.
Unfortunately, I'm modifying somebody else's script and, from further
troubles down the line, it appears that there must be some other file
handling commands that are not implemented in PerlWin32 on a Win95
machine (which are valid on a WinNT machine, but do not give me errors).
Does anyone know of a list of unsupported functions in PerlWin32
specifically for a Win95 box?
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: 11 Sep 1997 19:12:03 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: Getting started with ODBC.pm on MSsql6.5
Message-Id: <5v9fq3$cr0$1@news01.li.net>
Have you checked out:
http://www.roth.net/odbc/odbcfaq.htm
I found it very helpful.
lparillo at suffolk dot lib dot ny dot us
: Danny Aldham wrote:
: >
: > I have installed activewares perl and the ODBC.pm module onto a NT4
: > machine running SQL6.5 . I seem to be able to connect to the database
: > using the test.pl program; it passes the tests and finds the tables.
: > But that is a far as I get. I cannot figure out the syntac to do my
: > own sql queries. Simple things like create a table, alter a table, or
: > insert data into the table. Then maybe do a Query on a column. If someone
: > has some simple sample code, it would be very much appreciated.
: >
: > --
: > Danny Aldham SCO Ace , MCSE , JAPH , DAD
: > I don't need to hide my e-mail address, I broke my sendmail.
------------------------------
Date: Thu, 11 Sep 1997 21:25:58 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: grepping for parens
Message-Id: <EGD4vB.9uu@world.std.com>
"Jeremy L. Mordkoff" <jom@net1plus.com> writes:
> if ( $team ) {
> $team =~ s/\(/\\\(/g;
> $team =~ s/\)/\\\)/g;
> }
>so that "Merrimac (MA)" would become "Merrimac \(MA\)" but this did not
>help. Is there a simple way to turn off ()'s in a search?
That should have done it, although the "\Q" (quote, or disable special
regular expression metacharacters) and "\E" (end quoting)
metacharacters are more general purpose.
if($team && $team =~ /\b\Q$team\E\b/)
--
Andrew Langmead
------------------------------
Date: Thu, 11 Sep 1997 14:22:19 -0600
From: Dana Blunt <dana@wicksend.com>
To: dana@wicksend.com
Subject: Help with Perl
Message-Id: <874004852.10271@dejanews.com>
I need to find someone who can convert a perl script that is written for
Webstar on the Mac over to something that will run on unix...The major
difference between this guestbook and most off the shelf guestbooks is
that it is inserting input from a form into more than one existing html
file at once...Does anyone know how to modify a guestbook to do this. If
you can help me please contact me at dana@wicksend.com.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 11 Sep 1997 15:25:54 -0700
From: amit kothari <amit@csd.sgi.com>
To: ishen@ciscorp.com
Subject: Re: How to connect to Oracle database
Message-Id: <34186FF2.E18422BD@csd.sgi.com>
Isabella Shen wrote:
>
> Hi,
>
> I don't know how to connect to Oracle database (7.3, SQL*Net 2.3) from
> Netscape Enterprise server 2.01 by perl? What is the connect string? I
> already installed the client communication software (SQL*Net 2.3) on the
> web server. What is the perl syntax for connection?
>
> Thank you very much.
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Isabella Shen Tel: (412) 787-9600 ex 125
> Email: ishen@ciscorp.com
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
U first need to install the DBI module and the oracle driver so that
u can connect to oracle from perl. follwo this link and read the
dbispec.V06
http://www.cs.ruu.nl/pub/PERL/perl5.0/CPAN/modules/dbperl/DBI
--
_______________________________________________________________________________
Truth is self-evident; nonviolence is its maturest fruit, it is
contained in Truth, but is not self-evident. - Gandhi
My Home Page: http://www.geocities.com/ResearchTriangle/4960/
_______________________________________________________________________________
------------------------------
Date: Thu, 11 Sep 1997 20:53:50 GMT
From: gbuzzell@hardlink.com (Gerry Buzzell)
Subject: Re: How to email text file
Message-Id: <341859f3.590027015@nntp.ne.mediaone.net>
gbuzzell@hardlink.com[Gerry Buzzell] wrote:
Here is another way to do it:
=========================
#!/usr/local/bin/perl
$mailprog = '/usr/lib/sendmail'; # or wherever your sendmail is
$to = 'who@where'; # the email address
$from = 'my@here'; # my email address
$me = 'my_name'; # my name
$file = 'file.txt'; # the file to send, including path
open (MAIL, "|$mailprog $to") || die "Can't open $mailprog!\n";
print MAIL "From: $me <$from>\n";
print MAIL "Subject: $file \n\n";
open(IN, "$file") || die ("Can't open $file");
while(<IN>){
print MAIL $_;
}
close (IN);
close (MAIL);
>Hello!
>
> All I want to do is to open a text file, read it's contents in and email
>it to an address that a person had entered on a form.
> I think I need an open and close statement and a while loop but all the
>possible examples that I've looked at always has a few bells or whistles
>extra that I haven't wanted.
> Please delete the ** from my address to reply. Anti-spam stuff.
>
> Thanks.
> Bud.
>
>--
>
>
>
>
------------------------------
Date: Wed, 10 Sep 1997 15:12:55 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Limits in Perl 5 on array sizes ???
Message-Id: <3416AAE7.B7C8A5B5@york.ac.uk>
James H. Blackwell wrote:
>
> Is there a limit on the size of a Perl array ?
AFAIK, there's no limit built into perl. The only limitations are
hardware limitations, ie how much memory you have.
HTH,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: 11 Sep 1997 19:09:47 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Loading modules or subroutines at execution
Message-Id: <5v9flr$6ld@news-central.tiac.net>
In article <3418224E.EF121558@fccc.edu>,
Lorna McLaughlin <L_McLaughlin@fccc.edu> wrote:
>Is there a way to not load a module or subroutine within a module until
>it is actually needed? This would reduce compile time. Or, is there
>anyway to use an if statement to selectively "require" a module only
>when needed?
Have you looked at the AutoLoader documentation? It starts out like
this:
NAME
AutoLoader - load subroutines only on demand
If you want to selectively require a module then I guess you could use
eval.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 11 Sep 1997 15:05:31 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: manipulating chars inside strings?
Message-Id: <bui9v5.k11.ln@localhost>
Yoav Zach (zachy@nite.org.il) wrote:
: Hi,
: Can anyone tell me how to manipulate single chars inside
: strings, something like 'str[j] = c;' in C?
$j = 3;
substr($str, $j, 1) = 'c';
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Sep 1997 15:42:31 -0600
From: Bryan Blackburn <blb@fedex.com>
Subject: Re: NET::NNTP Woes
Message-Id: <341865C7.3E8B@fedex.com>
Well, actually, not for the line I posted, but for what I was replying
to, which was,
$nntp = Net::NNTP->new( Debug );
Those statements are true (believe it or not, I did test it...) Unless,
I suppose, "Debug" is a valid hostname on someone's network, in which
case the -w may still not complain in Net::NNTP.
Bryan
Zenin wrote:
>
> Bryan Blackburn <blb@fedex.com> wrote:
> >snip<
> > Also, when you create $nntp, note that options follow the hostname in
> > the call to new, ie,
> > $nntp = Net::NNTP->new( 'news.ilk.com', Debug => 1 );
>
> > If you turn on warnings (-w switch) Net::NNTP should complain about a
> > bad hostname of "Debug".
> No, it won't.
>
> > Finally, "use strict;" would complain about Debug being a bare word.
> No, it won't. To quote the perlop man page:
>
> "The => digraph is mostly just a synonym for the comma
> operator. It's useful for documenting arguments that come
> in pairs. As of release 5.001, it also forces any word to
> the left of it to be interpreted as a string."
>
> Note the word "forces". It will pass use strict no problem.
>
> --
> -Zenin
> zenin@best.com
------------------------------
Date: 11 Sep 1997 13:49:15 -0500
From: rmfowler@raptor.mtc.ti.com (Rex Fowler)
Subject: Re: Perl DBM file
Message-Id: <5v9efb$5bs@raptor.mtc.ti.com>
In article <5v6a2t$bqf@lztnsc06.att.com>,
news_check.py <ltest@rte9-sun_5.5.1> wrote:
>In article <873828337.28334@dejanews.com> Irene Wu <irenewu@net.com> wrote:
>> Have anyone tried to copy a database from one format to another using
>> Perl? Due to the huge disk usage of my NDBM file, I need to convert it
>
I used the following to convert a ndbm file to berkeley db.
The same method should work for other conversions.
use POSIX;
use AnyDBM_File;
use DB_File;
tie %OLD, "NDBM_File", "/old/file", O_RDWR, 0644;
tie %NEW, "DB_File", "/new/file", O_CREAT|O_RDWR, 0644;
%NEW=%OLD;
>Irene Wu (irenewu@net.com)
>Network Equipment Technologies
--
Rex Fowler http://www.mtc.ti.com/~rmfowler
(972)997-2779 mailto:rmfowler@mtc.ti.com
Alpha Pager http://www.mtc.ti.com/cgi-bin/alpha_pager.cgi
TI MSG rfow
------------------------------
Date: 11 Sep 1997 18:59:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl on SunOS question
Message-Id: <5v9f1r$64h@news-central.tiac.net>
In article <3417fe3d.4170847@news.igs.net>,
William Wue(2xP)elma(2xN) <williamw@rooster.igs.deleteTheRooster.net> wrote:
>Okay, I admit it, I use Perl for Win32/95 (I have no choice). Maybe it
>has a few peculiarities, but I was trying to copy a script that works
>fine on Win95 to a SunOS platform, and I've been getting errors that
>seem quite bizarre. For example:
>
>chop($input = <STDIN>);
>works just fine, but
>
>chomp($input = <STDIN>);
>and
>@files = glob($input);
What version of perl are you running on the Sun? Use
perl -v
at the prompt, as perl 5.xxx introduced chomp as a keyword.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 11 Sep 1997 13:05:12 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: pipe in the mailer
Message-Id: <3417DE78.9A1B75B2@york.ac.uk>
Sascha Kerschhofer wrote:
>
> i can mail messages with the mailer by opening a filehandle.
> open (MAIL, "|usr/bin/mail asd@akjsd.net");
> then i am mailing the text with the print command. i print:
>
> From: myadress
> Subject: my sybject
> And here i am mailin the message
>
> but: how can i divide the header (subject, from..) from the message
> itself? if i do it in the way i showed, alle the message remains in
> the
> Subject when reading the mail in x-mailers like Eudora. is there any
> character which divides the header from the message?
Separate the header from the message body with a newline.
HTH,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: 11 Sep 1997 20:08:48 GMT
From: "Drew Marold" <foo@bar>
Subject: Problem importing vars from package
Message-Id: <01bcbeee$80ac4a40$456e4789@odessa>
I'm having a bit of a problem importing variables from a package I wrote in
to the namespace of my perl program, and I can't understand why.
Here's my package:
package Nmc;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(NMC Channel_List);
@Channel_List = ("17c", "18c", "19c", "20c", "21c", "17b");
$NMC = {
"17c.1" => 22.8620, "18c.1" => 7.5440, "19c.1" => 4.2780,
#lots more of these
};
Then my program uses it like this:
#!/usr/local/bin/perl
use lib "/usr/frobnitz1/perl/lib/site_perl"; #to find my stuff
use Nmc;
foreach $channel (@Channel_List)
{
print $channel, "\n";
}
print "17c.1 is ", $NMC->{"17c.1"}, "% of network\n";
#end
But it doesn't work this way. If I use @Nmc::Channel_List and $Nmc::NMC I
get the values. Why aren't they importing into my programs main namespace
?
As far as I can tell I'm doing exactly what they show in the Camel book.
I've also tried things like use Nmc qw(NMC Channel_List); but that doesn't
work either.
Any help would be greatly appreciated.
Drew
--
Drew Marold - Resident Mad Scientist - Andrew.Marold@Analog.com
Advanced Technology Group "Home of the Science Project"
Be an Uber, Not a Knave,
Nietzsche uses, Burma Shave
------------------------------
Date: 11 Sep 1997 17:30:56 -0400
From: Tom Fawcett <fawcett@SPAMLESS.nynexst.com>
Subject: Re: Problem importing vars from package
Message-Id: <8jpvqf7d2n.fsf@SPAMLESS.nynexst.com>
"Drew Marold" <foo@bar> writes:
> I'm having a bit of a problem importing variables from a package I wrote in
> to the namespace of my perl program, and I can't understand why.
> Here's my package:
>
> package Nmc;
> use Exporter;
> @ISA = qw(Exporter);
> @EXPORT = qw(NMC Channel_List);
>
> @Channel_List = ("17c", "18c", "19c", "20c", "21c", "17b");
>
> $NMC = {
> "17c.1" => 22.8620, "18c.1" => 7.5440, "19c.1" => 4.2780,
Try:
@EXPORT = qw($NMC @Channel_List);
Note the dollar and at signs. If you're exporting variables you have to
tell the exporter exactly what you're exporting, ie scalars vs arrays.
A bareword specifies a function.
And, eh, use a valid return address, mate.
-Tom
------------------------------
Date: 11 Sep 1997 21:45:23 GMT
From: Christopher W. Knox <cknox@crl.crl.com>
Subject: Problem with a printer -- and maybe a perl monitor demon
Message-Id: <5v9opj$5h4$1@nnrp1.crl.com>
We've been having a problem with print queues going to sleep -- the
demon is present, but nothing moves through the queue. So I exercised
my emerging perl skills on a little script that looks in a specific
queue directory for files tat are older than 10 minutes. If it finds
old files in that directory, the script stops lpsched, sleeps 30
seconds, and restarts it. It announces that it found old files by
sending mail to root. The script should then go to sleep for 10
minutes after which it should start up again. This time if it finds
files older than 20 minutes, it pages the oncall by sending a text
message to the mail alias "page<poor dude's name here>".
It appears that something is causing this script to get into a tight
loop. It sent a dozen mail messages, two per minute between 11:35 and
11:41 (AM, fortunately). And to top it off, the entire printer
configuration got trashed, every printer had to be replaced manually.
It looks like something it this script is very wrong, but I don't see
it. Appreciate a critique and/or pointers on HP's print spooler
(HP-UX 10.01, Network printers administered through Jet Direct, plus
two QMS network printers set up as remote).
#!/usr/bin/perl
# Monitor specific printers for stuck queues
$queuedir="/var/spool/lp/request/prnt1n1";
fork && exit;
while (true) {
opendir(QUEUEDIR,"$queuedir");
@queuelist=readdir (QUEUEDIR) ;
closedir(QUEUEDIR);
for (@queuelist){
open (Q,"$queuedir/$_");
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks)=stat(Q);
if ( /^\..*/){
true;
}
else {
if (time - $mtime > 1200) {
system("echo \"Printer `basename $queuedir` has jobs more than 20 minutes old.\"|mailx page`cat /usr/local/adm/.oncall`");
}
if (time - $mtime > 600) {
if (time - $mtime < 1200) {
system(" echo \"Printer `basename $queuedir` has jobs more than 10 minutes old.\nCycling print queue.\"|mailx -s 'Message from lp monitor' root");
system("lpshut;sleep 30;lpsched");
}
}
}
close Q;
}
sleep 600;
}
system("echo $0 exiting | mailx root");
exit 0;
--
Chris Knox | This .sig intentionally left blank
cknox@us.dhl.com |
(602) 350-2026 | My views only and always.
------------------------------
Date: Thu, 11 Sep 1997 21:20:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problems using typeglobs to export arrays
Message-Id: <EGD4M8.6CC@world.std.com>
Tony Kay <tonyk@nscedu.com> writes:
>which gives a compilation error on line 6: "In string, @arr must be
>written \@arr", which I don't want to do because I want to see the
>SPACE separated VALUE of the array, not a literal @arr.
In older versions of perl, the interpreter used to guess whether
"aml@world.std.com" meant a literal "@", "w", "o", "r","l","d", or the
interpolation of the array "@world". Now it always interpolates the
array.
The problem is, lots of old code assumed that "@world" would not be
interpolated if the array didn't exist, so perl now complains if it
doesn't see any mention of the array.
If you say:
use vars qw/@array/;
At the top of your script, then you give perl a hint that @array is
really an array. (Since you snuck it in behind its back though
typeglobbing)
--
Andrew Langmead
------------------------------
Date: Thu, 11 Sep 1997 20:19:27 GMT
From: st93yjls@dunx1.ocs.drexel.edu (William Hall)
Subject: script to change htpasswd
Message-Id: <9b7cd$f131b.1d4@XAVIER>
I'm trying to find a way to allow users to change their password for the
.htpasswd file from a web page. I'm new to perl and cgi and can't seem
to find an example, but I know it can be done. Please email the below
address. Thank you.
--
.......................................
William C. Hall
Email: st93yjls@dunx1.ocs.drexel.edu
Web: http://httpsrv.ocs.drexel.edu/undergrad/st93yjls
------------------------------
Date: Thu, 11 Sep 1997 22:48:04 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: send values from form, read html result, not display it?
Message-Id: <oQ0n0BAUcGG0Ew9M@worsdall.demon.co.uk>
Please forgive me for this one....
There is a certain service that allows one to pass it two values from a
form, it then generates a html page with the answer.
Using perl I want to call the script on the server, but instead of the
html page being displayed, I want to read it into memory, search for the
parts I want, and build my own page including the values returned from
the original page, then display them as an html page.
I know you are going to say it is rude not to ask etc. but hey, is it
possible?
--
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk WEB site:- http://www.shadow.org.uk
------------------------------
Date: 11 Sep 1997 15:40:21 -0400
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: Strip spaces in filenames
Message-Id: <5v9hf5$kda@gateway.grumman.com>
In article <Pine.SOL.3.95.970908085419.8011B-100000@shakti.cc.trincoll.edu>,
Mukund Rao <mrao@trincoll.edu> wrote:
>Many of my scripts & perl routines bomb out when it comes to
>(recursively) processing filenames/dirs that contain spaces or
>whitespace-chars in them. Attempting to '| tr " " "?"' doesn't solve the
>problem either. Has anyone come up with a workaround? How could I make
>this one work, for example? -->
>
>#!/bin/ksh
># find and replace all occurrences of $1 with $2
># from current directory onwards (ie. all files/subdirectories below)
>
>perl -pi -e 's/$1/$2/;' `find . -type f -print`
With perl it's easy
perl -pi -e 'BEGIN { chop(@ARGV=`find . -type f -print`) } s/foo/bar/'
John.
--
_/JohnL\_allen@gateway.grumman.com <Sun>: 9.5 billion pounds per sec to energy
~\Allen/~Fax: 516-575-7428 <Universe>: 1e22 stars = 22 solar masses per sec
------------------------------
Date: Thu, 11 Sep 1997 22:10:41 GMT
From: christian_dinten@hp.com (Christian Dinten)
Subject: Three questions related to SNMP, external task handling, paralell tasking
Message-Id: <341866cf.32827653@15.0.121.40>
Hello All,
While programming not to frequently, I'm actually faced with 3
questions I have never had before, to be solved in Perl.
So any help or hint about a existing module would be very appreciated
and wellcome.
So here the three questions:
1.) Perl sub-routine which query's via a external SNMP-Tool (not the
Perl SNMP modules) from multiple SNMP Agents three values from a MIB
table with up-to 50,000 entry's. The problem I have with this is, the
query can take some seconds for a small amount of table-entry's, but
for the 50,000 entry's it can take up to 20 min. So if the first value
has been queried, the next query should start, then the third. The
query results are written into temp file.
So the question is how to coordinate multiple, external instances of
this query tool and to check if it is still running, finished (if
finished, to start the next query for this agent), or in a other state
e.g. dead, and if dead to kill or clean-up the child process.
2.) As a result of this query's described in point 1, each Agent will
have three in it self independent temp files, which each contains
tables of information looking like following (sorted by the first,
leftmost, IP address:
Temp File 1
Host A Host B Value1
10.10.10.1 10.20.20.2 100
......
Temp File 2
Host A Host B Value2
10.10.10.1 10.20.20.2 555
.......
Temp File 3
Host A Host B Value3
10.10.10.1 10.20.20.2 43210
.......
So let's assume the tables can be up to 50'000 entry's long, how would
you bring the three table's an the Values together into one table?
Example of result would be:
Output File 1
Host A Host B Value1 Value2 Value3
10.10.10.1 10.20.20.2 100 555 43210
.......
3.) What would you do to query large tables with SNMP using Perl with
direct socket and protocol call's, or any SNMP query technique to
query with SNMP V1 large tables.
I know the some public available program's such as the multi router
traffic grapher application from Tobias Oetiker and others.
Thanks in advance for any hint or program suggestion. Could you please
reply also to my E-Mail?
Christian
____________________________________________________________________________
**************
**** /_ _ **** "Scotty, beam me up!
*** / //_/ *** Down here is no intelligent live!"
**** / **** James Tiberius Kirk, Captain Starfleet
************** Ship Enterprise NCC 1701-A
"Bei Risiken oder Nebenwirkungen, erschlagen
Sie Ihren Arzt oder Apotheker"
Unbekannt
Christian Dinten
Hewlett-Packard AG
SSV Datacom Consultant
In der Luberzen 29
CH-8902 Urdorf/ZH Telephone: (+41) 735 72 43
Switzerland Fax: (+41) 735 77 03
Telnet: 780-7243
UnixMail: christian_dinten@hp.com
Disclaimer: Comments, Commitments, Concerns are all mine of course!
NOT HP!
____________________________________________________________________________
------------------------------
Date: Wed, 10 Sep 1997 17:46:25 +0100
From: Russell Odom <rjo100@york.ac.uk>
To: stephen <schan_ca@hotmail.com>
Subject: Re: where's gunzip and tar for dos/win?
Message-Id: <3416CEE1.4380E6F@york.ac.uk>
stephen wrote:
>
> Just downloaded the latest Perl for Windows/DOS,
> but it's in a gzipped and tar format:
>
> perl5_00402-bindist04-bc_tar.gz
>
> which utility do I use to gunzip and tar it?
WinZip (at http://www.winzip.com/) handles these formats and many more,
and is quite easy to use.
HTH,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1013
**************************************