[15985] in Perl-Users-Digest
Perl-Users Digest, Issue: 3397 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 16 21:05:54 2000
Date: Fri, 16 Jun 2000 18:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <961203912-v9-i3397@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 16 Jun 2000 Volume: 9 Number: 3397
Today's topics:
Brackets for Perl? Not Work? <weiwa592@student.liu.se>
Re: Brackets for Perl? Not Work? <tina@streetmail.com>
Re: Brackets for Perl? Not Work? <rootbeer@redcat.com>
Re: Brackets for Perl? Not Work? <weiwa592@student.liu.se>
Re: Brackets for Perl? Not Work? <tina@streetmail.com>
Can you help me? <weiwa592@student.liu.se>
Re: Can you help me? (David Bell)
Re: Can you help me? <rootbeer@redcat.com>
Re: flock() and blocking lock? <callgirl@la.znet.com>
Re: flock() and blocking lock? <callgirl@la.znet.com>
Re: GIMP on G4 Mac <gasior@snet.net>
Re: GIMP on G4 Mac (Peter L. Berghold)
Re: help: how to let it go <rootbeer@redcat.com>
Re: how do I "redirect" a substitution? <webqueen@my-deja.com>
Re: How do I print out the result of a @diff ??? please <rootbeer@redcat.com>
how to redirect stderr and stdout to same file vivienfei@my-deja.com
Re: how to redirect stderr and stdout to same file <tina@streetmail.com>
Re: I can't figure this one out... (Newbie question) (David Bell)
Re: I can't figure this one out... (Newbie question) (Craig Berry)
Re: I can't figure this one out... (Newbie question) (David Bell)
Re: I can't figure this one out... (Newbie question) <uri@sysarch.com>
Re: I can't figure this one out... (Newbie question) <lr@hpl.hp.com>
Interfacing PERL and C libraries <vikas@navya.com>
NET::SMTP nikn@hotmail.com
Re: NET::SMTP <rootbeer@redcat.com>
Re: NET::SMTP (Eric Bohlman)
Re: read single chars <lr@hpl.hp.com>
Subclassing Exporter::import <aperrin@famine.DEMOG.Berkeley.EDU>
Re: system() in WinNT4-service <rootbeer@redcat.com>
Re: Text substitution problem <tina@streetmail.com>
Re: Text substitution problem (Craig Berry)
Re: Using link checking scripts with Dynamo server (new <rootbeer@redcat.com>
Re: using mail-sender with NT scheduler service <geeky2@gte.net>
Very Strange Behaviour <jacobyte@goattee.co.uk>
What is wrong? <weiwa592@student.liu.se>
Re: What is wrong? <lauren_smith13@hotmail.com>
Re: What is wrong? <tina@streetmail.com>
Re: Writing line of death to log (Craig Berry)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 17 Jun 2000 00:22:31 +0200
From: Wang Wei <weiwa592@student.liu.se>
Subject: Brackets for Perl? Not Work?
Message-Id: <394AA8A7.88D4492E@student.liu.se>
Hi
I am just testing the learning perl code.
However, the print fuction must have ()
for example:
print("Hello");
and print "Hello"; does not work. Why?
The book is wrong??
Question 2.
I want to send a mail in a program:
open (MAIL "|mail YOUR_ADDRESS_HERE");
print( MAIL "bad news: ....\n";
however! it can not let me input MY_ADDRESS-HERE, and mail never sent
why?
thanks
ww
------------------------------
Date: 16 Jun 2000 22:34:06 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Brackets for Perl? Not Work?
Message-Id: <8iea0t$4mbdj$11@fu-berlin.de>
hi,
Wang Wei <weiwa592@student.liu.se> wrote:
> I am just testing the learning perl code.
> However, the print fuction must have ()
> for example:
> print("Hello");
you can also do:
print "Hello";
> and print "Hello"; does not work. Why?
> The book is wrong??
what does the book say? which book is it?
> Question 2.
> I want to send a mail in a program:
> open (MAIL "|mail YOUR_ADDRESS_HERE");
open (MAIL "|mail YOUR_ADDRESS_HERE") or die $!;
> print( MAIL "bad news: ....\n";
print MAIL "bad news: ....\n";
and don't forget to send the right headers (depending
on what you mail program needs)
is that a little help?
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Fri, 16 Jun 2000 15:34:48 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Brackets for Perl? Not Work?
Message-Id: <Pine.GSO.4.10.10006161531310.21108-100000@user2.teleport.com>
On Sat, 17 Jun 2000, Wang Wei wrote:
> However, the print fuction must have ()
> for example:
>
> print("Hello");
>
> and print "Hello"; does not work. Why?
You're doing it wrong. Maybe you should make a small, self-contained
program that shows what you're trying.
> I want to send a mail in a program:
>
> open (MAIL "|mail YOUR_ADDRESS_HERE");
> print( MAIL "bad news: ....\n";
>
>
> however! it can not let me input MY_ADDRESS-HERE, and mail never sent
Again, you're doing it wrong. Perhaps you don't have a mail program with
that interface on your system. Maybe you didn't put your valid e-mail
address where it says YOUR_ADDRESS_HERE. But you should probably make a
small, self-contained program that shows what you're trying. Else we can
merely guess what's wrong.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 17 Jun 2000 00:51:36 +0200
From: Wang Wei <weiwa592@student.liu.se>
Subject: Re: Brackets for Perl? Not Work?
Message-Id: <394AAF78.BE7DD1BC@student.liu.se>
Hi Tina
I am testing the code as follows: Please check
#!/usr/local/bin/perl
&init_words();
print("what is your name?");
$name =<STDIN>;
chomp($name);
if ($name =~ /^randal\b/i)
{
print("Hello, Randal! How good of you to be here!\n");
}
else
{
print("Hello, $name!\n");
print("What is secret word?");
$guess = <STDIN>;
chomp($guess);
while (! good_word($name,$guess))
{
print ("Wrong, try again. What is your secret word?");
$guess=<STDIN>;
chomp($guess);
}
}
#dbmopen (%last_good "lastdb", 0666);
#$last_good{$name} = time;
#dbmclose (%last_good);
sub init_words{
while($filename=<*.secret>){
open(WORDSLIST,$filename)||die "cannot open $filename:$!";
if(-M WORDSLIST < 7){
while ($name=<WORDSLIST>){
chomp($name);
$word=<WORDSLIST>;
chomp($word);
$words{$name}=$word;
}
}else {
rename($filename, "$filename.old")||die "cannot rename $filename to
$filename.old: $!";
}
close (WORDSLIST);
}
}
sub good_word{
my($somename,$someguess)=@_;
$somename =~ s/\W.*//;
$someguess =~ tr/A-Z/a-z/;
if($somename eq "randal"){
return 1;
}elsif (($words{$somename}||"groucho") eq $someguess){
return 1;
}else {
print("try to send mail\n");
open(MAIL,"|mail YOUR_ADDRESS_HERE"); ?????????????????
print (MAIL "bad news: $somename guessed $someguess\n");??????????
close (MAIL);
return 0;
}
}
Tina Mueller wrote:
>
> hi,
> Wang Wei <weiwa592@student.liu.se> wrote:
>
> > I am just testing the learning perl code.
> > However, the print fuction must have ()
> > for example:
>
> > print("Hello");
>
> you can also do:
> print "Hello";
>
> > and print "Hello"; does not work. Why?
> > The book is wrong??
>
> what does the book say? which book is it?
>
> > Question 2.
>
> > I want to send a mail in a program:
>
> > open (MAIL "|mail YOUR_ADDRESS_HERE");
>
> open (MAIL "|mail YOUR_ADDRESS_HERE") or die $!;
>
> > print( MAIL "bad news: ....\n";
>
> print MAIL "bad news: ....\n";
>
> and don't forget to send the right headers (depending
> on what you mail program needs)
>
> is that a little help?
>
> tina
>
> --
> http://tinita.de \ enter__| |__the___ _ _ ___
> tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
> search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 16 Jun 2000 23:49:44 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Brackets for Perl? Not Work?
Message-Id: <8ieeen$4n6bv$1@fu-berlin.de>
hi,
Wang Wei <weiwa592@student.liu.se> wrote:
> I am testing the code as follows: Please check
what is your perl question? you said print works
only with brackets. now you're sending the
whole script and you don't say what's wrong.
> #!/usr/local/bin/perl
#!/usr/local/bin/perl -w
that should be a little help though the script seems to be correct
> [...]
> }else {
> print("try to send mail\n");
> open(MAIL,"|mail YOUR_ADDRESS_HERE"); ?????????????????
open(MAIL,"|mail YOUR_ADDRESS_HERE") or die "Cannot open pipe for mail: $!";
so, and now tell us what's going wrong if you do
perl script.pl
(as tom said, you perhaps don't have the program
mail on your computer. if so, perl will tell you that now.)
and don't quote the whole posting again, just that what you
refer to.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Sat, 17 Jun 2000 00:32:53 +0200
From: Wang Wei <weiwa592@student.liu.se>
Subject: Can you help me?
Message-Id: <394AAB15.5FAAEE93@student.liu.se>
Hello,
I am just learning perl.
Yes I agree with you learning perl is a good book.
But I have also had some problem with Charpter 1
in the sub good-word{}
there is .....
open MAIL, "|mail YOUR_ADDRESS_HERE";
print MAIL "bad news:$somename guessed $simeguess\n";
close MAIL;
return 0;
.....
I can not send any mail because the destination always
YOUR_ADDRESS_HERE@.. However, the book says it alow user to input the
address I can not make it work.
Please tell me what was wrong?
thanks
------------------------------
Date: 16 Jun 2000 22:52:18 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: Can you help me?
Message-Id: <20000616185218.02902.00001123@ng-cg1.aol.com>
>there is .....
> open MAIL, "|mail YOUR_ADDRESS_HERE";
> print MAIL "bad news:$somename guessed $simeguess\n";
> close MAIL;
> return 0;
>.....
>
>
>I can not send any mail because the destination always
>YOUR_ADDRESS_HERE@.. However, the book says it alow user to input the
>address I can not make it work.
>
>Please tell me what was wrong?
Well, I haven't looked at that one specifially, but I'd guess YOUR_ADDRESS_HERE
should be $YOUR_ADDRESS_HERE? Does it prompt you for your address?
-------------------------
David Bell - Otherwise known as DB7654321
Remember to remove nospam, notrash or anything odd looking from my email
address. :)
------------------------------
Date: Fri, 16 Jun 2000 16:03:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Can you help me?
Message-Id: <Pine.GSO.4.10.10006161602160.21108-100000@user2.teleport.com>
On Sat, 17 Jun 2000, Wang Wei wrote:
> open MAIL, "|mail YOUR_ADDRESS_HERE";
> I can not send any mail because the destination always
> YOUR_ADDRESS_HERE@.. However, the book says it alow user to input the
> address I can not make it work.
That means that you should put your own e-mail address in place of the
marker YOUR_ADDRESS_HERE in the source code. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 16 Jun 2000 15:42:15 -0700
From: Kira <callgirl@la.znet.com>
Subject: Re: flock() and blocking lock?
Message-Id: <394AAD47.648F7860@la.znet.com>
Marc Haber wrote:
> given the following code snippet (on a Linux system,
> $FHNAME pointing to a file on a local FS):
> use Fcntl qw(:DEFAULT :flock);
> if( open FH, "< $FHNAME" )
> {
> print "trying to hget lock on $FHNAME\n";
> unless( flock( FH, LOCK_EX ) )
> {
> # A
> print "can't get lock on $FHNAME: $!";
> }
> else
(snipped)
> Any hints will be appreciated.
There are other syntax you might try, after
crossing your fingers. No promises on this
but perhaps you might see something which
may help.
use Fcntl qw(:DEFAULT :flock);
open(FILEHANDLE, "< $your_file") or die "Open Failed For File: $!";
unless (flock(FILEHANDLE, LOCK_SH | LOCK_NB))
{
$| = 1; # flush it
print "Trying To Attain Lock \n";
flock(FILEHANDLE, LOCK_SH) or die "Lock Failed For File: $!";
print "Lock Attained \n"
}
You could also experiment with a system type call:
sysopen(FILEHANDLE, "your file name", O_WRONLY | O_CREAT) or die...
etc...
There are some risks involved with sysopen. Be sure
to research all syntax associated with this method.
Good luck on this.
Kira
------------------------------
Date: Fri, 16 Jun 2000 15:55:43 -0700
From: Kira <callgirl@la.znet.com>
Subject: Re: flock() and blocking lock?
Message-Id: <394AB06F.DD67FB85@la.znet.com>
Kira wrote:
>
> Marc Haber wrote:
Sorry.. add a semicolon to this line:
print "Lock Attained \n";
My mistake and I hope you read this
or catch this syntax error.
Kira
------------------------------
Date: Fri, 16 Jun 2000 22:22:48 GMT
From: Robert Gasiorowski <gasior@snet.net>
Subject: Re: GIMP on G4 Mac
Message-Id: <394AB748.FE0927DB@snet.net>
Sorry, wrong group
------------------------------
Date: Sat, 17 Jun 2000 00:22:25 GMT
From: peter@berghold.net (Peter L. Berghold)
Subject: Re: GIMP on G4 Mac
Message-Id: <slrn8kldv0.7v7.peter@localhost.localdomain>
On Fri, 16 Jun 2000 12:43:45 GMT, concerning discussion about GIMP on G4 Mac
Robert Gasiorowski formed electrons and spake thusly:
*]I'm trying to install GIMP on G4 running LinuxPPC 2000, but when I run
*]configure
*]
Uhhmmmm... is it just me? Did I misconfigure my perl? I try doing a
perldoc -f GIMP and it doesn't give me back anything....
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Peter L. Berghold http://www.berghold.net
Peter@Berghold.Net Linux Bigot at Large
"Linux renders ships... Windows NT renders ships useless..."
------------------------------
Date: Fri, 16 Jun 2000 15:21:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: help: how to let it go
Message-Id: <Pine.GSO.4.10.10006161521080.21108-100000@user2.teleport.com>
On Fri, 16 Jun 2000, Yongfeng Luo wrote:
> I have a perl file to be used in a web page. It works fine in shell. But
> no resonpse when executing from browser. No any err message.
When you're having trouble with a CGI program in Perl, here's a handy
troubleshooting guide to get you back on track.
http://www.smithrenaud.com/public/troubleshooting_CGI.html
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 17 Jun 2000 00:47:36 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: Re: how do I "redirect" a substitution?
Message-Id: <8iehr7$ik5$1@nnrp1.deja.com>
Thanks for the replies. The double ='s isn't too pretty is it? I'd hoped
for something a little more elegant.
Larry, I respectfully submit that this would fit very nicely into Perl
6.0:
$scalar1 =~ s/cat/dog/gi,$scalar2;
While I'm at it a "writeln" equivalent would be nice. How often do we
use:
print "$scalar\n";
where
println $scalar;
would be neat.
Yes yes I know it would be VERY EASY to define a sub for this, but still
it would be a nice addition to the language. Subs for chop and chomp
would be easy as well but they are in the language aren't they? I'd use
println a lot more than either of those.
-WQ
In article <8iaolv$ruf$1@nnrp1.deja.com>,
webqueen, queen of the web <webqueen@my-deja.com> wrote:
>
>
> I don't see this in the docs or camel. Often I want to use a regex to
> extract or modify one string and store that result in another. Usually
I
> do something like:
>
> $s1='cat dog';
> .
> .
> .
> $s2=$s1;
> $s2 =~ s/cat/mouse/;
>
> Is there a way to do the last 2 lines in one statement? Like split for
> example, has the optional , at the end:
>
> @l= split / /,$myvar;
>
> I'd like to do something like that:
>
> $s2 =~ s/cat/mouse/,$s1;
>
> where we could still use switches if we wanted to:
>
> $s1 =~ s/cat/mouse/ig,$s1
>
> --
> Time is nature's way of preventing everything from happening at once.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
Time is nature's way of preventing everything from happening at once.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 16 Jun 2000 15:40:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How do I print out the result of a @diff ??? please. Small sample code
Message-Id: <Pine.GSO.4.10.10006161538130.21108-100000@user2.teleport.com>
On Fri, 16 Jun 2000, Robert Chalmers wrote:
> I wonder if anyone knows how to print out the result of this diff .
If you want output like the diff program generates, that shouldn't be hard
to do. But in that case, maybe you should simply run that program. :-)
Still, a little code to print the results of an Algorithm::Diff might be
something good to add to the module. You should send a patch to the
module's author. :-)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 16 Jun 2000 23:35:18 GMT
From: vivienfei@my-deja.com
Subject: how to redirect stderr and stdout to same file
Message-Id: <8iedjm$g16$1@nnrp1.deja.com>
I can't figure out how to redirect both stdout and stderr to same file
in my perl script. Please help. Thanks in advance
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Jun 2000 23:55:03 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: how to redirect stderr and stdout to same file
Message-Id: <8ieeon$4n6bv$2@fu-berlin.de>
hi,
vivienfei@my-deja.com wrote:
> I can't figure out how to redirect both stdout and stderr to same file
> in my perl script. Please help. Thanks in advance
perldoc -q STDERR
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 16 Jun 2000 22:32:45 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out... (Newbie question)
Message-Id: <20000616183245.02926.00001048@ng-cg1.aol.com>
Wow, this is a fast responding newsgroup. :) I'm still trying out all the
suggestions. Well, I think someone asked what these scripts were for. If so,
here's a brief history of 'em:
I use IP masquerading in Linux to share my dialup modem connection to the net
with 5 people. I could figure out diald, so I wrote a very simple shell script
to start /sbin/ifup ppp1. All worked great for about 2 minutes. PPPd didn't
create a lock file as it was supposed to, so each time someone ran the connect
script when they were (unknowingly) connected, it would redial the modem.
…This became extremely annoying (especially during a long download). So I
improved the connect script the Perl. Now it first checks to see if I'm
already connected (by 'system(/sbin/ifconfig | grep ppp0)' which returns 0 if
connected.) before dialing. Now it's time to improve the disconnect script, as
it's very easy to not know when someone else is using the net when you
disconnect. I first thought that the best way to check was each time the
connect script was executed, it would add 1 to a number stored in a file (and
the opposite for the disconnect, when that number was 0 it would disconnect).
But, I soon realized that if a user were to run the connect script more than
once without the disconnect, It wouldn't work so well. Instead, I decided to
have the user's username entered into a file at connect (while making sure that
it's not entered in there twice), and removed when the disconnect script is run
until no names are left, at which point it would disconnect. I think that
brings everything up to present. Right now I'm working on the part for the
connect script. I hope this may have cleared something up. Thanks again for
your in-depth, quick responces! If you need [or would like] to know anything
else, just ask!
-------------------------
David Bell - Otherwise known as DB7654321
Remember to remove nospam, notrash or anything odd looking from my email
address. :)
------------------------------
Date: Fri, 16 Jun 2000 22:33:06 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: I can't figure this one out... (Newbie question)
Message-Id: <sklap22dis470@corp.supernews.com>
Drew Simonis (care227@attglobal.net) wrote:
: Craig Berry wrote:
: >
: > : open(USERINFO, "id -un|") || die "Can't open id -un $!";
: > : $userinfo = <USERINFO>;
: > : close(USERINFO);
:
: Bah. Why use that syntax when you are only getting a logon name?
:
: chomp($userinfo = `id -un`);
Note that (a) I didn't write that, and (b) the OP's version allows easier,
more granular error detection (if one adds a check to the close, of
course).
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 16 Jun 2000 23:10:27 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out... (Newbie question)
Message-Id: <20000616191027.02902.00001128@ng-cg1.aol.com>
WoooHoooo! It works! Here is the completed code (comments, suggestions,
demands are accepted):
#!/usr/bin/perl -w
use strict;
my $true = "no";
my $num = 0;
my $userfile = "/home/david/perl/users";
open(USER, $userfile) or die "Can't open $userfile $!\n";
my @user = split ' ', <USER>;
close(USER) or die "can't close $userfile: $!\n";
chomp(my $userinfo = `id -un`) or die "Can't execute id -un $!\n";
open(WRITEUSER, ">>$userfile") || die "Can't open $userfile $!\n";
while($true eq "no") {
if ($user[$num] eq $userinfo) {
print "\n\tYou're already using the internet.\n\n";
$true = "yes";
} elsif ($num < 9) {
$num = ++$num;
} else {
print WRITEUSER "$userinfo ";
print "\n\tYou're on the list now!\n\n";
$true = "yes";
}
}
close(WRITEUSER) or die "Can't close $userfile $!\n";
I got the 'Use of uninitialized value at ./user line 12.' error until I put a
word (I used test) in $userfile. All appears working well now. Now all I've
gotta do is (somehow (maybe this could be a sub routine?)) merge this into the
connect script, and figure out the disconnect. :) ...For the disconnect, I've
got a question: How can I go about removing one username from $userfile? When
the disconnect script is executed, it is supposed to remove that user's name
from $userfile, until no names are left, then it'll disconnect. Thanks again!
-------------------------
David Bell - Otherwise known as DB7654321
Remember to remove nospam, notrash or anything odd looking from my email
address. :)
------------------------------
Date: Fri, 16 Jun 2000 23:44:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I can't figure this one out... (Newbie question)
Message-Id: <x7og515gy7.fsf@home.sysarch.com>
>>>>> "DB" == David Bell <db7654321@aol.comspamsux> writes:
DB> WoooHoooo! It works! Here is the completed code (comments,
DB> suggestions, demands are accepted):
well, you have ignore many suggestions and critiques. so why should we
send you more?
DB> #!/usr/bin/perl -w
DB> use strict;
DB> my $true = "no";
like larry sai, using a string for a boolean marker is weak
DB> $num = ++$num;
and that is a major loser line. you really should read perlop and learn
what ++ does. you don't need to assign it back to itself. that would
more properly be:
$num = $num + 1 ;
or
$num += 1 ;
DB> } else {
DB> print WRITEUSER "$userinfo ";
DB> print "\n\tYou're on the list now!\n\n";
DB> $true = "yes";
or any string that is not 'no'. just do it like larry said and use last.
while( 1 ) {
if ( blah ) {
more blah
}
else {
print WRITEUSER "$userinfo ";
print "\n\tYou're on the list now!\n\n";
last ;
}
}
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Jun 2000 17:12:59 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I can't figure this one out... (Newbie question)
Message-Id: <MPG.13b46261338d48d798ab98@nntp.hpl.hp.com>
In article <x7og515gy7.fsf@home.sysarch.com> on Fri, 16 Jun 2000
23:44:50 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "DB" == David Bell <db7654321@aol.comspamsux> writes:
...
> DB> $num = ++$num;
>
> and that is a major loser line. you really should read perlop and learn
> what ++ does. you don't need to assign it back to itself. that would
> more properly be:
>
> $num = $num + 1 ;
> or
> $num += 1 ;
You omitted the obvious:
$num++;
or
++$num;
I prefer the last from my old C days, because it doesn't have to save a
copy to use as a potential rvalue. But in Perl, there is no way that
minute distinction can matter.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Jun 2000 20:09:49 -0400
From: Vikas Aggarwal <vikas@navya.com>
Subject: Interfacing PERL and C libraries
Message-Id: <394AC1CD.AAD2AFBC@navya.com>
I am trying to interface a C library with a Perl module.
I have a C library which calls a function to read a config file and then
calls
a 'test' function. While linking with this C library, the main routine sets
the 'readconf' and the 'test' function pointers.
test.h
------
int (*readconfig_func)();
int (*test_func)();
lib.c
------
lib_main()
{
(*readconfig_func)(cfile);
(*test_func)();
}
main.c
------
do_test() { }
read_config() { }
main()
{
int read_config(), do_test();
readconfig_func = read_config;
test_func = do_test;
lib_main();
}
What I am trying to do is create a PERL module, and be able to call
lib_main() function, with the readconfig and test functions set to PERL
routines.
My test.pl file has the two subroutines, and then calls a XS function.
sub read_config { ... }
sub do_test { ... }
&test_main; # defined in test.xs
My test.xs file contains the following:
call_readconfig()
CODE:
...
perl_call_pv("read_config", G_SCALAR);
... (stuff from manual/html/pod/perlcall.html here)
test_main()
CODE:
int call_readconfig(); /* defined above */
readconfig_func = call_readconfig;
Needless to say, this does not work when I run test.pl
1) the test_main() complains about call_readconfig() being undefined.
I think this needs to be XS_call_readconfig, but I dont know the
proper way to define this in the .xs file.
2) the call_readconfig() seems to be called with an incorrect number
of parameters for some reason (from libmain()).
3) call_readconfig() complains about not being able to find
"read_config.al" in @INC (i.e. it does not find the perl
function in test.pl).
Any pointers? I am pretty stumped.. using Perl 5.004_04.
-vikas
vikas@navya.com
------------------------------
Date: Fri, 16 Jun 2000 22:52:32 GMT
From: nikn@hotmail.com
Subject: NET::SMTP
Message-Id: <8ieb3e$ehn$1@nnrp1.deja.com>
Hi, I am trying to ensure that during user registration, the email
addresses that are entered are valid. I have been reading up on
NET::SMTP and it seems that the VERIFY method can be used to do so.
I have not be able to successfully use the method to track the validity
of an email address.
Has this been used by someone? a small code sample would be a great help
thanks
_nik
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 16 Jun 2000 16:15:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: NET::SMTP
Message-Id: <Pine.GSO.4.10.10006161614480.21108-100000@user2.teleport.com>
On Fri, 16 Jun 2000 nikn@hotmail.com wrote:
> Hi, I am trying to ensure that during user registration, the email
> addresses that are entered are valid.
Can't be done. See the FAQ. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Jun 2000 23:17:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: NET::SMTP
Message-Id: <8iecif$8eg$2@nntp9.atl.mindspring.net>
nikn@hotmail.com wrote:
: Hi, I am trying to ensure that during user registration, the email
: addresses that are entered are valid. I have been reading up on
: NET::SMTP and it seems that the VERIFY method can be used to do so.
: I have not be able to successfully use the method to track the validity
: of an email address.
That method depends on being able to directly contact a mail server
that's set to honor SMTP 'vrfy' requests, something many mail servers
refuse to do. And of course it doesn't work if the address in question
is valid, but doesn't point at a full-time mail server (note that
contacting your local MTA and trying to do a 'vrfy' is completely useless).
If you haven't already, read the section in perlfaq9 about email address
verification.
------------------------------
Date: Fri, 16 Jun 2000 17:15:30 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: read single chars
Message-Id: <MPG.13b462ff91737f4098ab99@nntp.hpl.hp.com>
In article <H2x25.36$LA4.40100@news.pacbell.net> on Fri, 16 Jun 2000
14:38:09 -0700, Trevor Sky Garside <trevor@trevorsky.com> says...
> "Tim" <tcuffel@exactis.com> wrote in message
> news:mBu25.2725$Ck1.292331@den-news1.rmi.net...
> > Oliver Soeder wrote in message
> <394A71A2.788F9B12@ai-lab.fh-furtwangen.de>...
> > >$chars=<STDIN>
> > >
> > >This reads in a string, how can i read it as single chars?
> >
> > Do this first:
> >
> > $/ = \1;
> >
> > $/ is the input separator, normally set to \n. However, if you set
> > it to a reference to an integer, it read no more than that many
> > characters at a time. This is to support fixed length non delimited
> > records, but it works for your situation as well.
>
> Don't forget to set $/ back to "\n" when you're done.
Not the best advice, because maybe it wasn't "\n" previously.
The best advice is to localize the change in a block:
{
local $/ = \1;
...
}
Then the previous value is restored automatically on block exit.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Jun 2000 17:14:16 -0700
From: Andrew Perrin - Demography <aperrin@famine.DEMOG.Berkeley.EDU>
Subject: Subclassing Exporter::import
Message-Id: <u5kn1klf9k7.fsf@famine.DEMOG.Berkeley.EDU>
Greetings.
I want to be able to pass an option to an Exporting package; the
option is 'no_logger' and tells the package to avoid opening a
separate logging script that is part of the application. The package
is called DemogTrak, and I would like to use it such:
use DemogTrak qw/no_logger Getname/;
I tried to implement it such:
package DemogTrak;
require Exporter;
use Date::Manip;
@ISA=qw/Exporter/;
@EXPORT_OK=qw/Getname Shortdate now safeTeX dispatch min max students/;
sub import{
$args=join ("\t", @_);
if ($args=~m/no_logger/i){
$args=~s/no_logger//i;
@_=split(/\t+/, $args);
}else{
unless ($^O =~ /win/i) {
open(STDERR, '| /home/davis/app2/dt2/log.pl') || die "Ouch! $!\n";
}
}
Exporter::import(@_);
}
This solution successfully catches the no_logger option and does the
right thing with the log; unfortunately, it breaks the
Exporter::import routine; the regularly-import()able subroutines are
not imported.
Summary: I need to search for, act on, and remove a given string from
the arguments to import(), passing the remainder of the arguments to
Exporter's import().
Any advice?
Thanks.
--
---------------------------------------------------------------------
Andrew J. Perrin - aperrin@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography - University of California at Berkeley
2232 Piedmont Avenue #2120 - Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199
------------------------------
Date: Fri, 16 Jun 2000 15:42:55 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: system() in WinNT4-service
Message-Id: <Pine.GSO.4.10.10006161540510.21108-100000@user2.teleport.com>
On Fri, 16 Jun 2000, Wolfgang Hielscher wrote:
> on most of these WinNT-machines, this misbehavior disappears after
> rebooting them 2 or 3 times
Does it also disappear after installing Linux? :-)
If rebooting helps a Perl program, there's probably a problem at the OS
level. There's probably nothing you can do at the Perl level which will
fix things. Oh, well!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Jun 2000 22:21:19 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Text substitution problem
Message-Id: <8ie98v$4mbdj$6@fu-berlin.de>
hi,
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8ie5rb$4mbdj$5@fu-berlin.de> on 16 Jun 2000 21:22:51 GMT,
> Tina Mueller <tina@streetmail.com> says...
>> > The /m modifier only makes a difference if the match string contains ^ or
>> > $, which this one does not.
>>
>> and if the pattern contains "."
> No. That is irrelevant. You are thinking of /s.
oops, sorry...
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Fri, 16 Jun 2000 22:38:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Text substitution problem
Message-Id: <sklb3bjbis443@corp.supernews.com>
Tina Mueller (tina@streetmail.com) wrote:
: Craig Berry <cberry@cinenet.net> wrote:
: > Johannes (gedichte@lycosmail.com) wrote:
: > : If $postinput is a multiline string you should use: $postinput =~
: > : s/=//mg;
:
: > The /m modifier only makes a difference if the match string contains ^ or
: > $, which this one does not.
:
: and if the pattern contains "."
Nope, /m has no relevance to ".". Perhaps you're thinking of /s, which
*only* changes "." (to match \n).
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: Fri, 16 Jun 2000 15:15:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Using link checking scripts with Dynamo server (newbie question)
Message-Id: <Pine.GSO.4.10.10006161511040.21108-100000@user2.teleport.com>
On Fri, 16 Jun 2000, Bella wrote:
> I have an interesting problem.
I doubt it. :-)
> We're trying to write an html link checker.
Why? There are plenty of them available for free. Some of them actually
work. If Randal's most recent one doesn't work with minimal tweaking, let
him know - he's always looking for new column ideas.
http://www.stonehenge.com/merlyn/WebTechniques/
Of course, if your server doesn't follow the specs, that's another matter.
In that case, replace the server. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 16 Jun 2000 23:05:37 GMT
From: "Mark Meyer" <geeky2@gte.net>
Subject: Re: using mail-sender with NT scheduler service
Message-Id: <5py25.3713$NB4.348444@paloalto-snr1.gtei.net>
> the at command is awful. It always tells you that
> everything looks good when it doesn't and the
> parser handling its options is not very well designed.
> 1. Therefore I switched to winat.exe which you can
> find in the nt resource kit.
peter ..
thx alot for the tips..
mark
------------------------------
Date: Sat, 17 Jun 2000 01:28:16 -0700
From: "Jacobyte" <jacobyte@goattee.co.uk>
Subject: Very Strange Behaviour
Message-Id: <8iegpf$mq2$1@plutonium.btinternet.com>
I am running a few web sites out there each with their own cgi-bins on unix
servers - all scripts work fine and well.
I am also running 3 personal web servers one on Win98 , one Linux Mandrake
and one on Corel Linux for the sole purpose of customizing my existing
scripts on the remote servers. On win98 only %40 work, everything is set up
ok though while on the linux servers with Apache installed I cannot get any
to work through the browser - just get the 500 error - most of the scripts
will execute through bash ok though.
I know this is a long shot but I desperatley need an offline cgi development
environment. and am absolutley stuck as to why things are not working esp in
Linux even though they run on the remote servers. I have check all the usual
basepaths, permissions etc and everything is ok
If you have any ideas on this then feel free to throw them at me I will be
eternaly grateful !
cheers
------------------------------
Date: Sat, 17 Jun 2000 02:18:47 +0200
From: "Charles W.W." <weiwa592@student.liu.se>
Subject: What is wrong?
Message-Id: <394AC3E7.66367EBF@student.liu.se>
Please tell me what was wrong with this expression??
I want to save hash value to the DBM file lastdb.dir and latdb.pag
But...
This is the error message I had got. Please tell me why!
dbmopen(%last_good"lastdb", 0666);
#perl charp1.pl
#tring found where operator expected at charp1.pl line 28, near
"%last_good"lastdb""
# (Missing operator before "lastdb"?)
#
#
#
#syntax error at charp1.pl line 28, near "%last_good"lastdb""
#Execution of charp1.pl aborted due to compilation errors.
$last_good{$name} = time;
dbmclose (%last_good);
------------------------------
Date: Fri, 16 Jun 2000 17:25:17 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: What is wrong?
Message-Id: <8iegg8$5ld$1@brokaw.wa.com>
Charles W.W. <weiwa592@student.liu.se> wrote in message
news:394AC3E7.66367EBF@student.liu.se...
> Please tell me what was wrong with this expression??
> I want to save hash value to the DBM file lastdb.dir and latdb.pag
> But...
>
> This is the error message I had got. Please tell me why!
>
> dbmopen(%last_good"lastdb", 0666);
You missed a comma.
:-)
Lauren
------------------------------
Date: 17 Jun 2000 00:50:39 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: What is wrong?
Message-Id: <8iei0v$4kou1$1@fu-berlin.de>
hi,
Charles W.W. <weiwa592@student.liu.se> wrote:
> Please tell me what was wrong with this expression??
> This is the error message I had got. Please tell me why!
> dbmopen(%last_good"lastdb", 0666);
> #perl charp1.pl
> #tring found where operator expected at charp1.pl line 28, near
> "%last_good"lastdb""
> # (Missing operator before "lastdb"?)
what are you trying to do here?
%last_good"lastdb" should be what? a string, a hash, ...?
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Fri, 16 Jun 2000 22:51:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Writing line of death to log
Message-Id: <sklbrf83is437@corp.supernews.com>
Dave McIntyre (dem@achilles.net) wrote:
: The user wants a log file entry everytime the script dies
: for any reason.
:
: I'm doing this:
:
: open(FILE, "file.txt") or print LOG scalar(localtime) . " Line: Can't open
: $file: $!\n" and die;
:
: but would like to include the line number it died on. Possible?
It's easier to override $SIG{__DIE__} to do your logging; then your
code can just use die() the usual way. See 'perldoc -f die' for details.
Here's some example code -- note how both the log write and a print to
stderr occur; this behavior can be changed, but I find it useful.
#!/usr/bin/perl -w
# death - demo of SIG{__DIE__} trapping.
# Craig Berry (20000616)
use strict;
BEGIN {
open LOG, '>> death.log' or die $!;
}
$SIG{__DIE__} = sub { print LOG scalar localtime, ' ', @_ };
1 == 2 or die "Horribly";
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3397
**************************************