[7320] in Perl-Users-Digest
Perl-Users Digest, Issue: 946 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 29 12:17:32 1997
Date: Fri, 29 Aug 97 09:01:34 -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 Fri, 29 Aug 1997 Volume: 8 Number: 946
Today's topics:
Re: perl question <SPAMFREEcolmang@ms.com>
Re: Perl Regular Expression has a bug? <fawcett@nynexst.com.spam-me-not>
Perl, ODBC, & Solaris 2.x ???? aggarwal@dti.net
Re: Q: Daemon-Programming - HOWTO? (Greg Bacon)
Q:Perl comm-line substitution <mrao@nospam.trincoll.edu>
Re: readig a file into an array <SPAMFREEcolmang@ms.com>
Re: Reading in a file for use... <rootbeer@teleport.com>
Re: Returning a hash list (associative array) <jefpin@bergen.org>
Seeking: html2text module <ltomlin@indiana.edu>
Re: SSH and Perl (Leslie Mikesell)
Re: type char <jefpin@bergen.org>
Re: Where is the FAQ? Not at "www.perl.com"! <rootbeer@teleport.com>
Re: Wrong status from system() in child process ? lusol@turkey.cc.Lehigh.EDU
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Aug 1997 15:04:03 +0100
From: Gary Colman <SPAMFREEcolmang@ms.com>
To: polone@sanasys.com
Subject: Re: perl question
Message-Id: <3406D6D3.23CC@ms.com>
Hi
> I've got a script that does three things, set a variable
> $cheese ="foo",
> and open up file handle FILE for reading, and print the contents of
> this file to standard output. The file that has been opened has,
> somewhere in int, a string that looks like this: $cheese.
>
> and the contents of $file are as follows:
> this is just $cheese for me
>
> Any ideas?
Yup.
$filename='foo';
$cheese="cool stuff";
open(FILE,$filename);
while (<FILE>) {
s/(\$\w+)/$1/eeg;
print;
}
close(FILEHANDLE);
What it's doing above is to cycle through the file, and everytime
is encounters a word whose first character is a $ it evaluates that
as a variable ... multiple times if required.
Regards
Gary
--
remove SPAMFREE from my email address before replying.
------------------------------
Date: 29 Aug 1997 10:35:06 -0400
From: Tom Fawcett <fawcett@nynexst.com.spam-me-not>
Subject: Re: Perl Regular Expression has a bug?
Message-Id: <8jyb5loy5h.fsf@nynexst.com.spam-me-not>
dennis@csie.nctu.edu.tw () writes:
> See my program:
> #!/usr/bin/perl
> $date = localtime();
> print "$date\n";
> if($date = ~/(..):(..):(..)/)
> {
> print "Now \$date = $date\n";
> print "Time: $1:$2:$3\n";
> }
>
> And the output is very strange, Why?
See line 4. =~ is one operator. = and ~ are two operators.
-Tom
------------------------------
Date: Fri, 29 Aug 1997 09:22:15 -0600
From: aggarwal@dti.net
To: aggarwal@dti.net
Subject: Perl, ODBC, & Solaris 2.x ????
Message-Id: <872864220.26508@dejanews.com>
Hi are there any perl modules which can access a database thru odbc
drivers available for the solaris 2.5 platform, i noticed that there are a
few for windows but i need it for solaris...
i am running an informix database server, and am familiar with DBD and
DBI, however those won't suffice, i need something more generic.
thanks...
Samir Aggarwal
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 29 Aug 1997 14:26:00 GMT
From: gbacon@adtran.com (Greg Bacon)
To: t1206bq@lrz-muenchen.de (Joachim Wunder)
Subject: Re: Q: Daemon-Programming - HOWTO?
Message-Id: <5u6m5o$4c7$3@info.uah.edu>
[Posted and mailed]
In article <5u569q$5kq$1@sparcserver.lrz-muenchen.de>,
t1206bq@lrz-muenchen.de (Joachim Wunder) writes:
: I am a newbie to Daemon-programing in Perl. Could someone email me an example
: of a simple daemon-structure? Or point me to some appropriate literature
: about it?
Following is a C to Perl translation of the daemon_init function in
W. Richard Stevens' "Advanced Programming in the UNIX Environment":
use POSIX qw( setsid );
sub daemon_init {
my $pid;
if (not defined($pid = fork)) {
$@ = "Failed fork: $!\n";
return undef;
}
elsif ($pid != 0) {
sleep 15;
exit 0; # parent goes bye-bye
}
## child continues
setsid; # become session leader
chdir '/'; # change working directory
umask 0; # clear our file mode creation mask
1;
}
Use it as
daemon_init or die; # error propogates
...; # do what I mean :-)
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Fri, 29 Aug 1997 10:52:23 -0400
From: Mukund Rao <mrao@nospam.trincoll.edu>
To: jpn@genrad.com
Subject: Q:Perl comm-line substitution
Message-Id: <Pine.SOL.3.95.970829104636.21764A-100000@shakti.cc.trincoll.edu>
I am trying to write a script that will recursively perform a
global case-insensitive text-substitution on all files in current and
recursive directories.
perl -pe 's/find/replace/' `find ./ -print`
is my general idea. But this doesn't seem to be working quite without a
hitch. Also, if I replaced the `find...` with actual filenames, perl will
only write to STDOUT, instead of actually writing to the files.
Thanks to all for your suggestions & help.
_ _ ____
| \ / | \ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| \/ | () / Mukund Rao | Trinity College
| | |\ \ "visualize whirled peas" | WWW Admin, Programmer
|_|\/|_|_| \_) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Note: To reply, remove "nospam" from mrao@nospam.trincoll.edu
------------------------------
Date: Fri, 29 Aug 1997 15:28:09 +0100
From: Gary Colman <SPAMFREEcolmang@ms.com>
To: temp.ed.vanderbush@bentley.com
Subject: Re: readig a file into an array
Message-Id: <3406DC79.2691@ms.com>
Ed Vander Bush wrote:
>
> Can I
> open a file
> @my_array = filehandle
> close file
> Id there anything wrong with this?
No. But it's not gonna do much, and very likely
not what you want it to do.
Cheers
Gary
--
remove SPAMFREE from my email address before replying.
------------------------------
Date: Fri, 29 Aug 1997 08:20:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gary Colman <SPAMFREEcolmang@ms.com>
Subject: Re: Reading in a file for use...
Message-Id: <Pine.GSO.3.96.970829081833.15991M-100000@julie.teleport.com>
On Fri, 29 Aug 1997, Gary Colman wrote:
> The following will read in a file, storing each line as an
> element in @array
>
> $filename='bob'; # set the filename
> undef $/; # undefine the input record separator
> open(FILEHANDLE,$filename); # open the file for reading
Especially when giving help and advice, it's important to check the return
value from open.
> @array=split(/\n/,<FILEHANDLE>); # slurp the file into the array
Now, why did you go to the trouble of undefining $/ ? If you hadn't done
that, you could have written that last line more easily, more quickly, and
more efficiently like this.
@array = <FILEHANDLE>;
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 29 Aug 1997 10:16:48 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: Jacob Miner <jacob@bitsrfr.cnd.hp.com>
Subject: Re: Returning a hash list (associative array)
Message-Id: <Pine.SGI.3.95.970829101329.1209A-100000@vangogh.bergen.org>
>sub Families {
> local(%Name);
>
> $Name["Fred"]="Flinstone";
change this to $Name{"Fred"} = "Flintstone";
notice the braces {} not the brackets []
> $Name["Barney]="Rubble";
change this to $Name["Fred"] = "Rubble";
notice the braces {} not the brackets []
> return %Name;
>}
>
>%Test = Families();
>print %Test["Fred"];
changes this to print $Test{"Fred"};
notice the $ and not the %
notice the braces {} and the brackets []
----------------
| "I am just so full of it!"
| - Josh Ludzki
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>+++1094++++ L E--->---- W++++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
- geek code -
------------------------------
Date: Fri, 29 Aug 1997 10:12:35 -0500
From: Jay Tomlin <ltomlin@indiana.edu>
Subject: Seeking: html2text module
Message-Id: <Pine.OSF.3.91.970829080608.17381A-100000@copper.ucs.indiana.edu>
Hello,
Can anyone refer me to a good Perl module or library that will convert
HTML to formatted text, like the lynx -dump option does? I had been
relying on lynx for this but now I need something more secure.
Please reply by e-mail if you know of or have written such a beast.
TIA,
-jay
-----------
Jay Tomlin
Indiana University Office of Overseas Study
http://php.indiana.edu/~ltomlin
"When it speaks of music, language is lame." -George Steiner
------------------------------
Date: 29 Aug 1997 10:33:58 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: SSH and Perl
Message-Id: <5u6q56$2rq$1@Mars.mcs.net>
In article <872785193.26062@dejanews.com>, <jjune@midway.uchicago.edu> wrote:
>
>I am currently trying to write a perl script that will utilize ssh and scp
>to
>
> 1) Copy files to many different servers automatically;
> 2) Execute commands on many different servers automatically;
>
>Basically I need to be able to execute the same command on multiple
>servers... for example... I will need to scp a file (a tar file) to 30
>different servers... and execute a command to untar the file on all 30
>servers.
>
>I think I can set up the ssh with RSA to ssh in and out of all the servers
>without passwords... so i'm in the process of writing a perl script which
>will basically read in the server ips and do a system call on them...
>
>turning out to be MUCH more tricky then I had anticipated... has anyone
>seen any script that does this?... Or better yet... can anyone offer any
>pointers or advice on how to go about writing something like this?
I don't see why scp/ssh would be any different than rcp/rsh at this level.
If you don't need to run interactive commands (i.e. all options are passed
on the command line) it should boil down to a loop of:
scp source destination
ssh host command
If the commands are complicated or you want to do something on error conditions
it might work best to send a shell script along with the files and let it
detect the errors and handle them reasonably.
If you have to chat with interactive programs on the remote machines it becomes
more complicated but you can do it with facilities in perl, expect, or kermit.
Les Mikesell
les@mcs.com
------------------------------
Date: Fri, 29 Aug 1997 10:28:00 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: the count <eglamkowski@mathematica-mpr.com>
Subject: Re: type char
Message-Id: <Pine.SGI.3.95.970829102329.1209B-100000@vangogh.bergen.org>
>In C you can use type char, which can be treated as a number or a letter
>depending on context. But in perl, it will treat the number as a string
>containing those numbers, not as a letter (so if $i = 65, in character
>context it is "65" and not "A", of whatever ascii character that is)
>Is there a trivial way to force it to behave like C's char type?
Try using chr(). In the Camel Book (Prog. Perl for newbies), it reads:
chr NUMBER
This function returns the character represesented by that NUMBER in the
character set. For example, chr(65) is "A" in ASCII. To convert multiple
characters, use pack("C*", LIST) instead.
That should help...
----------------
| Before you think UNIX is family-oriented, note that all children must die.
| - Cross-Platform Perl
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>+++1094++++ L E--->---- W++++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
- geek code -
------------------------------
Date: Fri, 29 Aug 1997 07:25:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Desmond Curry <jdcurry@primenet.com>
Subject: Re: Where is the FAQ? Not at "www.perl.com"!
Message-Id: <Pine.GSO.3.96.970829071603.15991F-100000@julie.teleport.com>
On 28 Aug 1997, John Desmond Curry wrote:
> I have spent hours trying to find the Perl FAQ at the various places
> that previous messages on this newsgroup (comp.lang.perl.misc) have said
> that it is at, including "www.perl.com", but none of them exist. So,
> where is it?
www.perl.com is having a bad week. But the FAQ comes with 5.004, so the
command 'perldoc perlfaq' should probably give it to you. (And if you
don't have it, you should nag your sysadmin. :-) But you can also find it
on CPAN at
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
...or that address's equivalent with your own CPAN mirror. That is,
substitute the part before 'CPAN' as needed to make a URL which works for
you. If you don't know a CPAN site near you, the list of sites has been
posted about eight times in the last day or two. :-) Or you could try
this site.
ftp://ftp.digital.com/pub/plan/perl/CPAN/doc/FAQs/FAQ/html/
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Aug 1997 14:02:09 GMT
From: lusol@turkey.cc.Lehigh.EDU
Subject: Re: Wrong status from system() in child process ?
Message-Id: <5u6kp1$s6q@fidoii.cc.Lehigh.EDU>
Tom Phoenix <rootbeer@teleport.com> wrote in article <Pine.GSO.3.96.970828151206.18691K-100000@julie.teleport.com> :
>
>On Thu, 28 Aug 1997, Richard J. Marisa wrote:
>
>> I'd like to get the return status from a program
>> executed via system()
>>
>> However, system returns -1; $rc (as computed below) is 255.
>> $! contains "No child processes"
>
>That's odd. Are you certain that system is returning -1? (I ask only
>because the code as posted doesn't print out the actual return value from
>system.) That sounds as if something reaped the child process's status
>before Perl could - which shouldn't happen with system. Could be a bug in
>your Perl. What version are you running, and does it pass all of the tests
>in the test suite, especially ./t/op/exec.t?
I've seen this too... very odd. AIX 3.2.5, probably Perl 5.004... here's
a code snippet:
system "/usr/local/bin/gzip -f -c $fn > ${nfn}1.gz";
carp "gzip failed: $CHILD_ERROR" unless $CHILD_ERROR == 0 or $CHILD_ERROR == -1;
This check for -1 is a kludge because I couldn't figure out what was going on!
>
>If system is really returning -1, I think it's a bug. If you still see
>that happening with 5.004_03, run perlbug to file a bug report. Good luck!
I'll see if it's still happening @ 5.004_3.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 946
*************************************