[7322] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 947 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 29 14:20:18 1997

Date: Fri, 29 Aug 97 11:00:21 -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: 947

Today's topics:
     Re: Bizarre result with regex in -i -pe (M.J.T. Guy)
     Can NTPerl do DDE? (Paul Falbe)
     disappearing values in DBM files <duclert@genset.fr>
     Re: Docu ment contains no data (was :www.perl.com)? (Clay Irving)
     Re: Does tie hash require an flock? (Peter Haworth)
     Re: Filtering CR & CRLF from text input (William Wue(2xP)elma(2xN))
     find command with perl <stephane@titude.arc.nasa.gov>
     Help Capturing Error Messages From sendmail <areeves@us.ibm.com>
     Re: HTML --> Perl conversion (Jeremy D. Zawodny)
     Re: I have to ASK (Greg Bacon)
     Re: My counter counts, but too munch <ajohnson@gpu.srv.ualberta.ca>
     Re: Pattern Matching <ajohnson@gpu.srv.ualberta.ca>
     Perl script question for gurus <chris@purple.tmn.com>
     Re: Perl, ODBC, & Solaris 2.x ???? (Mike Heins)
     Re: Q: Daemon-Programming - HOWTO? (Greg Bacon)
     Re: Q:Perl comm-line substitution <rootbeer@teleport.com>
     Re: Q:Perl comm-line substitution (Greg Bacon)
     Re: Simple Search Script (Jeremy D. Zawodny)
     Socket question (Arvind Karandikar - VT ~)
     using unix commands for missing libwww module (Bob Maillet)
     Re: Which Windows (95) Perl to use? <Jacqui.Caren@ig.co.uk>
     Re: Wrong status from system() in child process ? (Jimmy Aitken)
     Re: Wrong status from system() in child process ? (M.J.T. Guy)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 29 Aug 1997 17:51:00 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bizarre result with regex in -i -pe
Message-Id: <5u7264$sfj$1@lyra.csx.cam.ac.uk>

