[12975] in Perl-Users-Digest
Perl-Users Digest, Issue: 384 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 14:17:35 1999
Date: Thu, 5 Aug 1999 11:05:17 -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 Thu, 5 Aug 1999 Volume: 9 Number: 384
Today's topics:
Re: *Yet another* Net::FTP question (I R A Darth Aggie)
Re: 5.005.03 compile problem (Steve Manes)
Re: @foo = @{[@arry, shift @arry]}; behaves oddly? <aqumsieh@matrox.com>
Activestate Perl/Dos? Question mknickelbein@my-deja.com
Re: Autovivification? <aqumsieh@matrox.com>
Re: CGI.pm Example <geoffrey.halliwell@Sun.COM>
Re: chomp not working (Anno Siegel)
Re: chomp not working (Malcolm Ray)
Re: chomp not working <sariq@texas.net>
Re: chomp not working <tchrist@mox.perl.com>
Re: chomp not working <rootbeer@redcat.com>
Re: Complex data structure <aqumsieh@matrox.com>
Determining if a POP3 message has been read rook268@my-deja.com
Re: eliminating / from a word <aqumsieh@matrox.com>
Re: format-question <rootbeer@redcat.com>
Free Online Training mabidex@my-deja.com
Re: Get Executables path <mattk@cybersurf.net>
Re: Hackers and Gurus and Wizards <sariq@texas.net>
Re: How can I use ODBC and LOBs with Perl? (Dan Wilga)
Re: how can I write an e-mail in an perl prg? <salvador@my-deja.com>
Re: how can I write an e-mail in an perl prg? (Malcolm Ray)
Re: how can I write an e-mail in an perl prg? <rootbeer@redcat.com>
How do I replace a "space" character? perdrix@my-deja.com
Re: How do I replace a "space" character? <sariq@texas.net>
Re: How do I replace a "space" character? (Larry Rosler)
Re: How to trim a String <aqumsieh@matrox.com>
Re: IMPORTANT: "19$year" <aqumsieh@matrox.com>
Interesting database manipulation problem <P.Gillingwater@iaea.org>
Re: Interesting database manipulation problem (Anno Siegel)
Re: Is there any way to get user name (Malcolm Ray)
Re: Is there any way to get user name (Gary O'Keefe)
Re: Is there any way to get user name (Malcolm Ray)
making EventLog work with ActiveWare build 316 (5.003_0 ecklesweb@yahoo.com
My Last Words on => vs comma <perlking@hotmail.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Aug 1999 16:56:23 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: *Yet another* Net::FTP question
Message-Id: <slrn7qjglq.5n6.fl_aggie@thepentagon.com>
On Thu, 5 Aug 1999 14:15:51 GMT, John Borwick <John.Borwick@sas.com>, in
<37ab9c65.266856689@newshost.unx.sas.com> wrote:
+ On 3 Aug 1999 18:00:39 GMT, fl_aggie@thepentagon.com (I R A Darth
+ Aggie) wrote:
+ >and then it times out. Even if I excise the debugging stuff, and just pass
+ >in Port 23, it times out. As a wild-assed guess, I tried this:
+ >%options=qw(Debug 10 23 Port);
+ >Well, shiver me timbers, that worked. That strikes me as being somewhat
+ >anti-intuitive, but maybe I'm not thinking about it correctly?
+ Maybe this worked because there was no defined port key, so it ignored
+ 23 => Port and used the default port of 23?
Ok, that makes sense. In which case, why did 'Port'=>23 _not_ work?
That's what bothers me. What did I fsck up?
James
------------------------------
Date: Thu, 05 Aug 1999 18:02:41 GMT
From: smanes@NOSPAM.HEREmagpie.com (Steve Manes)
Subject: Re: 5.005.03 compile problem
Message-Id: <37aad0ea.16455994@news.panix.com>
On Thu, 05 Aug 1999 02:41:27 GMT, smanes@NOSPAM.HEREmagpie.com (Steve
Manes) wrote:
>I had this compiled and running fine under Linux 2.0.34. Yesterday, I
>got Dell P3 for the network and installed Redhat 6.0 on it for a
>starter system.
...
>Actually, Perl compiles without gripes. It just fails one test in
>'anydbm.t'. This test assigns a string value to a hash, h, with a
>null key, i.e.
Addendum: this is a confirmed problem with Redhat 6.0, as indicated by
its bug tracking web site. 6.0's dbm libraries are all screwed up
with a mix of db1, db2, missing header files, etc. It looks like I'm
going to have to rebuild all them from fresh sources. Sheesh.
------------------------------
Date: Thu, 5 Aug 1999 12:36:05 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: @foo = @{[@arry, shift @arry]}; behaves oddly?
Message-Id: <x3ybtcmchhm.fsf@tigre.matrox.com>
philipp+perl@cnct.com writes:
> This is the smallest I can get it...
> the results of the following:
>
> @arry = qw(a b c d e f g);
> @foo = @{[@arry, shift @arry]};
You can easily re-write the above line as:
@foo = (@arry, shift @arry);
which should be faster. But since you're looking for obfuscation,
maybe you should stick with your approach.
> print join ":", @foo, "\n";
>
> is:
>
> a:b:c:d:e:f:g::
This is weird. If you flip the order like so:
% perl -w
@arry = qw(a b c d e f g);
@foo = (shift @arry, @arry);
print join ":", @foo, "\n";
__END__
a:b:c:d:e:f:g:
Which is correct. Changing shift() to pop() shows this better:
% perl -w
@arry = qw(a b c d e f g);
@foo = (pop @arry, @arry);
print join ":", @foo, "\n";
__END__
g:a:b:c:d:e:f:
I believe it has something to do with the ordering of
execution. According to the docs, there is no defined ordering and you
shouldn't depend on it.
Maybe I'm wrong and it's bug.
Anybody got any more clues?
------------------------------
Date: Thu, 05 Aug 1999 16:10:04 GMT
From: mknickelbein@my-deja.com
Subject: Activestate Perl/Dos? Question
Message-Id: <7ocd0g$gbv$1@nnrp1.deja.com>
Hi,
I'm sorry if this is offtopic, but I'm not sure if it applies to Perl
or to DOS.
When I type in at the dos prompt:
perl myperlfile.pl > myoutputfile.dat
If there were no errors in the PL file, myoutputfile.dat will contain
the output of my Perl file, and nothing will be printed to the screen.
But if there were errors, if will print to the screen and not to the
file. How can I make it -always- print to the file?
Thanks,
Mark
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 5 Aug 1999 11:27:01 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Autovivification?
Message-Id: <x3yiu6uckoq.fsf@tigre.matrox.com>
bart.lateur@skynet.be (Bart Lateur) writes:
> >you don't run with use strict in general?
>
> No. Especially not in one-off scripts, whuich is... most of them. See
> the eternal discussion of why "strict" is not the standard option for
> Perl, i.e. why YOU have to turn it on, explicitely.
>
> If I liked what "strict" requires from me, I'd be using Ada. ;-)
IMO, "strict" has more pros than cons. I have an alias:
alias myperl perl -Mstrict
which I use very often.
Ala
------------------------------
Date: Thu, 05 Aug 1999 09:57:07 -0700
From: Geoff Halliwell <geoffrey.halliwell@Sun.COM>
Subject: Re: CGI.pm Example
Message-Id: <37A9C263.D2C19F96@Sun.COM>
Abigail wrote:
>
> Geoff Halliwell (geoffrey.halliwell@Sun.COM) wrote on MMCLXIV September
> MCMXCIII in <URL:news:37A87DBD.8446A25C@Sun.COM>:
>
> Stealth emails are a sign of bad taste, or plain dumbness.
>
> \\ Abigail wrote:
> \\ >
> \\ > So, what's $! set to?
> \\ >
> \\
> \\ $! returns "Bad File Number" when you submit and entry,
> \\ and returns nothing when you try to view the guestbook.
>
> Did you check the return value of open? Did you open the file in the
> correct mode? Did you check your system manuals when EBADF occurs?
>
> Abigail
> --
I made a smaller test case and found that it didn't like:
my $fh = lock($GUESTBOOKFILE,1);
-w returned "Useless use of a variable in void context"
I changed the subroutine to:
my $fh = lock_file($GUESTBOOKFILE,1);
and everything is working fine.
Geoff
------------------------------
Date: 5 Aug 1999 16:11:10 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: chomp not working
Message-Id: <7ocd2u$el7$1@lublin.zrz.tu-berlin.de>
Tom Briles <sariq@texas.net> wrote in comp.lang.perl.misc:
>John Embow wrote:
>>
>> Any explainations/ suggestions?
>>
>
>Yeah. Read the replies to your first post on the subject.
He just might have had a reason to post twice (and, on my feed, a third
time). I am currently seeing an unusual amount of canceled messages,
two copies of John Embow's among them. Some cancelbot run wild?
Anno
------------------------------
Date: 5 Aug 1999 16:25:56 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: chomp not working
Message-Id: <slrn7qjeok.7sm.M.Ray@carlova.ulcc.ac.uk>
On 5 Aug 1999 16:11:10 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
wrote:
>He just might have had a reason to post twice (and, on my feed, a third
>time). I am currently seeing an unusual amount of canceled messages,
>two copies of John Embow's among them. Some cancelbot run wild?
>
>Anno
Three of mine have been cancelled. I won't lose any sleep over it.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 05 Aug 1999 11:32:41 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: chomp not working
Message-Id: <37A9BCA9.301F1F94@texas.net>
jembow@my-deja.com wrote:
>
> >
> >Are you sure about that? Let's see a code snippet, please.
> >
>
> #!/usr/bin/perl -w
> $x = "good night\n";
> chomp($x);
> print($x);
>
> yields the following error message. "Chop", however, works fine:
>
> "chomp" may clash with future reserved word at ./chomp_test line
> 3syntax error i
> n file ./chomp_test at line 3, next 2 tokens "chomp("
> Execution of ./chomp_test aborted due to compilation errors.
You're using Perl 4.
Try creating a program with:
#!/usr/bin/perl -v
as the first line. It could just be that /usr/bin/perl is a link to an
old version that's still on your system.
Also, if you haven't seen past replies in this thread, your news server
has a problem.
- Tom
------------------------------
Date: 5 Aug 1999 10:58:43 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: chomp not working
Message-Id: <37a9c2c3@cs.colorado.edu>
[courtesy cc of this posting mailed to cited authors]
In comp.lang.perl.misc, M.Ray@ulcc.ac.uk (Malcolm Ray) writes:
:On 5 Aug 1999 16:11:10 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
:>He just might have had a reason to post twice (and, on my feed, a third
:>time). I am currently seeing an unusual amount of canceled messages,
:>two copies of John Embow's among them. Some cancelbot run wild?
:
:Three of mine have been cancelled. I won't lose any sleep over it.
Cancelled by whom, though? Someone should track this down.
Perhaps it's a script kiddie who got RTFM'd. :-)
--tom
--
I use `batshit' in an idiosyncratic fashion. --Andrew Hume
------------------------------
Date: Thu, 5 Aug 1999 10:43:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: chomp not working
Message-Id: <Pine.GSO.4.10.9908051029300.9452-100000@user2.teleport.com>
On Thu, 5 Aug 1999 jembow@my-deja.com wrote:
> To: "comp.lang.perl.misc@list.deja.com" <comp.lang.perl.misc@list.deja.com>
???
> #!/usr/bin/perl -w
> $x = "good night\n";
> chomp($x);
> print($x);
>
> yields the following error message. "Chop", however, works fine:
> "chomp" may clash with future reserved word at ./chomp_test line
Smells like you've got a version of Perl that was released longer ago than
"Pulp Fiction". Perl 4 is an antique; upgrade!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 5 Aug 1999 12:40:43 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Complex data structure
Message-Id: <x3yaes6ch9w.fsf@tigre.matrox.com>
julmajuha@my-deja.com writes:
> Hi!
> I am struggling with the complex data structures
> in PERL.
> I use a hash of arrays like this :
>
> $Comp = "res1";
> $Codes{$Comp}[0] = 123;
> $Codes{$Comp}[1] = 321;
> $Codes{$Comp}[2] = 345;
> $Codes{$Comp}[3] = 543;
>
> It works OK. However, I would like to do the
> following :
>
> for $i (123, 321, 345, 543) {
> push @Codes{$Comp}, $i;
> }
@Codes{$Comp} is a hash slice. The first argument to push() has to be
an array.
> I tried many variations of the syntax with no
> success.
> Eg. push @[$Codes{$Comp}], $i; ... etc.
Very close:
push @{$Codes{$Comp}}, $i;
should be fine. $Codes{$Comp} is an array reference. Just dereference
it to get the array. The syntax is as shown above.
Have a look at perldsc. It contains some helpful examples.
> Similarly, I want to print the codes using
> foreach, something like this :
>
> foreach $i (@Codes{$Comp}) {
> print "Code = $i\n";
> }
Again,
foreach $i (@{$Codes{$Comp}}) {
print "Code = $i\n";
}
HTH,
Ala
------------------------------
Date: Thu, 05 Aug 1999 17:07:55 GMT
From: rook268@my-deja.com
Subject: Determining if a POP3 message has been read
Message-Id: <7ocgd1$j62$1@nnrp1.deja.com>
I'm tinkering with a web-based email client written in Perl. I'd like
to be able to see only messages that haven't been read yet. I've looked
through the Net::POP3 documentation, and can't seem to find anything
that will tell you if a particular message has been read before. Am I
missing something in Net::POP3, or is there another module I can use for
this?
Paul Mindeman
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 5 Aug 1999 11:52:32 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: eliminating / from a word
Message-Id: <x3yemhicji7.fsf@tigre.matrox.com>
Alan Melton <alan@home.net> writes:
> Problem with eliminating a character
> the character is /
> ie. C/HU
> this is equal to $h[0]
> so that $h[0]= C/HU
> and I want it to be CHU
> what is a proper substitution
> # $h[0] =~ s/(^\s*|\s*$)//g;
> # $h[0] =~ s/(/)//g;
Did you read perlre? Do you know what brackets do? Do you know what /g
does?
I suggest you have a look at tr/// in perlop.
HTH,
Ala
------------------------------
Date: Thu, 5 Aug 1999 10:07:41 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: format-question
Message-Id: <Pine.GSO.4.10.9908051006560.9452-100000@user2.teleport.com>
On 5 Aug 1999, Steffen Koehler wrote:
> But what I need is
> "Hallo" and
> "An long text with information"
> independent from the length of $var.
Maybe you don't want formats. Or maybe you want the special @* field. See
the perlform manpage. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 05 Aug 1999 15:57:40 GMT
From: mabidex@my-deja.com
Subject: Free Online Training
Message-Id: <7occ9d$fr7$1@nnrp1.deja.com>
Free Trial. Not sure what you can expect
from Online Training? Complete Training,
simulations, Tests after chapters, etc.
24 hours a day from your own home... Try it out for Free!
For a free MCSE Microsoft Approved
Online Certification Training learning session
or Windows 98 Session,
(MCSE Module: Exchange Server 5.5:7 Troubleshooting),
if it's easy for you to understand,
then you'll know Online Training is for you!
click on link below:
http://www.handtech.com/asp/learningcenter/gate/HandUDemo_redirect.asp?
host=usa-scholar
270 Courses available, including MCSE, A+,
Excel, Access, Windows 95, Windows 98,
Internet, From Basics for kids to Advanced Programming.
For Those that already have an MCSE. Please
Feel free to comment on the completeness of
the Training by trying out the one free module.
Thanks!
If your interested in what is available
look for the "Learning Center" image at
this link & click!:
Http://usa-scholar.com/
Regards,
Anthony Loera
Http://usa-scholar.com/
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 10:01:39 -0700
From: Matt Kennedy <mattk@cybersurf.net>
Subject: Re: Get Executables path
Message-Id: <37A9C373.32E30031@cybersurf.net>
Martien Verbruggen wrote:
>
> Of course this does _not_ give you the directory the script is in, but
> the current working directory. They are not necessarily the same, and
> in fact often _not_ the same.
Whoops, wasn't thinking on this one, good call. I misunderstood his
post.
Matt
------------------------------
Date: Thu, 05 Aug 1999 11:05:22 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Hackers and Gurus and Wizards
Message-Id: <37A9B642.ABEE1605@texas.net>
Tom Christiansen wrote:
>
> * Expert
> o Write JAPHs to impress their friends and annoy their coworkers.
> o Begins all programs with use strict.
> o Thinks Perl should just be Perl.
> o Has taken enough advantage of cryptocontext to annoy others.
> o Knows how to create records and objects with hash refs.
> o Uses syscall to get at undocumented operating system calls.
> o Curses the flexibility of the Perl object system.
> o Uses /e in substitutes.
> o Has begun to wonder what typeglobs are for.
> o Has written their own modules in Perl.
> o Begins to look at all data in terms of regular expressions.
> o Understands why regexes can't match nested data.
> o Rewrites minor utilities in Perl.
Woohoo! Another item for my resume...
* Tom Christiansen calls me a "Perl Expert"
;-)
- Tom
------------------------------
Date: Thu, 05 Aug 1999 13:26:13 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: How can I use ODBC and LOBs with Perl?
Message-Id: <dwilgaREMOVE-0508991326130001@wilga.mtholyoke.edu>
In article <7o9ng7$4fq$1@news.netvision.net.il>, "gosha"
<georgy@gtek.co.il> wrote:
> How can I use ODBC and LOBs with Perl?
> Thanks.
I suggest reading about DBI and DBD::ODBC. Both are available from CPAN,
http://cpan.perl.org .
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Thu, 05 Aug 1999 16:34:48 GMT
From: Salva <salvador@my-deja.com>
Subject: Re: how can I write an e-mail in an perl prg?
Message-Id: <7ocef7$hlr$1@nnrp1.deja.com>
In article <37A9A912.BAE8AC8A@garnix.unix-ag.uni-hannover.de>,
knigge@stud.uni-hannover.de wrote:
> in an Variable I habe an text. These text I like to sende to an
person.
> I work whith unix.
>
> how can I do this
> like system(mail,"xyz@gmx.com",$text);
> or `echo $text|mail "xyz@gmx.com"'
>
> what is the correct way?
open M,"|mail xyz@gmx.com";
print M $text;
close M;
bye,
- Salva.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 5 Aug 1999 16:54:20 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: how can I write an e-mail in an perl prg?
Message-Id: <slrn7qjgds.7sm.M.Ray@carlova.ulcc.ac.uk>
On Thu, 05 Aug 1999 16:34:48 GMT, Salva <salvador@my-deja.com> wrote:
>In article <37A9A912.BAE8AC8A@garnix.unix-ag.uni-hannover.de>,
> knigge@stud.uni-hannover.de wrote:
>> in an Variable I habe an text. These text I like to sende to an
>person.
>> I work whith unix.
>>
>> how can I do this
>> like system(mail,"xyz@gmx.com",$text);
>> or `echo $text|mail "xyz@gmx.com"'
>>
>> what is the correct way?
>
>open M,"|mail xyz@gmx.com";
>print M $text;
>close M;
I count four errors in that. Not bad for three lines of code!
perldoc perlfaq9: How do I send mail?
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 5 Aug 1999 10:28:07 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: how can I write an e-mail in an perl prg?
Message-Id: <Pine.GSO.4.10.9908051027270.9452-100000@user2.teleport.com>
On Thu, 5 Aug 1999, Christian WIese wrote:
> Subject: how can I write an e-mail in an perl prg?
Have you seen the FAQ, section nine?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 05 Aug 1999 17:11:04 GMT
From: perdrix@my-deja.com
Subject: How do I replace a "space" character?
Message-Id: <7ocgit$j9t$1@nnrp1.deja.com>
Hi,
I'm a newbie to Perl programming, so excuse me if this is a simplistic
question. I need to replace all " " characters with "" in a variable
called $CRITERIA. effectively I need to rid the variable of any spaces
that might be present. Any assistance with this problem would be
appreciated.
Best Wishes,
Dennis
--
The SurnameWeb
http://www.surnameweb.org/
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 12:39:33 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How do I replace a "space" character?
Message-Id: <37A9CC55.C761243E@texas.net>
perdrix@my-deja.com wrote:
>
> Hi,
>
> I'm a newbie to Perl programming, so excuse me if this is a simplistic
> question. I need to replace all " " characters with "" in a variable
> called $CRITERIA. effectively I need to rid the variable of any spaces
> that might be present. Any assistance with this problem would be
> appreciated.
>
> Best Wishes,
>
> Dennis
perldoc -f tr
- Tom
------------------------------
Date: Thu, 5 Aug 1999 10:48:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I replace a "space" character?
Message-Id: <MPG.12136e2931ba430b989de0@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7ocgit$j9t$1@nnrp1.deja.com> on Thu, 05 Aug 1999 17:11:04
GMT, perdrix@my-deja.com <perdrix@my-deja.com> says...
> I'm a newbie to Perl programming, so excuse me if this is a simplistic
> question. I need to replace all " " characters with "" in a variable
> called $CRITERIA. effectively I need to rid the variable of any spaces
> that might be present. Any assistance with this problem would be
> appreciated.
It is simplistic, but that doesn't prevent it from being asked every few
days. What do people have against space characters anyway?
Someone is sure to tell you this:
$CRITERIA =~ s/ //g;
(by the way, all upper-case letters implies a constant, not a variable,
by convention).
But the Right (i.e. fastest) way to do it is this:
$CRITERIA =~ tr/ //d;
Look in perlop for the 'translate' operator. It has lots of goodies for
dealing with single characters out of context.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 5 Aug 1999 12:19:09 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How to trim a String
Message-Id: <x3yd7x2ci9u.fsf@tigre.matrox.com>
"Faisal Nasim" <swiftkid@bigfoot.com> writes:
> sub trim
> {
> ( local $_ = shift ) =~ s/\s+|\s+$//gs;
> $_
> }
Of course this will remove every single white space in your
string. Did you try it before posting?
And why do you use the /s modifier? Any reasons?
------------------------------
Date: Thu, 5 Aug 1999 12:42:26 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: IMPORTANT: "19$year"
Message-Id: <x3y907qch71.fsf@tigre.matrox.com>
Matt Sergeant <matt.sergeant@bbc.co.uk> writes:
> Jeff Pinyan wrote:
> >
> > Do not accept ANY substitutes.
> >
> > $date = 1900 + $year;
>
> $year += 1900;
$date = 1900 + $year + 0;
$date = 1900 + $year + 5 - 5;
$date = 1900 + $year + log(1);
:-)
Ala - who is just being silly
------------------------------
Date: Thu, 05 Aug 1999 16:51:55 +0200
From: Paul Gillingwater <P.Gillingwater@iaea.org>
Subject: Interesting database manipulation problem
Message-Id: <37A9A50B.CBE528F6@iaea.org>
First, this is not for a CS assignment. I graduated already. This is a
real-world reporting requirement from a corporate database. FWIW, the
database is SQL-based, but I don;t think that matters. I'm looking at a
suggested approach to reduce the complexity of the problem.
There are two tables, one containing Persons, the other containing Jobs
(generic tasks, not roles.) A third table uses unique ids from the
other two, and provides the many-many relationship between the first
two.
The question is: given that there is some overlap, i.e., some people do
the same jobs as other people, create a report that lists the areas of
greatest overlap, i.e., a set of jobs and people in common with the
greatest number of jobs in common. Now do it again, for one less job.
Then again, until no more than 5 jobs are in common.
I tried creating hashes, counting the number of jobs for each person,
and can easily produce a report listing each job, and the people that do
that job in their department. It's much harder to find an efficient
(non-iterative) way to find the commonality, and do so in a way that
won't rapidly approach n! iterations, where n is the number of jobs.
Any pointers would be greatly appreciated.
Thanks,
Paul Gillingwater
------------------------------
Date: 5 Aug 1999 17:01:32 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Interesting database manipulation problem
Message-Id: <7ocg1c$eph$1@lublin.zrz.tu-berlin.de>
Paul Gillingwater <P.Gillingwater@iaea.org> wrote in comp.lang.perl.misc:
>First, this is not for a CS assignment. I graduated already. This is a
>real-world reporting requirement from a corporate database. FWIW, the
>database is SQL-based, but I don;t think that matters. I'm looking at a
>suggested approach to reduce the complexity of the problem.
>
>There are two tables, one containing Persons, the other containing Jobs
>(generic tasks, not roles.) A third table uses unique ids from the
>other two, and provides the many-many relationship between the first
>two.
>
>The question is: given that there is some overlap, i.e., some people do
>the same jobs as other people, create a report that lists the areas of
>greatest overlap, i.e., a set of jobs and people in common with the
>greatest number of jobs in common. Now do it again, for one less job.
>Then again, until no more than 5 jobs are in common.
>
>I tried creating hashes, counting the number of jobs for each person,
>and can easily produce a report listing each job, and the people that do
>that job in their department. It's much harder to find an efficient
>(non-iterative) way to find the commonality, and do so in a way that
>won't rapidly approach n! iterations, where n is the number of jobs.
Without going into too much algorithmic detail (which isn't Perl-
specific anyway) you may want to set up a pair of incidence matrices
in form of bit vectors (the rows of one being the columns of the
other). Finding all people working on a set of jobs (say) would
be an or-operation on the bit vectors belonging to the given jobs.
This doesn't change the complexity of the yet-to-be-devised algorithm,
but it may make a big difference in constant factors. It would
also hide one level of loops.
Anno
------------------------------
Date: 5 Aug 1999 16:13:22 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Is there any way to get user name
Message-Id: <slrn7qje12.7sm.M.Ray@carlova.ulcc.ac.uk>
On 5 Aug 1999 11:28:41 -0400, Tanvada Jagannadha <jaganna@shell.one.net> wrote:
>Sir,
> is there anyway we could get the user information along with the
>environmental variables? I mean the login name. If not with env variables,
>is there any command like unix 'w/who' so that we could get the login
>name. Thanks in advance.
>Regards,
>Jagannadh
>
my $username = getpwuid($>);
Will be undef if there's no username corresponding to the effective uid.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 05 Aug 1999 16:42:16 GMT
From: gary@onegoodidea.com (Gary O'Keefe)
Subject: Re: Is there any way to get user name
Message-Id: <37a9bdc8.116933926@news.hydro.co.uk>
Tanvada Jagannadha wrote:
> is there anyway we could get the user information along with the
>environmental variables? I mean the login name. If not with env variables,
>is there any command like unix 'w/who' so that we could get the login
>name. Thanks in advance.
There is a hash %ENV which contains the environment variables, the
user name is stored as
$ENV{'USER'}
Check out the perlvar documentation for more predefined variables.
Gary
--
Gary O'Keefe
gary@onegoodidea.com
You know the score - my current employer has nothing to do with what I post
------------------------------
Date: 5 Aug 1999 17:00:21 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Is there any way to get user name
Message-Id: <slrn7qjgp5.7sm.M.Ray@carlova.ulcc.ac.uk>
On Thu, 05 Aug 1999 16:42:16 GMT, Gary O'Keefe <gary@onegoodidea.com> wrote:
>Tanvada Jagannadha wrote:
>
>> is there anyway we could get the user information along with the
>>environmental variables? I mean the login name. If not with env variables,
>>is there any command like unix 'w/who' so that we could get the login
>>name. Thanks in advance.
>
>There is a hash %ENV which contains the environment variables, the
>user name is stored as
>
> $ENV{'USER'}
You need to be aware that this can't be trusted:
$ cat user_test
#!/usr/bin/perl
print $ENV{USER}, "\n";
__END__
$ USER=root ./user_test
root
I'm sure you can think of situations in which this would be bad news.
However, $< and $> can be relied on.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 05 Aug 1999 16:36:39 GMT
From: ecklesweb@yahoo.com
Subject: making EventLog work with ActiveWare build 316 (5.003_07)
Message-Id: <7oceim$hnu$1@nnrp1.deja.com>
I have several NT clusters in production that have perl 5.003_07 (build
316 by ActiveWare) available on them. I have written a perl script that
will check to see if any automatic services have stopped running and if
so, write a message to the application log so that HP OpenView can pick
up on the failure and notify the operators. (OpenView is a suite of
programs, we use OpCenter to monitor Unix and NT servers).
I used Win32::EventLog to write the message to the Application log, and
everything works under the latest build of perl. Unfortunately, it does
not work with build 316. Here's the error I get:
Goto undefined subroutine &AutoLoader::AUTOLOAD at
C:\Perl\lib/Win32/EventLog.pm line 49, <INFILE> chunk 7
Sure enough, there's no AUTOLOAD function defined in the version of
autoloader.pm that comes with build 316.
I tried to extract the code from EventLog.pm module and put it right in
my script, but there are two routines that I can't find the code for:
OpenEventLog used in EventLog::Open and WriteEventLog used in
EventLog::Report. I suspect that these are "autoloaded" functions.
So, I'm looking for any suggestions as to how to write a critical
message to the application log via perl 5.003_07 build 316 (EventLog or
not). Updating perl is not an immediate option; because these are
production servers, the latest version of perl would have to be tested
for weeks on test servers then validated before being installed on
production. Same applies for updating just the autoloader.pm file.
Thanks for you help.
Jay Eckles
Distributed Communications Software
FedEx Corp., Memphis, TN.
PS-if convenient, please copy my email on replies.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 13:26:53 EDT
From: "Perl King" <perlking@hotmail.com>
Subject: My Last Words on => vs comma
Message-Id: <19990805172653.47299.qmail@hotmail.com>
The point of my last post was to show that you can NOT use the
corresponds-to operator everywhere you use the comma operator.
In the case of the open example
open PW => '/etc/passwd';
it causes a syntax error. It may cause unexpected errors in
other code. In short, I see no reason to use "=>" instead of ",".
The comment that "it looks better" just doesn't wash. A comma is
used in virtually all programming languages to separate arguments
and is easily recognized by programmers. The => can be confused
with a structure pointer or branch operator. "=>" also requires
extra keystrokes, and may be less efficient. I have not see it
used anywhere in Perl books or standard code except for hash
initialization. Using "=>" instead of "," just because you CAN
makes me think of someone who prefixes numeric constants with "+" since "it
makes them stand out more".
My advice? Use the language as it was meant to be used, and don't
try to decorate it! Perl is already beautiful enough as is.
Perl King
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
------------------------------
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 384
*************************************