[11250] in Perl-Users-Digest
Perl-Users Digest, Issue: 4850 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 9 01:07:33 1999
Date: Mon, 8 Feb 99 22:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Feb 1999 Volume: 8 Number: 4850
Today's topics:
callback functions (Kbulgakov)
Re: Comma insertion in numbers, 333,333 (Ronald J Kimball)
Re: Converting a Byte to it's respective bits (Ronald J Kimball)
Delete links on virtual server <fredhendrikson@iname.com>
Entry widget (Kbulgakov)
Re: Help (Ronald J Kimball)
Re: how do I get a date in perl? (Ronald J Kimball)
How do I parse carriage returns, not newlines aretol@my-dejanews.com
Re: How do I parse carriage returns, not newlines (Ronald J Kimball)
Re: How do I use CGI.pm to fetch parameters? <schultsm@hotmail.com>
Re: How fo have non blocking STDIN <ebohlman@netcom.com>
Re: HTML::Parser::parse_html <jamesht@idt.net>
Re: HTML::Parser::parse_html <rick.delaney@home.com>
implementing a find method for an object? (Brian Lindsay)
Re: implementing a find method for an object? <bmb@ginger.libs.uga.edu>
Re: implementing a find method for an object? (Brian Lindsay)
Re: locking files (Chris Komuves)
Re: Net::FTP - STOU?? <jamesht@idt.net>
Re: NEWBIE Question about error checking string (Ronald J Kimball)
Re: performance penalty: bareword, single quoting, doub (Ilya Zakharevich)
Re: Perl 'zine <carvdawg@patriot.net>
Re: Perl 'zine <jjarrett@ecpi.com>
Re: Perl 'zine <tomrou@ainet.com>
perl invoke unix command- help <pchang@cybersource.com>
Re: perl invoke unix command- help <bmb@ginger.libs.uga.edu>
perl password example <farber@admin.f-tech.net>
Re: perl password example <bmb@ginger.libs.uga.edu>
Re: Program needs compactification (Ronald J Kimball)
Re: Python vs. Perl vs. tcl ? (Martien Verbruggen)
Re: Question: using write to format strings in a $varia <ebohlman@netcom.com>
Re: Rounding for Euro currency <ian@no-spam4site.co.uk>
Re: Rounding for Euro currency (Ronald J Kimball)
send form to SMTP server <spam@spam.com>
sending mail from nt with perl 4.x...?? <jamesht@idt.net>
Re: sending mail from nt with perl 4.x...?? <dgris@moiraine.dimensional.com>
Re: Simple Question About a Scalar (Tad McClellan)
Re: String splitting. (Tad McClellan)
Re: String splitting. (Ronald J Kimball)
Re: testing for scalar/list/array <rick.delaney@home.com>
Re: Would love UNIX program that could read Excel binar (Victor Wagner)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Feb 1999 04:46:37 GMT
From: kbulgakov@aol.com (Kbulgakov)
Subject: callback functions
Message-Id: <19990208234638.19642.00000395@ng34.aol.com>
How are arguments passed to a callback function in Perl/Tk?
------------------------------
Date: Tue, 9 Feb 1999 00:05:22 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Comma insertion in numbers, 333,333
Message-Id: <1dmxi5q.14w4jzu1lcl4e8N@bay1-326.quincy.ziplink.net>
Xeno Campanoli <xeno@bigger.aa.net> wrote:
> I know I knew this before, but now I don't and I can't figure it out.
Guess what! The FAQ has a much better memory than you do.
perlfaq5:
How can I output my numbers with commas added?
This one will do it for you:
sub commify {
local $_ = shift;
1 while s/^(-?\d+)(\d{3})/$1,$2/;
return $_;
}
$n = 23659019423.2331;
print "GOT: ", commify($n), "\n";
GOT: 23,659,019,423.2331
You can't just:
s/^(-?\d+)(\d{3})/$1,$2/g;
because you have to put the comma in and then recalculate your
position.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 9 Feb 1999 00:05:23 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Converting a Byte to it's respective bits
Message-Id: <1dmxikf.1tiex39b08p4bN@bay1-326.quincy.ziplink.net>
Mark Leighton Fisher <fisherm@tce.com> wrote:
> In article <36BE76FC.BF1AEFCD@acpub.duke.edu>, ricks@acpub.duke.edu
> says...
> > However, I can't figure out how to break that information out into its
> > separate bits (I need to be able to read out the bit values).
>
> Use vec().
Or unpack().
unpack 'b*', $info;
unpack 'B*', $info;
depending on bit order.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 09 Feb 1999 05:13:26 +0100
From: Fred Hendrikson <fredhendrikson@iname.com>
Subject: Delete links on virtual server
Message-Id: <36BFB5E5.58FB@iname.com>
Hi,
I will place an "add a link script" on my site like
DCLinks98 (http://www.dcscripts.com/dclinks98.shtml)
and customise it to allow users to add more links at
ones.
URL's often change so I want to give anyone who
adds links, a password. The problem is that I want
to allow users not only to ADD but also DELETE
links. How can I do this if I don't have my own
dedicated server?
Thanks,
Fred Hendrikson
------------------------------
Date: 9 Feb 1999 04:45:10 GMT
From: kbulgakov@aol.com (Kbulgakov)
Subject: Entry widget
Message-Id: <19990208234510.19642.00000394@ng34.aol.com>
How does the program determine what text the user entered?
and how does the program determines when the user has finished entering text?
------------------------------
Date: Tue, 9 Feb 1999 00:05:20 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help
Message-Id: <1dmxhzw.w3bfoa3qziaoN@bay1-326.quincy.ziplink.net>
<pegasusetc@my-dejanews.com> wrote:
> I have tried to modify a guestbook from Matt's Archive only to mess it up.
Matt's Scripts are not very popular among the Perl gurus on clpm. I
would recommend finding a better guestbook script to start from.
(Sorry, I can't direct you to any offhand.)
P.S. Please use a more descriptive subject line.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 9 Feb 1999 00:05:25 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: how do I get a date in perl?
Message-Id: <1dmxjvm.13411ibr3qvs4N@bay1-326.quincy.ziplink.net>
Duc Le <bamboo@best.com> wrote:
> given "02/12/1999", I would like to know what date of the week this day
> falls on.
I remember seeing this question less than a month ago...
Here's the answer I gave, archived by DejaNews:
http://www.dejanews.com/getdoc.xp?AN=431502321
:-)
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 09 Feb 1999 02:03:16 GMT
From: aretol@my-dejanews.com
Subject: How do I parse carriage returns, not newlines
Message-Id: <79o50u$2rt$1@nnrp1.dejanews.com>
Hi all,
I am trying to parse a flat file that contains both newlines and carriage
returns (^M). For some reason, my program won't pick up any matches
dealing with carriage returns. I use the \r character, but it doesn't
seem to work. It seems to pick up \n just fine however.
Here is the gist of my code:
open(F,$ARGV[0]);
while (<F>)
{
if (m/\r/) {
print;
}
}
close(F);
Any help would be appreciated. Thanks.
Dan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 9 Feb 1999 00:05:25 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How do I parse carriage returns, not newlines
Message-Id: <1dmxk3w.eqobj56hkdyzN@bay1-326.quincy.ziplink.net>
<aretol@my-dejanews.com> wrote:
> I am trying to parse a flat file that contains both newlines and carriage
> returns (^M). For some reason, my program won't pick up any matches
> dealing with carriage returns. I use the \r character, but it doesn't
> seem to work. It seems to pick up \n just fine however.
What OS are you running this script on? On Windows systems, "\r\n" is
changed to "\n" upon input (and back again on output). Unless you
binmode() the filehandle first.
> Here is the gist of my code:
>
> open(F,$ARGV[0]);
You forgot to check the return value of open().
open(F,$ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 8 Feb 1999 18:57:35 -0800
From: "Sam Schulte" <schultsm@hotmail.com>
Subject: Re: How do I use CGI.pm to fetch parameters?
Message-Id: <3vNv2.58$hR.1144@news6.ispnews.com>
The below should work Jonathan. Why can't people just answer questions in
this group instead of all this "go read more" stuff?
#!/usr/local/bin/perl
#####################
# headlines.pl
# Jonathan Stowe
# 2/8/99
#####################
use CGI qw(:standard);
$county = param('county');
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>County Thingie</TITLE></HEAD>\n";
print "<BODY>\n";
print "$county\n";
print "hello\n";
print "</BODY></HTML>\n";
==========
Enjoy!
Sam
------------------------------
Date: Tue, 9 Feb 1999 01:58:56 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How fo have non blocking STDIN
Message-Id: <ebohlmanF6v6u8.KDs@netcom.com>
Jonathan Stowe <gellyfish@btinternet.com> wrote:
: On Mon, 08 Feb 1999 01:04:54 GMT gurdeeps@qualcomm.com wrote:
: > I want to check a keystroke in perl. When I use getch () function, it blocks
: > input
: > till one or more character is entered followed by carriage return.
: >
: > In C there is a function kbhit() which do the desired job. How can be
: > implement, same kind of functionality in perl.
: >
: I think the library function kbhit is only available in th MS libraries.
: You might find the module Term::ReadKey available from CPAN helpful in
: doing what you want.
s/might/will/;
------------------------------
Date: Mon, 08 Feb 1999 23:41:34 -0500
From: jamesht <jamesht@idt.net>
To: Asha Bageshpura <bageshpu@pa.dec.com>
Subject: Re: HTML::Parser::parse_html
Message-Id: <36BFBC7E.2B3C46E2@idt.net>
Hello,
use HTML::Parser;
...
$parsed_html = HTML::Parser::parse_html($html);
for(@{$parsed_html->extract_links}) {
#process the link
}
In other words, don't put an ampersand (&) in front of the 'HTML'.
hth,
James
Asha Bageshpura wrote:
> I an trying to use the HTML::Parser::parse_html method and when I
> compile I get
>
> 'Undefined subroutine &HTML::Parser::parse_html called'. In the new
> version should I use
>
> a different method.
>
> Thanks
------------------------------
Date: Tue, 09 Feb 1999 05:30:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: HTML::Parser::parse_html
Message-Id: <36BFC9CC.C5DEF524@home.com>
[posted & mailed]
jamesht wrote:
>
> Hello,
>
> use HTML::Parser;
>
> ...
>
> $parsed_html = HTML::Parser::parse_html($html);
Hmm, 'Undefined subroutine &HTML::Parser::parse_html called'.
> for(@{$parsed_html->extract_links}) {
> #process the link
> }
>
> In other words, don't put an ampersand (&) in front of the 'HTML'.
Why not? What difference would that make in this case?
I think an existing method is required. Try parse or parse_file.
perldoc HTML::Parser
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 9 Feb 1999 04:03:05 GMT
From: blindsay@bnr.ca (Brian Lindsay)
Subject: implementing a find method for an object?
Message-Id: <79oc1p$l0p$1@bmerhc5e.ca.nortel.com>
The perlobj.html reference pages have the following
suggested method implementation to find an object
in a class by name:
sub find
{
my ($class, $name) = @_;
$objtable{$name};
}
How do I setup $objtable to properly store a reference to an
object?
I tried the following in the new method for the class
but this doesn't seem to work properly.
$objtable{$self->name} = $self
Thanks.
(A perl OO novice)
--
--------------------------------------------------------------
The opinions expressed above are solely those of Brian Lindsay
--------------------------------------------------------------
------------------------------
Date: Mon, 8 Feb 1999 23:37:24 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: implementing a find method for an object?
Message-Id: <Pine.A41.4.02.9902082329160.13514-100000@ginger.libs.uga.edu>
On 9 Feb 1999, Brian Lindsay wrote:
> I tried the following in the new method for the class
> but this doesn't seem to work properly.
>
> $objtable{$self->name} = $self
Have you read 'perltoot', too?
Giving that one line out of context probably won't help us help you.
Perhaps you could show us more code, like the whole 'new' method (if not
too long). What exactly does "doesn't seem to work properly" mean?
Regards,
-Brad
------------------------------
Date: 9 Feb 1999 05:46:31 GMT
From: blindsay@bnr.ca (Brian Lindsay)
Subject: Re: implementing a find method for an object?
Message-Id: <79oi3n$ord$1@bmerhc5e.ca.nortel.com>
In article <Pine.A41.4.02.9902082329160.13514-100000@ginger.libs.uga.edu>,
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>On 9 Feb 1999, Brian Lindsay wrote:
>> I tried the following in the new method for the class
>> but this doesn't seem to work properly.
>>
>> $objtable{$self->name} = $self
>
>Have you read 'perltoot', too?
Probably not sufficiently at this point!
>
>Giving that one line out of context probably won't help us help you.
>Perhaps you could show us more code, like the whole 'new' method (if not
>too long). What exactly does "doesn't seem to work properly" mean?
>
>Regards,
>
OK, here's the new method:
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
my $name = shift;
$self->{NAME} = $name;
bless($self);
$objtable{$name} = $self; <== likely something fishy here?
return $self;
}
and here's the find method:
sub find
#-------
{
my ($class, $name) = @_;
$objtable{$name};
}
and if I try this...
$fredsobj = dummy->find("fred");
print ($freds_class->name);
I get the following:
Can't call method "name" without a package or object reference at testit line 1
--
--------------------------------------------------------------
The opinions expressed above are solely those of Brian Lindsay
--------------------------------------------------------------
------------------------------
Date: Tue, 09 Feb 1999 05:02:32 GMT
From: nosp_am@kom.com (Chris Komuves)
Subject: Re: locking files
Message-Id: <36bfbf8e.47411899@news.avnl1.nj.home.com>
On Mon, 08 Feb 1999 14:09:10 -0800, dan <webmaster@macdaddyusa.com>
wrote:
>can someone give me a quick rundown on what locking files is? thanks
When you write to a log or data file, for instance, from a number of
different applications or instances of the same application, you have
to be careful to make sure two processes don't try to modify data in
the same file at the same time. Doing so could corrupt the file.
The solution is to do some sort of file locking. In the simpliest
case, have your script create a lockfile (just a blank file is fine)
before you start writing to a particular data file, and delete it when
the write is finished. Before you write to the datafile, check for
the existance of the lockfile. If there is one, wait (sleep) until it
is gone, then create your own lockfile, write the data, and delete
your lockfile. This way, only one process at a time can write to the
file.
-Chris
---
/========================^=============================================\
| Christopher S. Komuves | Email: ckNOSPAM@kom.com <== remove "NOSPAM" |
| KOMUVES CONSULTING | WWW: http://chris.kom.com/ |
\========================+=============================================/
(SPAMMER CANDY: nosp_am@kom.com )
------------------------------
Date: Mon, 08 Feb 1999 23:32:46 -0500
From: jamesht <jamesht@idt.net>
Subject: Re: Net::FTP - STOU??
Message-Id: <36BFBA6E.D1A40276@idt.net>
Hello,
I have a problem as well with Net::FTP. I need to use the STOU command to
upload a file and have it named some random, unique name, but I don't know
how to do this... I guess I have to get a socket connection and then print
the file to that socket?? Just have never seen an example, and can't seem
to get it...
Does anyone know of some sample code or a good example/reference of how to
do this?
Thank you in advance,
James
------------------------------
Date: Tue, 9 Feb 1999 00:05:27 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: NEWBIE Question about error checking string
Message-Id: <1dmxkes.nxgww811pdxutN@bay1-326.quincy.ziplink.net>
Bradley J. Gibby <bgibby@iinet.net.au> wrote:
> Try this...
>
> if ($FORM{'string1'} =~ /[0..5]/ || $FORM{'string1'} =~ / /) {
^^^^^^
I think you meant [0-5]. Character classes have their own syntax; you
cannot use the range operator like that. Your character class matches
zero, five, or period.
Of course, there's no reason for two regex matches...
/[0-5 ]/
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 9 Feb 1999 04:53:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: performance penalty: bareword, single quoting, double quoting
Message-Id: <79oevk$n74$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to
<mlehmann@prismnet.com>],
who wrote in article <79nrgl$qou$1@nnrp1.dejanews.com>:
> I have been wondering for a while if I should use barewords for the keys in
> hashes. I started off using:
>
> $hash{'key_value'}
>
> because I thought it was the least amount of work for perl to determine what I
> want.
>
> Because perl interpolates double quoted strings I avoided using:
>
> $hash{"key value"}
>
> Using that logic I figured that perl has to look through some table containing
> the method/function names to determine if a bareword is an executable.
Note that `key' in
$hash{key}
is not a bareword, it is quoted. Similarly in
foo key => $bar';
Hope this helps,
Ilya
------------------------------
Date: Mon, 08 Feb 1999 21:54:40 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Perl 'zine
Message-Id: <36BF5D1F.CC23FFF6@patriot.net>
Well...I'd like to feature things much the same way as TPJ..and have
articles for all versions of Perl, not just those on Unix. I use Perl on
win32 right now...I'd like to feature system administration scripts,
etc, for all platforms. CGI, etc...
John T. Jarrett wrote:
> This sounds like fun. When do we start?
>
> John
>
> Marquis de Carvdawg wrote:
>
> > Just throwing this out to everyone...
> >
> > I really enjoy TPJ...when it comes out. I get digests from
> > the ActiveState listservers, and I read the groups.
> >
> > Is there any desire for a monthly 'zine along the lines of TPJ?
> > I was thinking that it could start out online, and then possibly
> > go to soft-cover in the future. I would be glad to not only
> > subscribe to such a thing, but also contribute...
> >
> > I am asking this b/c I have added a 'Perl Corner' to an e-letter
> > that I edit, and it's been a real hit with newbies and more experienced
> > Perl programmers, as well...
> >
> > Carv
------------------------------
Date: Mon, 08 Feb 1999 23:40:14 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
To: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Perl 'zine
Message-Id: <36BFBC2E.A935CED0@ecpi.com>
I, um, (cough) haven't actually been doing perl long enough to have known to
get a TPJ when it came out last...so I haven't seen one. Read enough technical
rags, though. Seems there are quite a few writers right here that might help
get things kicked off. We could even go to print rather quickly in a two-color
blue-and-white format like the perl site itself.
I used to desktop publish 30-page gov permit applications that were numerous
tech reports tacked together. And now Word is actually easer (and about $600
cheaper) than Ventura Publisher was back then.
Imagine a Perl Mongers page with local news - shoot, we could even have it
printed in various global locales (like US, UK, Europe proper, Australia) so
the perl monger stuff could be more localized.
John
------------------------------
Date: Mon, 08 Feb 1999 21:36:30 -0800
From: "Tom Rouillard" <tomrou@ainet.com>
Subject: Re: Perl 'zine
Message-Id: <79ohi3$r5a$1@remarQ.com>
I'm interested. I'm not an expert at Perl, but I wish I was. There's so much
to learn and the Camel can sometimes step way over my head. I never learned
C. I stopped programming at PL1 and went into writing other things --
fiction, poetry, and finally news stories (reporter/editor for 7 years).
Now I find myself the manager of a newspaper web site and I'm learning to
program all over again. Except everything is different now. Perl has been
pretty easy to learn, but sometimes I feel like I'm flying blind or doing
things the hard way.
I'd love to contribute, but I'd love it more if I could learn something.
Let me know.
Tom
------------------------------------------------
Tom Rouillard | tom@modbee.com
Online News Manager | tomrou@ainet.com
The Modesto Bee | http://www.modbee.com
----------
In article <36BF5D1F.CC23FFF6@patriot.net>, Marquis de Carvdawg
<carvdawg@patriot.net> wrote:
> Well...I'd like to feature things much the same way as TPJ..and have
> articles for all versions of Perl, not just those on Unix. I use Perl on
> win32 right now...I'd like to feature system administration scripts,
> etc, for all platforms. CGI, etc...
>
> John T. Jarrett wrote:
>
>> This sounds like fun. When do we start?
>>
>> John
>>
>> Marquis de Carvdawg wrote:
>>
>> > Just throwing this out to everyone...
>> >
>> > I really enjoy TPJ...when it comes out. I get digests from
>> > the ActiveState listservers, and I read the groups.
>> >
>> > Is there any desire for a monthly 'zine along the lines of TPJ?
>> > I was thinking that it could start out online, and then possibly
>> > go to soft-cover in the future. I would be glad to not only
>> > subscribe to such a thing, but also contribute...
>> >
>> > I am asking this b/c I have added a 'Perl Corner' to an e-letter
>> > that I edit, and it's been a real hit with newbies and more experienced
>> > Perl programmers, as well...
>> >
>> > Carv
>
>
>
------------------------------
Date: Mon, 08 Feb 1999 18:18:18 -0800
From: Paul Chang <pchang@cybersource.com>
Subject: perl invoke unix command- help
Message-Id: <36BF9AEA.8B034826@cybersource.com>
Hi,
I like to grep the output of unix cmd and assign to a variable
like $number=`grep -w "order_number"
$dates_to_check/$dirs/to_scan/$logfile`;
but the var didn't get assigned.
I need to use system function call or use another way?
thanks,
Paul.
------------------------------
Date: Mon, 8 Feb 1999 22:35:50 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: Paul Chang <pchang@cybersource.com>
Subject: Re: perl invoke unix command- help
Message-Id: <Pine.A41.4.02.9902082234030.13514-100000@ginger.libs.uga.edu>
On Mon, 8 Feb 1999, Paul Chang wrote:
> I like to grep the output of unix cmd and assign to a variable
> like $number=`grep -w "order_number"
> $dates_to_check/$dirs/to_scan/$logfile`;
> but the var didn't get assigned.
> I need to use system function call or use another way?
Works for me. Maybe "order_number" isn't in the file.
#!/usr/local/bin/perl -w
use strict;
my $dates_to_check = '1999';
my $dirs = 'xxx';
my $logfile = 'dumpy';
open OUT, ">$dates_to_check/$dirs/to_scan/$logfile" or die $!;
print OUT "order_number 1\n";
print OUT "order_number 2\n";
close OUT;
my $number=
`grep -w "order_number" $dates_to_check/$dirs/to_scan/$logfile`;
print "number=\n$number\n";
### output:
### number=
### order_number 1
### order_number 2
Regards,
-Brad
------------------------------
Date: Mon, 8 Feb 1999 21:49:28 -0500
From: Paul Farber <farber@admin.f-tech.net>
Subject: perl password example
Message-Id: <Pine.LNX.3.96.990208213225.2282A-100000@admin.f-tech.net>
Can anyone provide me with a code example to encrypt a password in perl?
I have the basics of the crypt function, but I need to get the salt values
to encrypt the password. How do I get a good salt value?
Any code snippets helpfull!
Paul D. Farber II
Farber Technology
717-628-5303
farber@admin.f-tech.net
------------------------------
Date: Mon, 8 Feb 1999 22:42:03 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: Paul Farber <farber@admin.f-tech.net>
Subject: Re: perl password example
Message-Id: <Pine.A41.4.02.9902082240230.13514-100000@ginger.libs.uga.edu>
On Mon, 8 Feb 1999, Paul Farber wrote:
> Can anyone provide me with a code example to encrypt a password in perl?
> I have the basics of the crypt function, but I need to get the salt values
> to encrypt the password. How do I get a good salt value?
Because someone helped me with the same question:
+1 #!/usr/local/bin/perl -w
+2 use strict;
+3
+4 my @w = (
+5 'fortunate',
+6 'wu',
+7 );
+8 foreach my $password ( @w ) {
+9 print "$password = ", crypt($password, &salt), "\n";
+10 }
+11
+12 sub salt {
+13 # the following are the 64 chars that are valid in
+14 # a crypted password.
+15 my @chars = ('a'..'z', 'A'..'Z', '0'..'9', '/', '.');
+16 return $chars[rand(@chars)].$chars[rand(@chars)];
+17 }
+18
+19 ### output:
+20 ### fortunate = 3SJ.tAvHbvXHA
+21 ### wu = 2iizhwt6Ub0uQ
Cheers!
-Brad
------------------------------
Date: Tue, 9 Feb 1999 00:05:28 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Program needs compactification
Message-Id: <1dmxl8c.an40ilvc7xh9N@bay1-326.quincy.ziplink.net>
Uri Guttman <uri@home.sysarch.com> wrote:
> i think it violates some
> (which?) rules of fair play in perl hackery as it takes advantage of
> knowing how -p and -n are implemented.
Taking advantage of specific details is what makes Perl hackery
possible/fun.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 09 Feb 1999 04:05:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Python vs. Perl vs. tcl ?
Message-Id: <buOv2.5$Uh.333@nswpull.telstra.net>
In article <wkr9s0hfff.fsf@ifi.uio.no>,
Lars Marius Garshol <larsga@ifi.uio.no> writes:
>| 7) He says that Python documentation is better than Perl's and
>| mentions a "program" that generates the documentation in various
>| formats. I wonder if that author knew about perldoc and the pod2*
>| scripts.
>
> Vaguely. Do they automatically get the signatures of subroutines and
> methods right in the generated documentation?
There is no such thing as a signature for a perl sub (or method, which
is just a sub as well). So the answer to this would be 'No.'.
Pod has its limitations, some of which stem from the language, but
it's still a very good way of keeping documentation with the code that
it's about.
Martien
--
Martien Verbruggen |
Interactive Media Division | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: Tue, 9 Feb 1999 02:12:56 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Question: using write to format strings in a $variable or @list
Message-Id: <ebohlmanF6v7HK.MKI@netcom.com>
Jonathan Stowe <gellyfish@btinternet.com> wrote:
: On Mon, 08 Feb 1999 15:23:32 -0500 Ben Smith wrote:
: > I would like to be able to use format and write to generate a page held
: > only in
: > memory, without having to write to a file and then read it back in. Does
: > anyone
: > have an idea of how I might be able to do this?
: A tied filehandle - see the perltie manpage.
IO::Scalar (which creates a tied filehandle and provides the access
methods needed) would probably be helpful here.
------------------------------
Date: Tue, 09 Feb 1999 02:07:58 GMT
From: "Ian Wilkinson" <ian@no-spam4site.co.uk>
Subject: Re: Rounding for Euro currency
Message-Id: <01be53d0$e4ce9780$LocalHost@quibhrgm>
Alan Barclay <gorilla@elaine.drink.com>
wrote in article <918522936.105828@elaine.drink.com>...
> Multiply by 20, round to the nearest integer as normal, then divide
> by 20.
>
> $new=sprintf("%9.0d",$old*20)/20;
But that rounds down, not to the NEAREST 1/20th.
(eg, 12.9499 becomes 12.9, rather than 12.95)
Also, I should have said that the result ought to be shown to two decimal
places.
$new=sprintf("%9.2f",sprintf("%9.0d",$old*20)/20);
.... does the second part but not the first.
------------------------------
Date: Tue, 9 Feb 1999 00:05:29 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Rounding for Euro currency
Message-Id: <1dmxm1n.j4ewiz1qa0ekwN@bay1-326.quincy.ziplink.net>
Ian Wilkinson <ian@no-spam4site.co.uk> wrote:
> But that rounds down, not to the NEAREST 1/20th.
> (eg, 12.9499 becomes 12.9, rather than 12.95)
>
> Also, I should have said that the result ought to be shown to two decimal
> places.
>
> $new=sprintf("%9.2f",sprintf("%9.0d",$old*20)/20);
>
> .... does the second part but not the first.
>
Generic rounding:
$new = sprintf "%9.2d", $old + .5;
Rounding to the nearest 20th:
$new = sprintf("%9.2f", sprintf("%9.0d", $old*20+.5) /20);
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 08 Feb 1999 21:20:36 -0500
From: CJ <spam@spam.com>
Subject: send form to SMTP server
Message-Id: <36BF9B74.65556BFB@spam.com>
I would like to be able to send a form to an SMTP server so that it can
be emailed after being submitted. the smtp server is not the same
machine that the web server is on.
does anyone have an example CGI script for this?
apreciated,
JC.
------------------------------
Date: Mon, 08 Feb 1999 23:21:15 -0500
From: jamesht <jamesht@idt.net>
Subject: sending mail from nt with perl 4.x...??
Message-Id: <36BFB7BB.D4D96518@idt.net>
Hello,
I'm sorry to ask you about this terribly hobbled system, but that's what
I have to work with.
How does one send mail from nt without using a module?? Are there good
libraries, or a good reference? All I've ever seen has either been for
sendmail or for some win32 module...
Thanks in advance,
James
------------------------------
Date: 08 Feb 1999 22:56:35 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: sending mail from nt with perl 4.x...??
Message-Id: <m3ww1sf7cc.fsf@moiraine.dimensional.com>
jamesht <jamesht@idt.net> writes:
> How does one send mail from nt without using a module??
One creates an implementation of the protocol specified in
rfc 821.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Mon, 8 Feb 1999 19:42:39 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple Question About a Scalar
Message-Id: <fq3o97.t89.ln@magna.metronet.com>
Spike White (spike_YYwhiteYY@YYdellYY.com) wrote:
: $date = system("date +\%m\%d");
: Double-quoted strings are variable-interpolated.
True enough.
: Meaning that
: perl is interpreting %m as a (currently-undefined) hash.
*Not* meaning that perl is interpreting %m as a hash, since
you cannot interpolate hashes, only scalars and arrays.
--------------------
#!/usr/bin/perl -w
use strict;
my %m = qw(one 1 two 2 three 3);
my $n = "interpreting %m as a (currently-undefined) hash";
print "$n\n";
--------------------
prints:
interpreting %m as a (currently-undefined) hash
take out the 'my %m' line, and you get the same output.
: Since
: it's currently undefined, in this scalar context I'd guess it has a value
: of 0.
Your guess is wildly far afield.
Please don't answer with guesses.
There are enough confused folks about already without feeding
them red herrings.
It isn't in scalar context either.
system() provides list context.
=item system LIST
=item system PROGRAM LIST
: What surprises me is that you don't get two 0's. If I'm correct, it's
: as if you invoked date as so:
: date +00
I don't think so.
: Pete Holsberg wrote in message <79fi77$171$1@lawrenceville.mccc.edu>...
: >I would like to create a filename from a string with the
: >month and day (eg, 0204) appended.
: >
: >I used
: > $date=system("date +%m%d");
The problem is not scalar vs. list context.
The problem has nothing to do with hash data structures.
The problem is that Pete did not read the description of the
function that he is using.
: >How can I get what I want?
The description of system() in the perlfunc.pod man page says
how to capture the _output_ of external programs.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 8 Feb 1999 19:48:22 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String splitting.
Message-Id: <654o97.t89.ln@magna.metronet.com>
Frank de Bot (debot@xs4all.nl) wrote:
: Why you don't explain it?
Could you explain how your code "gets the part of the string
before the full stop"?
: It's simple
Yes, but _you_ don't have it right either.
Type in some of those 'perldoc' things below and read them...
: @array = split(/ /, $string);
: Between the spaces must come what should be the split section in the string. In
: this case it is a single space.
: You can call each array with: $array[0] (The first) $array[1] (The second)
I think you have answered some _other_ question.
Was this meant to be a followup to a different thread?
: Scratchie wrote:
: > om7@cyberdude.com wrote:
: > : I've got a string, something like $string = abcd.efg, say. Can someone remind
: > : me how I would get the part of of the string before the full stop.
: >
: > perldoc -f split
: > perldoc -f index
: > perldoc perlre
: >
: > Depending on what you want to do with it.
[ Don't quote signatures. It indicates a clue deficiency ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 9 Feb 1999 00:05:33 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: String splitting.
Message-Id: <1dmxmeb.175qkwxzwxnrzN@bay1-326.quincy.ziplink.net>
<om7@cyberdude.com> wrote:
> I've got a string, something like $string = abcd.efg, say. Can someone remind
> me how I would get the part of of the string before the full stop.
There is no full stop in that string. ;-)
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 09 Feb 1999 05:08:12 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: testing for scalar/list/array
Message-Id: <36BFC499.5D9CBD9F@home.com>
Ronald J Kimball wrote:
>
> $ref_inside = \($one, $two, @three);
>
> is equivalent to:
>
> $ref_inside = (\$one, \$two, \@three);
As documented in perlref.
>
> which is equivalent to:
>
> $ref_inside = \@three;
As expected in scalar context.
>
> So you get a ref to an array.
>
> $ref_outside = \test();
>
> calls test() in a list context, returning (1, 2, 'a', 'b', 'c', 'd').
^^^^^^^^^^^^
Why is this in a list context? It looks like it should be scalar
context to me.
I think one should be able to tell the context of an expression just by
looking at it. Perhaps there is some subtle (or maybe obvious) rule
that I'm not aware of.
Where is it documented that '\' forces list context on its operands? I
could not find it in perlop. This is quite different from the other
symbolic unary operators and most other operators as well.
I don't know if I should have been surprised or not, but I was.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 9 Feb 1999 00:26:17 +0300
From: vitus@wagner.rinet.ru (Victor Wagner)
Subject: Re: Would love UNIX program that could read Excel binary file...
Message-Id: <79nkpp$d6v$1@wagner.wagner.home>
wsherrin <wsherrin@eccms1.dearborn.ford.com> wrote:
: Hi techical friends -
: Been surfing for a couple of days, but no luck...
: Does anyone know of a FREE Magical Perl module or
Try http://www.ice.ru/~vitus/catdoc/xls2csv.html
--
--------------------------------------------------------
I have tin news and pine mail...
Victor Wagner @ home = vitus@wagner.rinet.ru
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4850
**************************************