[11765] in Perl-Users-Digest
Perl-Users Digest, Issue: 5365 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 20:07:29 1999
Date: Mon, 12 Apr 99 17:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 12 Apr 1999 Volume: 8 Number: 5365
Today's topics:
An Excellent referal program for webmasters pcrev@my-dejanews.com
Re: Can you use defined() on a typeglob? (Tad McClellan)
CGI Redirct Script jharshberger@my-dejanews.com
Re: Examples of slow regexes? (was: Re: Perl regexps co (Abigail)
Re: Executing perl code from separate files (Lee)
Re: Help with submiting a form from a script <gellyfish@gellyfish.com>
Re: Help with submiting a form from a script (Abigail)
Help! I can't create an error response from this script <gcd_jones@dial.pipex.com>
Re: how can i send perl -c output to a file instead of (Abigail)
Re: How do I delete text in a file? (Abigail)
How Should I begin Perl? <WizeGuy@nettaxi.com>
Re: How Should I begin Perl? <All@n.due.net>
Re: How Should I begin Perl? (Abigail)
Re: How Should I begin Perl? <cassell@mail.cor.epa.gov>
Re: installing libnet on win32 <gellyfish@gellyfish.com>
Re: looking for a particular script.... <ebohlman@netcom.com>
Net::Telnet input out of order ellerp@my-dejanews.com
Re: PPM has created a new dir. <greg2@surfaid.org>
Re: Printing commas (Tad McClellan)
Re: stripping spaces out <gellyfish@gellyfish.com>
Re: stripping spaces out (Larry Rosler)
Re: su another user in my perl program <tripix@tdi-net.freeserve.co.uk>
Re: Suit case or backpack <tripix@tdi-net.freeserve.co.uk>
Re: Where I Can Learn About Pearl And CGI Scripting? ellerp@my-dejanews.com
Re: Win32 Mail Client <greg2@surfaid.org>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Apr 1999 21:54:39 GMT
From: pcrev@my-dejanews.com
Subject: An Excellent referal program for webmasters
Message-Id: <7etq2r$fhg$1@nnrp1.dejanews.com>
Hi, You are probably familiar with this one already because it's so good, Im
talking about Corey Rudl's marketingtips program where you get $65 per sale,
and its free to join. Any way I mentioned the product and the URL in my
newsletter that has only about 150 members and I got four sales that quick
mention made me $260 dollars If you have a popular website or newsletter this
could make you thousands, if you get the same sales ratio as me and you have
say 10,000 people on your newsletter thats about $18000 I think, so its worth
a go. There are also banners you can use on websites which havbe very high
clickthrough rates. It probably sells so well because this bloke is a
marketing genius and could sell ice to an eskimo, so its very easy to make
plenty of money, have a look at it at
http://www.marketingtips.com/sr/t.x/5096/
Just thought you might want to know, if not sorry to bother you.
Bye.
PS I dont work for this guy, I just thought you might be able to make a bit of
money too, as it was so easy for me to.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 12 Apr 1999 14:12:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can you use defined() on a typeglob?
Message-Id: <c2dte7.nr3.ln@magna.metronet.com>
Daniel Beckham (danbeck@qual.net) wrote:
: Thank you. That's what I'm looking for. Although, I wonder if that's
: possible to do anyway? Even if it's not the solution to my problem,
: would it be possible to know if symbol exists in the symbol table?
Sure, since you have access to the entire Symbol Table.
: I need to research that some more... interesting.
Then you will want to see the "Symbol Tables" section in
'perlmod.pod', read the first paragraph, and try it for
yourself:
----------------------------
#!/usr/bin/perl -w
#use strict;
$foo = 'bar'; # put some stuff in the ST
$bar = 'foo';
foreach (sort keys %main::) { # dump the ST for main package
print "$_ ==> $main::{$_}\n";
}
----------------------------
: In article <7em44r$ofo$1@pegasus.csx.cam.ac.uk>, mjtg@cus.cam.ac.uk
: says...
: > Daniel Beckham <danbeck@qual.net> wrote:
: > >I need to check to see if a filehandle is defined. Can I use a defined() o a
: > >typeglob?
: >
: > There isn't a concept of "defined" for a filehandle in Perl.
: >
: > Perhaps you mean "Is this filehandle currently open?". In which case
: > see perldoc -f fileno.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 12 Apr 1999 22:58:01 GMT
From: jharshberger@my-dejanews.com
Subject: CGI Redirct Script
Message-Id: <7ettpk$j55$1@nnrp1.dejanews.com>
I'm looking for help setting up a CGI script that will allow me to directly
access an individual web site. I have 2 sites set up under the same account
and currently have DNS for the second site pointing to the account. The site
is www.feather-jewelry.com. The new site is www.gemcutting.com. I have a dir
set up and the files are there for the gemcutting site, but am not able to get
to it using a browser. I'm sure there are many of these scripts floating
around out there and was wondering if anyone has a sample that I could use or
modify. Thanks!
Jeff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Apr 1999 23:37:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Examples of slow regexes? (was: Re: Perl regexps compared to Python regexps)
Message-Id: <7eu02s$7rm$2@client2.news.psi.net>
Bart Lateur (bart.lateur@skynet.be) wrote on MML September MCMXCIII in
<URL:news:37125e8e.946742@news.skynet.be>:
^^ David Cassell wrote:
^^
^^ >... and Friedl's tests suggest that well-written Perl regexes
^^ >should be much faster [although badly-written Perl regexes can be pain-
^^ >fully slow - a potential problem in any NFA regex engine].
^^
^^ I have, until now, never encountered a Perl regex that is "painfully
^^ slow", or not even "rather on the slow side". Can anybody please give an
^^ example of such a beast, point out the reason for it's slowness, and
^^ possibly even recipes on what to avoid?
"aaaaaaaaaaaaaaaaaaaaaab" =~ /a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a.c/;
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Mon, 12 Apr 1999 17:24:20 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Executing perl code from separate files
Message-Id: <B337DCC496684ADFD2@204.112.166.88>
In article <linberg-1204991733090001@ltl1.literacy.upenn.edu>,
linberg@literacy.upenn.edu (Steve Linberg) wrote:
>> Does that mean there is a way I can eval a file without opening a file handle
>> and reading it in? If so, how?
>
>Whoops, I meant "do". You can use this to execute a file of perl commands
>- similar to "require." See the documentation of these functions for
>complete info.
>
>do 'foo.pl'; # execute perl commands in foo.pl
You can also...
eval `cat foo.pl`;
if'n ya wanna.
>It's probably safer to explicitly open the file, read the contents,
>examine them, and do an eval if you're comfortable with what's there.
>Even safer would be to tokenize your verbs so that people couldn't plug
>malicious stuff in your foo.pl ...
If foo.pl is open to such mischief, would the script reading it not be
equally vulnerable? Why would they have different permissions/owners? (I
can imagine scenarios, but are they common?) Why such paranoia with do/eval
and not with use/require?
(curiosity, not flamebait)
Lee
------------------------------
Date: 12 Apr 1999 22:31:42 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help with submiting a form from a script
Message-Id: <7ets8e$45t$1@gellyfish.btinternet.com>
On Mon, 12 Apr 1999 14:41:34 -0500 Alejandro Eluchans wrote:
> Thanks for responding
>
> Sorry if I didn't make myself clear
>
> What I'm trying to do is create a crawler that submits to a cgi (this cgi
> handles a web form).
> So I may store the results from the cgi into my crawler.
> (trying to download a database)
>
You will want to use the LWP::UserAgent module to retrieve the data and
possibly HTML::Parser to extract the information form the returned page.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 12 Apr 1999 23:11:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help with submiting a form from a script
Message-Id: <7etujb$772$2@client2.news.psi.net>
Alejandro Eluchans (alejandro.eluchans@umb.edu) wrote on MML September
MCMXCIII in <URL:news:37123778.E3EB0D42@umb.edu>:
== Does any body know how to submit a form (name/value form entries) that
== is located in a PERL script (like a browser), so I may use the return
== (from the cgi) with the PERL script.
Just press the submit button of your browser!
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Mon, 12 Apr 1999 23:46:59 +0100
From: "Gareth Jones" <gcd_jones@dial.pipex.com>
Subject: Help! I can't create an error response from this script
Message-Id: <7ett8b$c32$1@plug.news.pipex.net>
Is there any way of getting this script to display HTML code on an error
e.g. if the smtp server unavailable, rather than a blank page!
Please Help...
#!/usr/bin/perl
$CHECK_EMPTIES=0;
print "Content-type: text/html\n\n";
sub ReadParse {
# slightly modified from the usual readparse
local (*in) = @_ if @_; local ($i, $loc, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'};}
elsif ($ENV{'REQUEST_METHOD'} eq "POST")
{read(STDIN,$in,$ENV{'CONTENT_LENGTH'});}
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2);
$FOUND=0; foreach (@FIELDS) { $FOUND=1 if ($key eq $_); }
if (($key ne 'TO')&&($key ne 'SMTPHOST')&&($key ne 'SUBJECT')&&($key ne
'REPLYTO')&&($FOUND==0))
{ push(@FIELDS,$key); }
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val; } return 1; }
&ReadParse;
foreach (@FIELDS) {&MissingInfo if (($in{$_} eq '')&&($CHECK_EMPTIES==1));}
$in{'TO'} ='ROOT' if (!defined $in{'TO'});
$in{'SUBJECT'} ='NO SUBJECT' if (!defined $in{'SUBJECT'});
$in{'REPLYTO'} ='CHATTERJEE_ROBIN@TANDEM.COM' if (!defined $in{'REPLYTO'});
$in{'SMTPHOST'} ='localhost' if (!defined $in{'SMTPHOST'});
$ENV{'SERVER_ADDR'} ='LOCALHOST' if (!defined $ENV{'SERVER_ADDR'});
$SUBJECT=$in{'SUBJECT'}; delete $in{'SUBJECT'};
$REPLYTO=$in{'REPLYTO'}; delete $in{'REPLYTO'};
$SMTPHOST=$in{'SMTPHOST'}; delete $in{'SMTPHOST'};
$SERVERNAME=$ENV{'SERVER_NAME'};
$SERVERNAME=$ENV{'SERVER_ADDR'} if(!defined $ENV{'SERVER_NAME'});
# split up the "to" names for multiple recipients
$TO=$in{'TO'}; @TO=split('\0',$TO);
#( $them, $port ) = @ARGV;
$port = 25 unless $port;
$them = $SMTPHOST unless $them;
$AF_INET = 2;
$SOCK_STREAM = 1;
$SIG{'INT'} = 'dokill';
sub dokill {
kill 9,$child if $child;
}
$sockaddr = 'S n a4 x8';
#chop($hostname = `hostname`);
($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp')
unless $port =~ /^\d+$/;;
($name,$aliases,$type,$len,$thisaddr) =
gethostbyname($hostname);
($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
if (socket(S, $AF_INET, $SOCK_STREAM, $proto))
# print "socket ok\n";
}
else {
die $!;
}
if (bind(S, $this)) {
# print "bind ok\n";
}
else {
die $!;
}
if (connect(S,$that)) {
# print "connect ok\n";
}
else {
die $!;
}
select(S); $| = 1; select(STDOUT);
$a=<S>;
print S "HELO ${SERVERNAME}\n";
$a=<S>;
print S "MAIL FROM:$REPLYTO\n"; # x-return path
$a=<S>;
print S "RCPT TO:<@TO[0]>\n"; # recipient
$a=<S>;
if ($#TO > 0) { foreach (1..$#TO) { print S "RCPT TO: @TO[$_]\n";$a=<S>; }
}
print S "DATA \n";
$a=<S>;
print S "To: @TO[0]\n";
print S "From: $REPLYTO\n";
if ($#TO > 0) { foreach (1..$#TO) { print S "Cc: @TO[$_]\n"; }
}
print S "Subject: $SUBJECT\n";
print S "Reply-To: $REPLYTO\n";
# Display each field and responses
foreach (@FIELDS) {
$in{$_}=~ s/\0/\n\n * /g;
print S "\n";
print S "$in{$_}\n";
}
print S ".\n";
$a=<S>;
print S "QUIT"; #end
# Read in the response and print it.
undef $/; $_=<DATA>; print;
# Everything down here is the default response.
__END__
<HTML>
MAIL HAS BEEN SENT
</HTML>
------------------------------
Date: 12 Apr 1999 23:07:36 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how can i send perl -c output to a file instead of STDERR
Message-Id: <7etubo$772$1@client2.news.psi.net>
William Smith (smith.will@epa.gov) wrote on MML September MCMXCIII in
<URL:news:7etj4d$hue1@valley.rtpnc.epa.gov>:
&& When perl finds syntax errors they are sent to STDERR. I want to send them
&& to a file.
STDERR *is* a file. Everything is a file. Your are a file too.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: 12 Apr 1999 23:12:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I delete text in a file?
Message-Id: <7etul6$772$3@client2.news.psi.net>
Gabriel Richards (grichard@uci.edu) wrote on MML September MCMXCIII in
<URL:news:7et5vr$95n@news.service.uci.edu>:
;; Is there a function which will allow me to delete text from a file?
open ().
Abigail
--
perl -wlne '}print$.;{' file # Count the number of lines.
------------------------------
Date: Mon, 12 Apr 1999 18:15:39 -0400
From: Raymond Yu <WizeGuy@nettaxi.com>
Subject: How Should I begin Perl?
Message-Id: <3712708B.50B09A70@nettaxi.com>
I have a book, but I don't get it. I NEED HELP!!!!!!!!!!!!!
------------------------------
Date: Mon, 12 Apr 1999 22:55:50 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: How Should I begin Perl?
Message-Id: <WRuQ2.6903$gr5.4356@news.rdc1.ct.home.com>
Raymond Yu <WizeGuy@nettaxi.com> wrote in message
news:3712708B.50B09A70@nettaxi.com...
: I have a book, but I don't get it. I NEED HELP!!!!!!!!!!!!!
Well, I am thinking: get a better book <g>. If you aren't reading
Learning Perl you should be. If you are reading Learning Perl, try to work
through the examples. If you have questions - after you have worked on the
problems and are still stuck - come back here and pose your questions. Try
to indicate what you believe you do know, and what the sticking point is.
The only other advice I have is that the best way to learn is to do.
Pick a project and work on it. When you get stuck, ask questions that will
help you get unstuck (but don't ask to have the solution given to you, very
little learning lies down that path). Lastly, try to have fun. Play. One
of the things that I have loved about the process of learning Perl is that
on a number of occasions, when I have gotten stuck in some trap of my of own
making, I have tried something just off the top of my head. At the time I
believe there is no way it will work but I write the code the way I say it I
was just trying to speak the language. Low and behold, these things almost
always end up working. It really is what I love about Perl. At a macro
level, things that should work do. So often Perl does what I mean even if I
don't know the "correct" way to say it. That is so amazingly satisfying it
just blows me away. Plus, you eventually you start to turn an elegant
phrase or two and that is just even more way fun. Oops waxing on for no
reason, I should probably contain myself. Good luck.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
Down that path lies madness. On the other hand, the road to hell is
paved with melting snowballs.
Larry Wall in <1992Jul2.222039.26476@netlabs.com>
------------------------------
Date: 12 Apr 1999 23:29:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How Should I begin Perl?
Message-Id: <7etvl2$7rm$1@client2.news.psi.net>
Raymond Yu (WizeGuy@nettaxi.com) wrote on MML September MCMXCIII in
<URL:news:3712708B.50B09A70@nettaxi.com>:
\\ I have a book, but I don't get it. I NEED HELP!!!!!!!!!!!!!
Yes, you do.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Mon, 12 Apr 1999 16:49:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How Should I begin Perl?
Message-Id: <37128692.24D1BF86@mail.cor.epa.gov>
Raymond Yu wrote:
>
> I have a book, but I don't get it. I NEED HELP!!!!!!!!!!!!!
Which book? I assume you have Perl installed somewhere you can play
with it as well. An up-to-date Perl, with an up-to-date book.
If you're working through Randal's 'Learning Perl' and you're getting
stuck all the time on leaps like 'array' or 'subroutine', then you'll
need to step back to a really basic book. Not anything with 'Dummies'
in the title, though. Maybe "Teach Yourself Perl in 21 Days" or
something like that. Or check out some of the basic Perl tutorials
scattered across the web.
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 12 Apr 1999 22:25:04 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: installing libnet on win32
Message-Id: <7etrs0$45o$1@gellyfish.btinternet.com>
On Mon, 12 Apr 1999 15:08:40 -0400 Tim Gray wrote:
>>You are almost certanly better off using the Perl Package Manager
>>(PPM) that comes with the Activestate distribution.
>>
>>Anyhow I thought that libnet came with that distribution. ?
>>
>>/J\
>
> SMTP.pm doesn't get installed anywhere I can find it. The only things in
> perl\lib\Net are hostentpm, protoent.pm, Ping.pm, servent.pm, and netent.pm
> and perl\site\lib\Net doesn't even exist.
>
Hmm I must have sleep-installed it then ;-}
> So I downloaded the zip of the package for libnet. When I try to install,
> PPM deletes all the files and then complains that it can't find them. It
> even tries to remove the current directory.
Bizarre - I must admit I have always been able to just install online
without downloading the zip file - is there any reason why you cant do
this ?
I'm not at a Windows machine right now but I think there is an HTML
document somewhere in the distribution that discusses the use of PPM
in a little more detail.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 12 Apr 1999 21:58:58 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: looking for a particular script....
Message-Id: <ebohlmanFA3JqA.A9D@netcom.com>
Larry Rosler <lr@hpl.hp.com> wrote:
: Does this really need a canned program?
: my %keywords;
: @keywords{qw(foo bar baz)} = ();
: while (<FILE>) {
: s%(\w+)%exists $keywords{lc $1} ? "<B>$1</B>" : $1%eg;
: print;
: }
: __END__
: All you need to add is the details of getting the keywords into the hash
: and opening the HTML file.
Unfortunately, this code will add <B>...</B> tags in places they don't
belong: inside attributes, inside tag names, inside comments, etc.
I'd rather use something like:
package Boldify;
use base qw/HTML::Filter/;
my $subexp;
my @keywords=(qw/foo bar baz/);
sub text {
my($self,$text)=@_;
$text=~s/($subexp)/<B>$1</B>/io;
$self->output($text);
}
$subexp='\b(?:'.join('|',@keywords).')\b';
my $p=new Boldify;
{local $/;
$p->parse(<STDIN>);
}
------------------------------
Date: Mon, 12 Apr 1999 22:47:46 GMT
From: ellerp@my-dejanews.com
Subject: Net::Telnet input out of order
Message-Id: <7ett6f$ikj$1@nnrp1.dejanews.com>
I am trying to write a telnet program using the Net::Telnet perl module that
will login to our Unix systems and 'inventory' what hardware/software is
installed there. Once I login I set the prompt to some funky pattern that
won't show up in the output of one of my commands. One of the first things I
do after setting the prompt is issue a 'uname -a', and parse the output for
OS type etc. On an HP-UX system this works fine. Here is a session log
excerpt:
< $
> export PS1='88G88 '
< export PS1='88G88 '
< 88G88
> uname -a
< uname -a
< HP-UX systemname B.1.0.20 E 9000/831 1234568 8-user license
< 88G88
This is what I expect to see - the command I write echoed back to me followed
by the command output, followed by the prompt.
On Digital Unix and AIX things seem to come back out of sequence. On AIX here
is what I received:
< $
> export PS1='88G88 '
< export PS1='88G88 '
> uname -a
< 88G88
> cd /usr/bin
< uname -a
< AIX systemname 3 4 1234567
< 88G88
In other words after I send the export PS1 command that gets echoed back to
me, but I send the uname -a command before I see the prompt (88G88). My
program moves on and sends additional commands (the cd /usr/bin) before I get
the echoed back command (uname -a) or the uname output (AIX systemname ...).
Things seem to come back out of the expected order.
Here is the code I am using:
$t->print("export PS1=$new_prompt");
$success = $t->waitfor('/\s$/');
if (!defined $success) {
error_routine();
}
@array = $t->cmd(String => 'uname -a',
Prompt => $new_prompt_reg);
On the HP @array gets initialized with the output from the uname -a command;
on the AIX box things come back out of sequence, and @array is empty.
Any insight into what might be going on, and possible work arounds would be
greatly appreciated.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 12 Apr 1999 23:14:31 +0100
From: Greg Griffiths <greg2@surfaid.org>
To: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PPM has created a new dir.
Message-Id: <37127047.B8219C7A@surfaid.org>
The contents of the \site directory looks like that of my \lib
directory, should I just leave them as two dir's or copy the \site into
my \lib ?
Jonathan Stowe wrote:
>
> In comp.lang.perl.misc Greg Griffiths <greg2@surfaid.org> wrote:
> > I've just started using PPM to update my packages and have noted that it
> > has created 3 new dir in my PERL directory :
> >
> > \html
> > \htmlhelp
> > \site
> >
> > what can I/ Should I do with them ?
>
> Er nothing.
>
> They're supposed to be there.
>
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
> Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 12 Apr 1999 14:26:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Printing commas
Message-Id: <gtdte7.nr3.ln@magna.metronet.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: In article <7etfjh$3g7$1@info2.uah.edu> on 12 Apr 1999 18:55:45 GMT,
: Greg Bacon <gbacon@itsc.uah.edu> says...
: > In article <7etem5$56e$1@nnrp1.dejanews.com>,
: > gtdgm@hotmail.com writes:
: > : I want output to look like this:
: > : str1,str2,str3,str4
: > [snip]
: > : What is the easiest way to do this
: > : without using any loop? Or is there such
: > : a way?
: >
: > Please read the perlfunc documentation on the join() operator.
: That is a good way, which produces a single string that you can print.
: Alternatively, to print directly you can do this:
: { local $, = ','; print $str1, $str2, $str3, $str4 }
: Please read the perlvar documentation on the $,
: ($OUTPUT_FIELD_SEPARATOR) variable.
Since you have an array rather than a list (that part got
snipped somewhere along the way), you can do it with
either $, or with $" (both described in 'perlvar.pod'):
{ local $, = ','; print @ra } # preferred (by me anyway)
{ local $" = ','; print "@ra" }
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Apr 1999 20:30:19 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: stripping spaces out
Message-Id: <7etl4r$44a$1@gellyfish.btinternet.com>
[Posted and something entirely different mailed]
On Mon, 12 Apr 1999 08:59:09 -0700 Larry Rosler wrote:
> [Posted and a courtesy copy sent.]
>
> In article <371208be.25127984@news.dircon.co.uk> on Mon, 12 Apr 1999
> 15:00:29 GMT, Jonathan Stowe <gellyfish@gellyfish.com >says...
> + On Mon, 12 Apr 1999 08:15:55 -0500, quinn coldiron
> + <qcoldiro@unlinfo.unl.edu> wrote:
> +
> + >I read the perl FAQ, and found a reg exp to strip spaces, but it only
> + >strips spaces off the beginning and end of a string. I want to strip
> + >ALL the spaces out of a string. Does anybody have a reg exp that
> + >will do this?
> +
> + Errr
> +
> + perlfaq4 has this to remove space from the ends of a string:
<blah>
> +
> + And the perlre manpage says:
<blah>
> +
> + So now you know what is causing those regex to do what they do and
> + thus you know what to remove in order to remove all spaces from a
> + string.
>
> Errr
>
> With the information you just gave, he could remove the first space from
> a string, not 'all spaces'. Something more is needed (besides just
> using the 'tr' operator, that is).
>
Eeeek.
Of course one will have to see the section entitled:
Regexp Quote-Like Operators
in the perlop manpage for that bit.
Anyhow just for fun and as antedote for all this regexry and translation
here is possibly the most *inefficient* way I can think of doing this:
#!/usr/bin/perl -w
use strict;
my $string = ' this is a string with space in it';
my $newstring;
foreach (split //,$string)
{
$newstring .= $_ if $_ ne ' ';
}
print $newstring;
Have Fun
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 12 Apr 1999 16:29:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: stripping spaces out
Message-Id: <MPG.117c21b07f5380ce98989e@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7etl4r$44a$1@gellyfish.btinternet.com> on 12 Apr 1999
20:30:19 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
...
> Anyhow just for fun and as antedote for all this regexry and translation
> here is possibly the most *inefficient* way I can think of doing this:
>
> #!/usr/bin/perl -w
> use strict;
>
> my $string = ' this is a string with space in it';
> my $newstring;
>
> foreach (split //,$string)
> {
> $newstring .= $_ if $_ ne ' ';
> }
>
> print $newstring;
>
>
> Have Fun
For sure.
You could do worse by using an indexed loop:
my @chars = split //, $string;
for (my $i = 0; $i < @chars; $i++) {
$newstring .= $chars[$i] if $chars[$i] ne ' ';
}
There. That looks much more like C and is surely slower.
But I would write those ugly loops as a one-liner:
my $newstring = join "", grep $_ ne ' ', split //, $string;
How's that for sophisticated functional coding? It uses the same clever
algorithm.
But no, I won't benchmark them. (My last try would probably be *more*
efficient than yours.)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 12 Apr 1999 23:53:30 +0100
From: "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk>
Subject: Re: su another user in my perl program
Message-Id: <7etu26$2j3$1@news6.svr.pol.co.uk>
yang shen wrote in message <7etiv9$9ab@newsstand.cit.cornell.edu>...
>Hi Everybody:
> I am writing a perl program to retrieve user's files form our ADSM.
>Inside my perl program I need to su user(file owner)first, then retrieve
the
>file. How could I get this done?
>
>Thanks a lot!
>Yang
>
what about telneting in a a privileged user?
although putting such things in a script is 'dodgy',
what about using suidperl?
------------------------------
Date: Mon, 12 Apr 1999 23:50:20 +0100
From: "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk>
Subject: Re: Suit case or backpack
Message-Id: <7ettni$29r$1@news6.svr.pol.co.uk>
-----Original Message-----
From: Stanley Horwitz <stan@tempest.temple.edu>
Newsgroups: comp.lang.perl.misc
Date: 12 April 1999 15:42
Subject: Suit case or backpack
>
>I think I might be going crazy, because I cannot seem to find the backpack
>I used on my previous trip to Europe.
hmm, sounds like your child proccess is missing some environment variables
from the last fork.
>I have searched my parents' house
>and my own, but to no avail. I guess maybe I lent the backpack to a friend
>and than forgot about it.
Are you refering to autoloadable libraries or super functions?
Are you sure you are not programming in c++?
>This backpack was kind of on the heavy side
>anyway so it wasn't the most convenient backpack.
use LZW;
> I could go out and get another backpack, but I
>would rather not spend the money, especially since I know that as soon
>as I buy a new one, I will find my old backpack.
yeah, unistallers, what a bitch.
have you tried "Memory::Storable" function?:
sub find_backpack
{
my $mem=shift;
$_=$memory->{"BackpackAttribs"};
/where_I_left_it_last:(.*)/ ? return $1 : return undef;
}
print pack find_backpack($memory);
Wayne
------------------------------
Date: Mon, 12 Apr 1999 23:17:14 GMT
From: ellerp@my-dejanews.com
Subject: Re: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <7etuti$k4u$1@nnrp1.dejanews.com>
In article <19990412123424.21220.00003207@ngol01.aol.com>,
barneyxter@aol.com (BarneyXter) wrote:
> The Title Says It All. I Want To Learn How To Make A Chat Room And Have Pages
> That I Can Input Text From...
>
My recommendation for learning Perl is:
Perl 5 Interactive Course by Jon Orwant, published by Waite Group Press.
For CGI programming it is:
CGI Programming (what else) on the World Wide Web, by Shishir Gundavaram,
published by O'Reilly & Assoc.
I'm just getting into the CGI book, but I found the Perl book excellent.
Just be sure you get the 2nd edition - several frustrating typos in the
first edition.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 12 Apr 1999 23:12:08 +0100
From: Greg Griffiths <greg2@surfaid.org>
To: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Win32 Mail Client
Message-Id: <37126FB8.300A1864@surfaid.org>
I'm not allowed due to server restrictions to use anything that is not
in the base install of the language. So I guess that rules out blat.
Jonathan Stowe wrote:
>
> On Sun, 11 Apr 1999 16:34:55 +0100, Greg Griffiths <greg2@surfaid.org>
> wrote:
>
> >I'm trying to get the equiverlent of Sendmail to work under a win32
> >environment, but keep hitting errors, does someone have a nippet of code
> >that will allow me to send an email in this environment ?
>
> In lieu of any other information Doris suggests that you try the NT
> port of sendmail from
>
> ftp://ftp.microsoft.com/developr/drg/UNIX-to-Windows/Ports/Sendmail/SML1121.zip
>
> And try that. Alternatively you might post with some more
> information.
>
> /J\
------------------------------
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 5365
**************************************