Jonathan Feinberg <jdf@pobox.com> wrote:
>rootbeer@teleport.com said...
>
>> That's because the [^\t] will match the newline, since that's not a tab. 
>> (But if [^\t] didn't match it, then the $ would.) 
>
>Hmm.  I quote perlre:
>
>  $ Match the end of the line (or before newline at the end)
>
>So $ shouldn't match a newline, right?  Furthermore, since $ matches
>"before" the newline, then /[^\t]+$/ should match all the non-tab chars
>up to, but not including, the newline at the end.  Or would that be 
>/[^t]+?$/ ? Am I misinterpreting perlre?

Firstly, $ doesn't match a newline, or any other character.   It matches
a _position in the string_, which may be before or after the final newline.

Secondly, you are overlooking the vices of regular expressions.
+ is _greedy_, so the [^\t]+ eats up all the characters of the final
field, then, since newline isn't a tab, swallows the newline for dessert.
Then it finds itself at the end of the string, where $ matches nicely,
and hey presto!

So another way of fixing the pattern is  /[^\t]+?$/  (or /\t[^\t]+?$/
to remove the tab separator as well), since that will try matching $
before the newline before trying after.   Yet again, TIMTOWTDI.


Mike Guy


------------------------------

Date: 29 Aug 97 16:53:44 GMT
From: paul@cassens.com (Paul Falbe)
Subject: Can NTPerl do DDE?
Message-Id: <9800.872873624@cassens.com>
Keywords: Perl, WinNT, DDE

I would like to use Perl to do some DDE.  Has anyone done this?
If so how?

Thanks in advance!

-Paul

--
Internet:             | Paul J. Falbe             |                          
   falbe@cassens.com  | Cassens Transport         | Std disclaimers apply.   
Voice:                | 145 N. Kansas Str.        |  (But you knew that!)    
   618-656-3006       | Edwardsville, IL 62025    |                          


------------------------------

Date: Fri, 29 Aug 1997 18:56:56 +0200
From: Aymeric Duclert <duclert@genset.fr>
Subject: disappearing values in DBM files
Message-Id: <3406FF58.13AA@genset.fr>

Hello,
 
I have a problem of disappearing (key,value) pairs using the Berkeley DB
library
 .
I'm using this library through perl5.
 
Here is a simple programm where the key "key1" is changed several times
and is lost at the end, while a new key "key11" appears ...
 
------------------------------------------------------------------------
#!/nfs/share/bin/perl
use Fcntl;
use DB_File;
&Fill("short");
&Fill("long");
&Fill("short");
 
sub Fill
{
        my($arg) = shift;
        tie %hash, "DB_File","toto",O_CREAT|O_RDWR,511,$DB_HASH;
        if ($arg eq "short") {
                $hash{"key1"} = "A";
        } elsif ($arg eq "long") {
                $hash{"key1"} = "A" x 10000;
        }
        $hash{"key2"} = "BBBB";
        @keys = keys(%hash);
        print "keys : @keys\n";
        print "length of key1 : " . length($hash{"key1"}) . "\n\n";
        untie %hash;
}
------------------------------------------------------------------------
Here is the suprising output :
 
keys : key1 key2
length of key1 : 1
 
keys : key2 key1
length of key1 : 10000
 
keys : key2 key11
length of key1 : 0
 
And if the programm is run several times, the result is even more
suprising : a hash with several identical keys !
------------------------------------------------------------------------
I'm working on a UNIX workstation with solaris5.5, using perl 5.002 and
the perl package DB_File.pm version 1.01
 
If anyone can help, I would be greatly interested.
 
Thanks a lot.

-- 
       Aymeric Duclert
  Aymeric.Duclert@genset.fr
        GENSET S.A.
1 rue Robert et Sonia Delaunay
        75011 Paris


------------------------------

Date: 29 Aug 1997 11:56:28 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Docu ment contains no data (was :www.perl.com)?
Message-Id: <5u6rfc$aqj@panix.com>

In <m3g1ru3s6r.fsf@windlord.Stanford.EDU> Russ Allbery <rra@stanford.edu> writes:

>The site has *been* a fantastic PR and reference site for Perl for years.
>It is currently being moved from one location to another to make it a
>great deal faster, and in the process some technical difficulties have
>apparently been encountered.  Please, everyone, have some patience and I'm
>sure it will be back up before long.

I believe the problem was bad memory on the new server -- The memory was
replaced and all seems well.

-- 
Clay Irving <clay@panix.com>                   http://www.panix.com/~clay/


------------------------------

Date: 29 Aug 1997 17:11:46 GMT
From: pmh@ioppublishing.com (Peter Haworth)
Subject: Re: Does tie hash require an flock?
Message-Id: <5u6vsi$208$1@newton.ioppublishing.com>

In article <5tsdsc$a5t$2@nntp2.ba.best.com>,
	Zenin <zenin@best.com> writes:
> Robert Nicholson <steffi@shell8.ba.best.com> wrote:
>> Is there an implicit flock at the time of an unbind?
> 	Depends on how the tied classes is designed.  Check the
> 	docs for the one you're using.  I don't think many (or any)
> 	of the DBM classes shipped with perl flock anything by default.

GDBM_File does. And with perl 5.004, it's implementation of flock() is the
same as perl's.

-- 
	Peter Haworth	pmh@edison.ioppublishing.com
The correct way of pronouncing (well, spelling) the name of LA is
"La Ciudad de nuestra Sen~ora la Reina de los A'ngeles de Porciu'ncula".
                    Good luck. :-)


------------------------------

Date: Fri, 29 Aug 1997 16:00:20 GMT
From: williamw@rooster.igs.deleteTheRooster.net (William Wue(2xP)elma(2xN))
Subject: Re: Filtering CR & CRLF from text input
Message-Id: <3406e911.8561910@news.igs.net>

On Thu, 28 Aug 1997 20:45:36 GMT, faust@wwa.com (Faust Gertz) wrote:

>On Thu, 28 Aug 1997 19:35:28 GMT, bart.mediamind@tornado.be (Bart
>Lateur) wrote:
>
>>"Carey Barnett" <cbarnett@idirect.com> wrote:
>>
>>>I'm new to Perl, but isn't this the 'chomp()' function EXACTLY!
>>
>>>> >Can anyone tell me how to strip CRLFs from text input fields? I'm
>>
>>You didn't understand the question quite right. Chomp remove the CRLF
>>from the END of a line.
>>
>>The problem was how to remove CRLF's from WITHIN a text field, with
>>multiline text, where the user used the return key to preformat his
>>text. The question was how to turn this back into one single line.
>
>I'm new to Perl too, but could something like either  's/\n//g'
>or 's#$/##g' be what you seek?  If not, someone please enlighten me
>too.

I think that might cause a problem, but

s/\Q\n\E//g;

should do the trick. I'm not 100% sure its necessary, but any time I
use any special characters in a regexp, I use \Q \E just in case.


-------------------------
William Wue(2xP)elma(2xN)
Reply-To: williamw (at) igs (dot) net
--------------------------------------------------------------
It is pitch black. You are likely to receive spam from a grue.


------------------------------

Date: Fri, 29 Aug 1997 10:16:11 -0700
From: "Stephane L. Couillaud [VOBio]" <stephane@titude.arc.nasa.gov>
Subject: find command with perl
Message-Id: <340703DB.B11A81D3@titude.arc.nasa.gov>

Hello there!

    I hope I won't be wasting bandwidth by asking this question.
Basically, I'm having a problem using either find or find2perl in a
perl script.  When I type the following command on the command line

/usr/bin/find /admin/vobadm/tmp -name "WYNDE*" -mtime +10 -exec ls -l {}
\;`);

I have no problem getting the info I'm looking for, howerver, if I put
it in a Perl script like so

#!/usr/local/gnu/bin/perl -w
system(`/usr/bin/find /admin/vobadm/tmp -name "file*" -mtime +10 -exec
ls -l {} \;`);

then I get the following message:  /usr/bin/find: incomplete statement.

I also tried this alternative but I get the same message.

#!/usr/local/gnu/bin/perl -w
find2perl /admin/vobadm/tmp -name "WYNDE*" -mtime +10 -exec ls -l {} \;

Would someone have an idea why this isn't working?  Sorry, it has been
discussed already.


    -Stephane


--
-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+

Stiphane L. Couillaud                          Sterling Software Inc.
E-mail: stephane@titude.arc.nasa.gov           NASA Ames Research Center
Phone:  (650) 604-0277                         Mail Stop 210-9
Fax:    (650) 604-0174                         Moffett Field, CA 94035

-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+-=+





------------------------------

Date: Fri, 29 Aug 1997 13:18:41 -0700
From: Adam Reeves <areeves@us.ibm.com>
Subject: Help Capturing Error Messages From sendmail
Message-Id: <34072EA1.75B9@us.ibm.com>

In the following code I can't seem to capture any error messages that
arise from sendmail! The 'open or die' construct doesn't seem to do the
trick. Could someone tell me what I am doing wrong? I think it has
something to do with signals but I don't know how to handle them. If
that is the case could you give me an example.

Also I get the following warning message:
Name "$Q::internalmail" used only once: pssible typo at send.pl line 27
(#1)
	(W) Typographical errors often show up as unique variable names.
	If you have a good reason for having a unique name, then just
	mention it again somehow to supress the message (the use vars
	pragma is provided for just this purpose).
I couldn't figure out how the use vars pragma worked because everytime I
tried to declare $Q::internalmail with it, it gave me some error message
about "you can't declare another packages variable with this pragma."
How do I supress that message properly, in other words leaving the
warnings, strict, and diagnostics turned on?

Thanks in advance!
Adam Reeves

#!/my/path/to/perl -w

use 5.003;       # This script requires Perl version 5.003 or later
use English;     # Use English or awk Names for Punctuation Variables
use strict;      # Restrict Unsafe Constructs
use diagnostics; # Force Verbose Warning Diagnostics
use CGI;         # Perl5 CGI Library

my ( $query, $subject, $to, $name, $email );

$query = new CGI;

$query->import_names('Q');

$subject = "FooBar";
$to      = $Q::to;
$name    = 'Webmaster';
$email   = 'Unknown';

open(MAIL, "|/usr/sbin/sendmail -F\"$name\" -f \"$email\" \"$to\"")
   or die("Cannot send mail to $email: $OS_ERROR");

   print MAIL <<MESSAGE;
Subject:  $subject
Reply-To: $Q::email
----------------------------------------------------------------------
Customer Name:   $Q::username
Customer Number: $Q::custnum
Customer Email:  $Q::internalmail
MESSAGE

close(MAIL)
   or die("Could not complete the email to $email: $OS_ERROR");

print $query->header;
print $query->start_html(-title   => "Confirmation",
                         -bgcolor => "white");
print $query->h2("Confirmation");
print $query->p("Your input has been accepted and sent to Customer
Support.");
print $query->end_html;

exit;


------------------------------

Date: Fri, 29 Aug 1997 16:16:17 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: HTML --> Perl conversion
Message-Id: <3406f4f7.69507436@igate.hst.moc.com>

[cc'd automagically to original author]

On Sat, 16 Aug 1997 11:05:49 +0200, Aitor <webmaster@dmedia.net>
wrote:

>Is there any program (for Macintosh) to transtale to perl an HTML page?

Odd question. Not sure why you'd need to do it, but okay...

---snip---

#!perl -w

my @lines;

@lines = <>;

print "<HTML><HEAD><TITLE>Perl Script</TITLE></HEAD>";
print "<BODY><PRE>\n";
print @lines;
print "</PRE></BODY></HTML>\n";

exit;

---snip---

It's not very elegant, but hey... it's good enough to illustrate the
concept.

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


------------------------------

Date: 29 Aug 1997 16:20:44 GMT
From: gbacon@adtran.com (Greg Bacon)
To: cowbys@aol.com (COWBYS)
Subject: Re: I have to ASK
Message-Id: <5u6sss$4c7$9@info.uah.edu>

[Posted and mailed]

In article <19970829154501.LAA29882@ladder01.news.aol.com>,
	cowbys@aol.com (COWBYS) writes:
: I am looking for the FTP.pm module, I know what CPAN is and Ive been there,
: my understanding was that i could go there and download modules, Ive gone
: into "modules", "by module" and I dont see any  ".pm" files, Isnt there an
: easier way of 
: obtaining a particular ".pm" file from somewhere.

Did you bother checking the CPAN modules list?

    http://www.perl.com/CPAN/modules/00modlist.long.html

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:44:51 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: My counter counts, but too munch
Message-Id: <3406EE73.3358C9D7@gpu.srv.ualberta.ca>

Lozano Mosterin, Jesus wrote:
> 
> Hello
> 
> I want to count the "0" chars in various strings of lengh 7,
> related to string position. I'm using this and sometimes works
> as expected, others don't, counting one ocurrence more in the
> seventh position
> 
> for ($j=0;$j<7;$j++) {  $stat[$j]++ if ($j == index($temp,"0",$j)); }
> 
> Thanks for your help

assuming that you mean that you want to look at several
strings of length 7 and have @stat reflect how many zeroes
were found at each position in those strings...then it
appears to work...ie:

my @stat=(0)x7;
while(<DATA>) {
 $temp=$_;
 for ($j=0;$j<7;$j++) {  $stat[$j]++ if ($j == index($temp,"0",$j)); }
}
foreach $i (0..$#stat) {
   print "$stat[$i] zeroes at position ",$i+1,"\n";
}
__DATA__
1234567
0123450
0012400
0001000
1111111
--------

prints:
3 zeroes at position 1
2 zeroes at position 2
1 zeroes at position 3
0 zeroes at position 4
1 zeroes at position 5
2 zeroes at position 6
3 zeroes at position 7

another way might be to replace your 'for' loop with:
$stat[pos($temp)-1]++ while $temp=~/0/g;
which also gives the same results.

perhaps you can post some data and code which 
appears to mis-count your zeroes?

regards
andrew


------------------------------

Date: Fri, 29 Aug 1997 12:37:34 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Pattern Matching
Message-Id: <340708DE.228C09C4@gpu.srv.ualberta.ca>

Joseph Essas wrote:
> 
> Hi
> 
> I need to find the first place in a string where certain string is not
> included. For example:
> 
> $string="abcdeabce";
> 
> I need to find the first place where there is: a..something that not
> 'bcd'..e
> 
> I tried $string=~/a[^(bcd)]e/ but it didn't work

you can try something like:

$string="abcdeabceblaheabcdeblahabcdeabcde";
while ($string=~/(a(?!bcd).*?e)/g) {
   $pos= pos($string)-length $1;
   $not_string=$1;
   print "$not_string occurred at position $pos\n";
}

note, the third occurrence of the substring you want
(or is that 'don't want') contains the substring you
don't want (or do want)...so you'll have to work on it if
this behaviour is not quite what you didn't want :-)

regards
andrew


------------------------------

Date: Wed, 27 Aug 1997 16:36:51 -0400
From: chris abraham <chris@purple.tmn.com>
Subject: Perl script question for gurus
Message-Id: <Pine.SOL.3.96.970825153417.22465A-100000@purple.tmn.com>

I am resending this for a friend; please respond to <mark@tmn.com>

I'm trying to write a quick script to rename a few thousand files in
sequential order.  Before I tax my novice skills creating a bug-filled
script, I'd like to see if this has been done before and is sitting on
someone's harddrive.

Thanks for any help!

Sie koennen auf Deutsch antworten.
On peut repondre en Francais.
Se puede contestar en Espanol.


I'm trying to rename a few thousand files in sequential order.

ie.

I have:
I want to change it to:

blah.txt   -->			00000001.txt
blub.txt			-->			00000002.txt
this.txt   -->   00000003.txt
that.txt   -->			00000004.txt
etc.txt				-->			00000005.txt


and so on...

At a later date, more files will show up, so I'd like to be able to start
at whatever number I choose.

ie.

>what number do you want to start at?
2409

>ok

blah.txt   -->			00002409.txt
blub.txt			-->			00002410.txt
this.txt   -->   00002411.txt
that.txt   -->			00002412.txt
etc.txt				-->			00002413.txt


I'll probably be running off a Windows box... I've heard there are
differences in the versions of perl.

Cheers, and thanks!

Mark Harrison

-- 
chris abraham <chris@urban.net> +1 202.452.7442 <http://www.urban.net>
the urban design group  po  box  15163  washington  dc  20003-0163 usa
    "peculiar travel suggestions are dancing lessons from god."





------------------------------

Date: 29 Aug 1997 17:06:51 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Perl, ODBC, & Solaris 2.x ????
Message-Id: <5u6vjb$gqu$1@vixen.cso.uiuc.edu>

aggarwal@dti.net wrote:
: 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...
: 

Not unless you use ....

: i am running an informix database server, and am familiar with DBD and
: DBI, however those won't suffice, i need something more generic.

DBD::ODBC.  I don't know how you can get more generic than

	use DBD::ODBC;
	$dbh = DBI->connect();
	$dbh->do("UPDATE inventory SET QTY='5' WHERE CODE='00-0011a'");
	$dbh->disconnect;

I needed to update a database I use, so that is tested code. 8-)

In any case, that is what is out there. I am finding it quite useful,
myself -- and quite generic.  It not only does ODBC but the other
vendor-proprietary interfaces.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


------------------------------

Date: 29 Aug 1997 15:50:41 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: Q: Daemon-Programming - HOWTO?
Message-Id: <5u6r4h$4c7$7@info.uah.edu>

In article <5u6m5o$4c7$3@info.uah.edu>,
	gbacon@adtran.com (Greg Bacon) writes:
:     sub daemon_init {
:         my $pid;
: 
:         if (not defined($pid = fork)) {
:             $@ = "Failed fork: $!\n";
:             return undef;
:         }
:         elsif ($pid != 0) {
:             sleep 15;
              ^^^^^^^^^

That sleep is worthy of nothing but a quick and painless dd.

Sorry about that,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


------------------------------

Date: Fri, 29 Aug 1997 09:06:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mukund Rao <mrao@nospam.trincoll.edu>
Subject: Re: Q:Perl comm-line substitution
Message-Id: <Pine.GSO.3.96.970829090409.15991V-100000@julie.teleport.com>

On Fri, 29 Aug 1997, Mukund Rao wrote:

> 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.

Use File::Find.

>   perl -pe 's/find/replace/' `find ./ -print`
> 
> is my general idea. But this doesn't seem to be working quite without a
> hitch. 

Maybe you need more hitches. :-)  But I think you probably wanted
something like -i.bak in there.

>         Note: To reply, remove "nospam" from mrao@nospam.trincoll.edu

Note: To get replies by email, put the correct address in your message
headers.  :-) 

-- 
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 16:16:19 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Mukund Rao <mrao@nospam.trincoll.edu>
Subject: Re: Q:Perl comm-line substitution
Message-Id: <5u6skj$4c7$8@info.uah.edu>

[Posted and mailed]

In article <Pine.SOL.3.95.970829104636.21764A-100000@shakti.cc.trincoll.edu>,
	Mukund Rao <mrao@nospam.trincoll.edu> writes:
: 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.

You forgot your i.  Try

    % perl -pi.bak -e 's/find/replace/' `find . -print`

Of course, you might do better with something like

    #! /usr/bin/perl -w

    $^I = ".bak";

    open FIND, "find . -print |" or die "Failed fork: $!\n";

    chomp(@ARGV = <FIND>);
    chomp(@ARGV = `grep -l find @ARGV`);

    while (<>) {
        s/find/replace/;
    }
    continue {
        print or die "failed print: $!\n";
    }

That way, you avoid having useless backup copies of files in which
no changes were made.

:         Note: To reply, remove "nospam" from mrao@nospam.trincoll.edu

Grrr.. friggin header mungers. :-(

Hope this helps,
Greg
-- 
To reply, add I-AM-A-WEENIE-BECAUSE-I-BREAK-WHAT'S-ALWAYS-WORKED to my
email address. :-)


------------------------------

Date: Fri, 29 Aug 1997 16:47:24 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Simple Search Script
Message-Id: <3407fce3.71535562@igate.hst.moc.com>

[cc'd automagically to original author]

On 28 Aug 1997 15:33:23 GMT, "Matthew Feinberg" <matt@monmouth.com>
wrote:

>Can anyone direct me to where I can find a simple search and replace
>script.
>for example I want to be able to replace a word or a string on multiple
>pages in a directory.
>
>i.e.  ./replace filename wordtoreplace newword

How about:

  perl -i.bak -p -e "s/oldword/newword/goi" filename

Making it work for multiple files/dirs is left as an exercise to the
reader. But I'll suggest File::Find.

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


------------------------------

Date: 29 Aug 1997 16:01:04 GMT
From: akarandi@pcocd2.intel.com (Arvind Karandikar - VT ~)
Subject: Socket question
Message-Id: <5u6ro0$a70$1@news.fm.intel.com>
Keywords: Sockets, perl 5

Hi, 

I'm trying to understand the code for Unix domain clients and servers 
in the 2nd edition of Programming Perl. There are a few things i 
havn't understood here - 

1. What is the reason for using the file /tmp/catsock ?
2. what does the function sockaddr_un() do ?
3. Why is $uaddr bound to Server? it isn't used at any later
   time. Is this call necessary?
4. along the same lines, $proto isn't used at all. Are these calls
   necessary to start communicating?

and, lastly, a more general question - 

5. Can i replace the perl client with a java client? what percautions 
   will i have to take to do this? does anyone have pointers to more 
   info for this?

yes, i have gone thru' the FAQ, as well as the documentation 
listed on the perl homepage.

The server code is as follows: 

#!/usr/bin/perl -w

require 5.002;
use strict;
use Socket;
use Carp;
use FileHandle ;

sub spawn ;
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }

BEGIN { $ENV{PATH} = '/usr/ucb:/bin'} ;

my $NAME = '/tmp/catsock';
my $uaddr = sockaddr_un($NAME) ;
my $proto = getprotobyname('tcp') ;
my $paddr ;

socket(Server, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!" ;
unlink($NAME) ;
bind (Server, $uaddr) or die "bind: $!" ;
listen(Server, SOMAXCONN)  or die "listen: $!";

my $waitedpid = 0;
logmsg "Server started on $NAME" ;

sub REAPER {
    $waitedpid = wait;
    $SIG{CHLD} = \&REAPER ;
    logmsg "reaped $waitedpid".($? ? " with exit $?" : "") ;
    }

$SIG{CHLD} = \&REAPER;

for(; $paddr = accept(Client, Server); close Client) {
    logmsg "Connection on $NAME" ;
    spawn sub {
        print "hi, its now ", scalar localtime, "\n" ;
        } ;
    }

sub spawn {
    my $coderef = shift ;

    unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
        confess "usage: spawn CODEREF" ;
        }

    my $pid;
    if (!defined($pid = fork)) {
        logmsg "cannot fork: $!" ;
        return;
        }
    elsif($pid) {
        logmsg "begat $pid";
        return ;
        }

    open(STDIN, "<&Client") or die "can't dup client to stdin";
    open(STDOUT, ">&Client") or die "can't dup client to stdout";
    STDOUT->autoflush() ;
    exit &$coderef() ;
    }

***************
the client is as follows:

#!/usr/bin/perl -w

require 5.002 ;
use strict ;
use sigtrap ;
use Socket ;

my ($rendezvous, $line) ;

$rendezvous = shift || '/tmp/catsock';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!" ;
connect(SOCK, sockaddr_un($rendezvous)) or die "connect: $!" ;
while($line = <SOCK>) {
    print$line ;
    }
exit ;



-- 
______________________________________________________________________
Arvind K. Karandikar
akarandi@pcocd2.intel.com
**not speaking for intel**
----------------------------------------------------------------------


------------------------------

Date: 29 Aug 1997 16:15:47 GMT
From: bob@cafemedia.com (Bob Maillet)
Subject: using unix commands for missing libwww module
Message-Id: <bob-2908971218330001@169.152.83.149>


Hi,

I am trying to get the following snippet of code to work..  The server I
am currently working on does not have the libwww module installed so I am
using unix commands to read the data from a remote sight..then parse out
that data.
I still have to enter a newline command when the script is run and the
data does not display..any ideas?

Bob







#!/usr/local/bin/perl


print "Content-type: text/html", "\n\n";

$stuff = `telnet www.wherever.com 80`;
$gruff = "\n";
$huff = "GET /data/ftpdata.dat HTTP/1.0";
$puff = "\n\n";

$rough = $stuff.$gruff.$huff.$puff;

print "$rough";

end


------------------------------

Date: Fri, 29 Aug 1997 13:12:38 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: Which Windows (95) Perl to use?
Message-Id: <EFoFD5.ArE@ig.co.uk>

In article comp.lang.perl.misc:<3407812a.4432159@207.126.101.82>, ron@farmworks.com (Ronald L. Parker) writes:
>On Thu, 28 Aug 1997 08:59:00 GMT, "Mark J. Gardner" <mjg@oms.com>
>wrote:
>
>>I'm assuming that "best modules" includes CGI.pm and LWP, right?
>
>Yes.  Along with GD, Tk (!), and of course the ultra-cool Net.  
>
>GSAR's 5.004 is, well, 5.004.  ActiveWare isn't yet.  GSAR also makes
>an effort to have perlbug and perldoc and other neat utilities that
>ActiveWare ignored.  All in all, it's a much better distribution and a
>much better job of porting.
>And none of it is copyrighted by Micro$oft.

I will have to remember this when describing the differences
between the various "flavours" of perl to customers.

<PLUG BLATANT="OFF"> :-)
Another good reason for using TOTP (The One True Perl :-)
is that commercial support is available (from us via
www.perl.co.uk/tpc) - and this includes modules such
as DBI and DBD::Oracle!
</PLUG>

All the best,
	Jacqui
-- 
Jacqui Caren                    Email: Jacqui.Caren@ig.co.uk
Paul Ingram Group               Fax: +44 1483 419 419
140A High Street                Phone: +44 1483 424 424
Godalming GU7 1AB United Kingdom



------------------------------

Date: 29 Aug 1997 07:13:35 -0700
From: jimmy$1@peter.com (Jimmy Aitken)
Subject: Re: Wrong status from system() in child process ?
Message-Id: <5u6lef$j15$1@shell3.ba.best.com>

In article <Pine.GSO.3.96.970828151206.18691K-100000@julie.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>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

Alternatively the program 'webget' could be exiting with -1 and hence
this value is passed on to the shell.  What happens if you run it from
the shell and then type
echo $?		# For ksh/sh/ or
echo $status	# for csh and derivatives

If it gives 255, then perl is reporting the correct value.  e.g.:

$ cat /tmp/a
#!/usr/local/bin/perl5
$rc=system("sh -c 'exit 255'");
$rc = ($rc & 0xffff) >> 8;
print "rc is $rc\n";

$ perl5 /tmp/a
rc is 255

Jimmy
-- 
jimmy@pyramid.com [work]    For secure mail, use my PGP key available from
jimmy@peter.com   [home]    PGP servers or "finger petejim@shell3.ba.best.com" 
 __                         Key ID is: EEAB8101
 \/ http://www.peter.com
`Rrrrum Ti-Tum Ti-Tum Ti-Tum, Rrrrum Ti-Tum Ti Ta-Ta,
 Rrrrum Ti-Tum Ti-Tum Ti-Tum, Rrrrum Ti Tiddly Ta...'




------------------------------

Date: 29 Aug 1997 17:25:10 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Wrong status from system() in child process ?
Message-Id: <5u70lm$rfb$1@lyra.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>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.

I also found a return of -1 odd (and unexpected), since it isn't a valid
Unix return code.    So I snuffled in the code of pp_system in pp_sys.c
and found the following undocumented feature (if I've interpreted the
code correctly  -  I can't see how to make a test case):

If system fails internally (i.e. the vfork fails, or the wait4pid fails)
then it will return a value of -1.   $? will be set to -1 and $! will
be set to a suitable error number/message.

If the fork fails because of "Process table full", system will wait 5
seconds then retry _ad infinitum_.   Eeek!


Given the $! value, it looks as though the wait4pid is failing, because
someone else has reaped the child already (or the system has lost it,
or something ... ).    Do you have a $SIG{CHLD} set?


Mike Guy


------------------------------

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 947
*************************************

home help back first fref pref prev next nref lref last post