[8175] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1793 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 3 00:07:32 1998

Date: Mon, 2 Feb 98 21:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 2 Feb 1998     Volume: 8 Number: 1793

Today's topics:
    Re: (no subject) (Martien Verbruggen)
        @INC points to nonexisting directories <hensh@math.msu.edu>
    Re: [utility] submit "unix_command" (Michael Wang)
    Re: can variables be generated on the fly <cdkaiser@delete.these.four.words.concentric.net>
        Crazy Idea <ldanna@hotmail.com>
    Re: crypt in perl CGI (David Efflandt)
    Re: dc.pm.org (Chris Winters)
    Re: Deleting directories (Michael Wang)
    Re: Error with analysis of system () return value on Pe (Michael Wang)
    Re: Error with analysis of system () return value on Pe (Chip Salzenberg)
        help with multi-line regexp subsitution <blairhj@intnet.net>
    Re: How do I get IP address of script user? <rjk@coos.dartmouth.edu>
    Re: How Do I Tell Whether a Key Is Valid for an Associa (Michael Rubenstein)
    Re: How Do I Tell Whether a Key Is Valid for an Associa <joegottman@nospam.worldnet.att.net>
    Re: How do you make the something case-insensitive? (Martien Verbruggen)
    Re: How to search for control characters ... <ebohlman@netcom.com>
    Re: How to write fixed format data? <j.metcher@spmed.uq.edu.au>
    Re: Is There a Way to Switch the case Sensitivity of Pa <rhodri@wildebst.demon.co.uk>
    Re: LWP problem: Error: 500 Offset outside string (Paul J. Schinder)
        multi-line regexp help needed <blairhj@intnet.net>
    Re: Parsing Word Docs <rhodri@wildebst.demon.co.uk>
        Please, help - rsh problem. (Eugene Kogan)
    Re: Q: What is the good way to process data like... <rhodri@wildebst.demon.co.uk>
    Re: removing a line from a file <benefits@cybertechs.com>
    Re: removing a line from a file (Roy S. Rapoport)
    Re: replacement for ls command? (-Chen,P.W.)
    Re: s/// Usage Problems <rjk@coos.dartmouth.edu>
    Re: send mail bug... ;( (Martien Verbruggen)
    Re: solution for multiline comments??? (Michael Wang)
    Re: Where's a DBD-mSQL Module? (Chris Winters)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 3 Feb 1998 01:56:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: (no subject)
Message-Id: <6b5th9$q3e$1@comdyn.comdyn.com.au>

[Subject: Re: (no subject)]

read the helpful article on how to choose a good subject at

http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

In article <34D6455C.638F@svcam.amd.com>,
	CS44 Personel <dwu@svcam.amd.com> writes:

> I'm reading in a file from one location on my unix system
> And printing the contents to another location. Heres my code.
> open (guesthandle , ">>usr/printtwo.html");
> open (guesthandle , "usr/printfrom.log");

Always check the return code of an open() statement.
Always check the return code of an open() statement.

You open the same handle twice.

> while (<guesthandle3>) {
> print guesthandle2;

This doesn't do anything. It should give you a warning message.
What are guesthandle2 and 3 anyway?


> (assumed location for needed instruction)
> }
> Anyway I want to save the last line printed form  hte file
> printfrom.log
> I have tried @a = @ARGV;

Why?

> and then print @a at the end of the program and a few other methods
> but nothing has worked so far.

One way to print the last line from a file, which might be not the
best one depending on the size etc..

#!/usr/local/bin/perl -w
use strict;

my $some_file = '/foo/bar/file';
my $out_file = '/foo/bar/out_file';
my $last_line;

open(FFF, $some_file) or die "Cannot open $some_file: $!";
while (<FFF>) { $last_line = $_; }
close(FFF);

print $last_line;

Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd.       | thing but mean your mother.
NSW, Australia                      | 


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

Date: Mon, 2 Feb 1998 22:11:57 -0500
From: "Richard Hensh" <hensh@math.msu.edu>
Subject: @INC points to nonexisting directories
Message-Id: <6b61l3$4vc$1@msunews.cl.msu.edu>

I'm using the perl5.004_02 win32 (Sarathy's) port on a WinNT4.0 machine.

Typing the command:

perl -e "print \"@INC\n\"" returns

g:\perl5004\lib\site g:\perl5004\lib c:\perl\lib c:\perl\lib\site
c:\perl\lib\site .



The first two paths are correct but the last three don't even exist on my
machine.  I've searched through the doc's and some older threads (in this
and related newsgroups) for help but I have not run across any tips about
how to %permanently% correct this. The comments that I've seen, seem to
offer only temporary fixes, and these must be reapplied with each perl
script.

Is there a way, short of recompiling, to point @INC to the correct libraries
so that

perl -e "print \"@INC\n\"" returns

g:\perl5004\lib\site g:\perl5004\lib


If not, where did the last three (four, if the "." is counted) paths come
from??


thanks
ricky






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

Date: 3 Feb 1998 03:13:32 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: [utility] submit "unix_command"
Message-Id: <6b620s$a5v$1@news.ml.com>

Eli the Bearded  <*@qz.to> wrote:
>Michael Wang <mwang@alhena.ibk.ml.com> wrote:
>>     submit allows you disconnect from the system after submitting a
>>     unix_command. submit spawns a child process to execute unix_command, 
>>     and then exits. The child process is adopted by init, and runs 
>>     independent of the parent. 
>
>Did you just reinvent "nohup unix_command &"?
>
>fails to see the advantage of this over nohup anyway

advantages:
  0. It does accept hangup signal
  1. It does not need &
  2. It works with rsh
  3. It recognize the command sequences: submit ./configure\; make
  4. It checks the return value from system() call
  5. It has self trimming log file
  6. It send both stdin and stderr to log file
  7. much much more :-)

This utility is available from
ftp://ftp.mindspring.com/users/mwang/submit
I have another utility niftp (non-interactive ftp) from
ftp://ftp.mindspring.com/users/mwang/niftp
You can submit niftp, or you can niftp submit, or you can
submit niftp something else :-)


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

Date: 3 Feb 1998 04:22:08 GMT
From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net>
Subject: Re: can variables be generated on the fly
Message-Id: <6b661g$19f@examiner.concentric.net>

aml@world.std.com (Andrew M. Langmead) writes:

>>Why? There's nothing in the New Testament aka Programming Perl that calls
>>symbolic references depreciated.

>No, there is just text that discourages their use.

I already found it after Tom C. chastised me. :-)
I'm just a depreciated guy, I guess.

--
Cameron Kaiser
cdkaiser at concentric dot net (it hasn't helped the spam yet though)
*** visit the Spectre Server at www.sserv.com
*** C64 software lives! www.computerworkshops.home.ml.org


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

Date: Mon, 02 Feb 1998 22:48:32 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Crazy Idea
Message-Id: <34D69390.4277B91A@hotmail.com>

I have no idea if this is possible but if 
would be pretty cool if you could do something like
this in a future release of perl...

m{ 
    \d+
  | (?:
      \(
      (?RECURSE)
      \)
    )
  | (?:
      (?RECURSE)
      [-+*/]
      (?RECURSE)
    )        	
}x

This would match an infix expression with an 
arbitrary amount of nesting.
 
---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
|               -Winston Churchill
---------------------------------------------------
Larry D'Anna                   "eschew obfuscation"


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

Date: Tue, 03 Feb 1998 01:38:19 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: crypt in perl CGI
Message-Id: <34d972f3.4732325@flood.xnet.com>

"Frederic Francken" <francken@kbinirsnb.be> wrote:

>Can anyone help me with writing a small script which generates a password file using the crypt routine as htpasswd does?
>I'm not at all familiar with Perl, so help is much appreciated.
>The script should ask a filename (password file) and a userID after which it asks for a password twice.
>The file structure should be something like this :

If you are doing it from the shell you could use the htpasswd that
comes with apache.  Otherwise I have an htpasswd.cgi that can be set
to allow only you to add users and passwords using an admin password.
An option can be set to allow anyone to add their name and password if
you are just tracking users.

See:  http://www.xnet.com/~efflandt/pub/


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: Tue, 03 Feb 1998 03:30:53 GMT
From: cwinters@clark.net (Chris Winters)
Subject: Re: dc.pm.org
Message-Id: <34d68f57.3292055@news.clark.net>

I'm there

Er, here.

Chris

hood@panix.com (Philip Hood) wrote:

>#################################################################
>d	c	. 	p	m 	. 	o	r	g
>#################################################################
>
>If New York has and LA and Boston are gonna have
>organized perl'ers, DC needs to have some as well!
>
>more later ...
>PH
>
>#!/usr/bin/perl -dc.pm.org
>My Sig Here!



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

Date: 3 Feb 1998 02:34:48 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: Deleting directories
Message-Id: <6b5vo8$a47$1@news.ml.com>

Jonathan Nicholson <jono@nospam.nowhere.noorg> wrote:
>
>Here's the little subroutine I use to do just that:-
>
>sub recursiverm {
>        my $file;
>        my ($directory) =  @_;
>	if (! -d $directory  )
>	{
>		unlink $directory;
>		return;
>	}
>        opendir THISDIR, $directory or return;
>        foreach $file ( grep !/^\.\.?$/, readdir THISDIR ) {
>                &recursiverm("$directory/$file");
>        }
>        closedir THISDIR;
>        rmdir $directory;
>}
>
>Its bloody fast too, on Digital Unix it will out perform the system rm -rf

OK, but do you include above subroutine in every perl script
which needs it? or what do you do? Thanks. 


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

Date: 3 Feb 1998 00:31:23 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: Error with analysis of system () return value on Perl book page 230
Message-Id: <6b5ogr$9tg$1@news.ml.com>

Chip Salzenberg <chip@pobox.com> wrote:
>According to jdporter@min.net:
>>So if the return value was 0x88, that's 0x0088; the low byte is not
>>zero, so ignore the high byte.
>
>You have that backwards, I'm afraid.  Check the *high* byte first.
>If it's zero, then the program exited normally, and the low byte
>is the exit code.  If the high byte isn't zero, then it represents
>the reason why the program died -- typically a signal number.

One line of code is worth of thousand lines of words :-)
    my $WIFEXITED = ( ($stat&0xFF) == 0 );
    my $WEXITSTATUS = ($stat>>8)&0xFF;
    my $WIFSIGNALED = ( ($stat&0xFF) > 0 && ($stat&0xFF00) == 0 );
    my $WTERMSIG = $stat&0x7F;

According to my code, which is copied from solaris <sys/wait.h>,
I have to say jdporter got it right and Chip Salzenberg got it backwards.
Is there a different kind of machine? I do not know. 


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

Date: Tue, 03 Feb 1998 02:09:03 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Error with analysis of system () return value on Perl book page 230
Message-Id: <6b5ubn$pq8$1@cyprus.atlantic.net>

According to mwang@alhena.ibk.ml.com (Michael Wang):
>Chip Salzenberg <chip@pobox.com> wrote:
>>According to jdporter@min.net:
>>>So if the return value was 0x88, that's 0x0088; the low byte is not
>>>zero, so ignore the high byte.
>>
>>You have that backwards, I'm afraid.
>
>One line of code is worth of thousand lines of words :-)  [...]
>According to my code, which is copied from solaris <sys/wait.h>,
>I have to say jdporter got it right and Chip Salzenberg got it backwards.

*sigh*  Please shoot me.  Or force-feed me the wait(2) man page.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
 "Boy, is it ever dark."  "I hope they don't get a moonburn."  // MST3K
           ->  Ask me about Perl training and consulting  <-
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Mon, 02 Feb 1998 22:01:52 +0000
From: "Hugh J. Blair" <blairhj@intnet.net>
Subject: help with multi-line regexp subsitution
Message-Id: <34D64250.795C@intnet.net>

Help !  I'm a perl newbie so this could make or break my perl career.
I'm trying to extract multi-line block of text from a very large file.
I can specify the begin pattern and the end pattern. The variation is a
string in the middle.
Any help will be greatly appreciated.

Thanks, Hugh Blair

-- 
_______________________________________________________ 
Some foolish people think science takes the wonder out of the universe;
          the exact opposite is true.
Genuine understanding is not only more useful than superstition or myth;
          it is always much more interesting.         Arthur C. Clarke
_______________________________________________________


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

Date: Mon, 02 Feb 1998 23:23:17 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: How do I get IP address of script user?
Message-Id: <34D69BB6.19A7A67C@coos.dartmouth.edu>

[posted but not mailed.  munged addresses are annoying.]

Martin Oakley wrote:
> 
> I can get the usename with $uid = getlogin;
> How can I get the ip address of the user, logged in via telnet,
> running the perl script?
> 
> Solaris and other UNIXes seem to do this because they report  "last
> login from xxx.xxx.xxx.xxx"

Look into the UNIX 'last' command.

Chipmunk


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

Date: Tue, 03 Feb 1998 02:10:31 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: How Do I Tell Whether a Key Is Valid for an Associative Array?
Message-Id: <34d67c2a.182193139@nntp.ix.netcom.com>

On 2 Feb 1998 23:20:07 GMT, simonsen_nospam@skopen.dseg.ti.com (Kevin
M Simonson) wrote:

>     I'm coding an application that looks like it would be nicely imple-
>mentable with a hash table.  But I can't seem to figure out how to do it.
>Anybody out there interested in helping me?  If so, you can mail me at
>"simonson@skopen.dseg.ti.com".
>
>     My "perl" script needs to read in a list of key words from one file,
>though the only information it needs to store for each key word is the fact   
>that it existed in the file.  So far, so good; I can implement that as an
>associative array that has keys but ignores the rest of its data.
>
>     At this point the script can close the first file, opens a source file   
>for input, and opens a destination file for output.  Each time it finds a
>certain series of characters in the input file, it needs to check the word
>that follows it to see if it was one of the files read from the first file.   
>That is, it needs to check to see if it exists in the associative array.
>
>     How do I do this?  If I write my code as follows:
>
>%Abc = ( "Xyz" , 0 , "Abc" , 1);
>
>how do I write a statement that refers to '$Abc{"Def"}' that will detect
>that it has been defined, and yet make another statement that refers to
>'Abc{"Fhi"}' to realize it does not exist, without blowing up and killing
>the execution of the script?

	if (exists $Abc{"Def"})
	{
	  # ...
	}
--
Michael M Rubenstein


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

Date: Mon, 02 Feb 1998 23:36:57 -0500
From: Joe Gottman <joegottman@nospam.worldnet.att.net>
Subject: Re: How Do I Tell Whether a Key Is Valid for an Associative Array?
Message-Id: <6b677j$3cu@bgtnsc03.worldnet.att.net>



Steve Linberg wrote:

> In article <6b5ohg$pgr$1@cyprus.atlantic.net>, chip@pobox.com wrote:
>
> > According to simonsen_nospam@skopen.dseg.ti.com (Kevin M Simonson):
> > >%Abc = ( "Xyz" , 0 , "Abc" , 1);
> > >how do I write a statement that refers to '$Abc{"Def"}' that will detect
> > >that it has been defined ...
> >
> >   if (exists $Abc{Def}) {}
>
> Uh oh, now I've done it.  I said "define" and other people said "exists".
> And me without my Perl docs handy...
>
> I think they both work in this case, but perhaps someone with books at
> hand (or in head) could clear up the difference.
>
> Blush...
>
>
>
>

    To see the difference, do the following
   %foo = ();
   $foo{'bar'} = undef();

  print "defined\n" if defined($foo{'bar'}); #Will not print, $foo{'bar'}
equals undefined value.
  print "exists\n" if exists($foo{'bar'}); #Will print. 'bar' IS a key of the
hash %foo.

--
Joe Gottman
joegottman@nospam.worldnet.att.net

[Remove nospam to reply]




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

Date: 3 Feb 1998 03:09:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do you make the something case-insensitive?
Message-Id: <6b61oe$qra$1@comdyn.comdyn.com.au>

In article <34D1D710.2AA2254A@mindspring.com>,
	Stephen Miano <smiano@mindspring.com> writes:

> Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"

Please get rid of this. You just sent a 41 line reply to a 3 line question.
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: Tue, 3 Feb 1998 00:27:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How to search for control characters ...
Message-Id: <ebohlmanEns19r.Ax3@netcom.com>

Rajiv Shivane <shiva001@tc.umn.edu> wrote:

: I am a new perl user and I managed to go through the ``learning perl''
: book but I am not able to search for control characters. I want to
: search and replace all the control M (^M) characters in $_ with <BR>\n.
: I tried s/^./<BR>\n/g; but it didn't work.

Of course it didn't.  That says to replace the first character on the 
line with "<BR>\n" and then to try to repeat it (which will always fail, 
because you have only one line in $_.

Try s/\r/<BR>\n/g;

: If the answer is there in one of the FAQs I would really appreciate it
: if you could send me the address of teh FAQ.

If you have a recent version of Perl on your system, the FAQs were 
included in the distribution in at least two formats: perlfaq.pod, 
perlfaq1.pod, perlfaq2.pod, ... are the FAQs in POD format, which you can 
read using the perldoc program that came with your distribution.  If you 
have a Unix distribution, the files will also be available as man pages; 
if you have a Win32 distribution, they'll be available as HTML files; if 
you have another platform, you'll have to check the appropriate readme 
files to find out what format the FAQs are in.

If worse comes to worse, you can find HTML versions of the FAQs at 
<http://www.perl.com/reference/>.


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

Date: Tue, 03 Feb 1998 10:40:00 +1000
From: Jaime Metcher <j.metcher@spmed.uq.edu.au>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: How to write fixed format data?
Message-Id: <34D66760.18A843DE@spmed.uq.edu.au>

Ah ha!  Right you are - thanks to you and Eric for pointing this out. 
The moral of the story is - use perldoc!

The trap that I fell into (not that I have a mania for self-revelation,
but some other poor denizen of Win32 might be caught, too) was assuming
that the contents of my docs directory (\perl\docs) was the same as the
pod directory (\perl\lib\pod) run though the pod2html converter.  Folks,
it's not!  \perl\docs was left over from the ActiveState (nee
Activeware) distribution and is less complete.  The pod2html stuff is in
\html\lib\pod (a much less alluring pathname, si?)

So I'm suffering from  a surfeit of documentation - maybe I should give
some to charity...

--
Jaime Metcher

Tad McClellan wrote:
> 
> Jaime Metcher (metcher@spider.herston.uq.edu.au) wrote:
> : Printf pops up again and again in the perl docs (must be a useful
> : routine). However, Win32 users don't necessarily have documentation for
> : printf formats.   There's nothing in the perl docs or the FAQs.
>                             ^^^^^^^^^^^^^^^^^^^^^^^^
> 
> There is in _my_ perl docs...
> 
> : I'd say that references in the perl docs and the camel to documentation
> : that is non-existent on something like 50% of perl installations does
> : nothing to enhance cross-platform appeal.
> 
> Since you seem documentation impoverished ;-) I'll share mine
> with you.
> 
sprintf docs snipped


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

Date: Tue, 03 Feb 1998 04:32:01 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Is There a Way to Switch the case Sensitivity of Pattern Recognition?
Message-Id: <48126f09b0rhodri@wildebst.demon.co.uk>

Your Titles Have Capital Letter Disease :-)

In article <6b5mdu$1l2@sf18.dseg.ti.com>,
 Kevin M Simonson <simonsen_nospam@skopen.dseg.ti.com> wrote:
>      Currently the code below gives the following results.  I'd like to
> know if there's a way to do the pattern recognition with the second com-
> pare to get an equality.

>                #!/usr/local/bin/perl
>                $Jqz = "Mno";
# [snip]
#>               if ($Jqz =~ /mno/)
                 if ($Jqz =~ /mno/i)
>                {  print "Test succeeded.\n";
>                }
>                else
>                {  print "Test failed.\n";
>                }

>      Sorry if this is in the FAQ, but I'm not sure how to go about
> getting ahold of the FAQ.

You should have copious documentation along with your Perl distribution.
Does the 'perldoc' command do anything?

-- 
Rhodri James  *-*  Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them

 ... Worse things happen in C


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

Date: Mon, 02 Feb 1998 19:54:49 -0500
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: LWP problem: Error: 500 Offset outside string
Message-Id: <schinder-0202981954500001@schinder.clark.net>

In article <m3n2gajvw9.fsf@furu.g.aas.no>, Gisle Aas <aas@sn.no> wrote:

}  Scott Walde <scott_hates_spam@saskatoon.com> writes:
}  
}  > I'm getting this error message:
}  > 
}  > Error: 500 Offset outside string
}  > 
}  > When trying to execute this line:
}  > 
}  > my $res = $ua->request($req);
}  > ($ua is a LWP::UserAgent, $req is a HTTP::Request)
}  > 
}  > The funny thing is, this code runs on another machine just fine.
}  > 
}  > Old machine (where it works) is a Pentium 75, RH Linux 4.2 with Perl
}  > 5.003,  LWP 5.08.  The new machine is a Pentium 75 with RH5.0, Perl
}  > 5.004, LWP 5.19.  Is this a glibc issue?
}  
}  I don't know.  This message is generated by Perl when sysread() (or
}  read()) is given a bad offset parameter.
}  
}    $ perl -le 'sysread(STDIN, $a, 5, -4)'
}    Offset outside string at -e line 1.
}  
}  I would think that all the calls to sysread in LWP/Protocol/http.pm
}  should be safe (length($buf) should never be an "offside outside
}  string"):
}  
}    $ grep sysread http.pm 
}              my $n = $socket->sysread($buf, $size, length($buf));
}                  my $n = $socket->sysread($buf, $size, length($buf));
}          my $n = $socket->sysread($buf, $size);
}  
}  Does this happens for all URLs you try?
}  
}  Perhaps you can debug it?  Start by finding out which of the sysreads
}  are failing and then investigating the $buf.  Perhaps an strace(1) on
}  the process reveals something of interest?

I've seen it before.  In fact, I was about an hour away from reporting
this on the libwww-perl mailing list, but since it's here, I'll report it
here, and cc: to Gisle.  I ran into this and fixed this in my MacPerl port
of LWP-5.19.

This is due to the change from LWP::IO to IO::Socket, and it's caused by
$content being the null string in LWP::Protocol::http.  Because it's
defined, it gets past the if(defined $content), and handed to
$socket->syswrite.  The old LWP version protected itself ("while ($offset
< $len)") from 0 length writes, while the "new" IO version doesn't, and
complains with the error message above.

I put "new" in quotes because it doesn't happen on my Sun running the next
to last version of IO:: (just installed the latest today).  MacPerl tends
to come with older versions of the packages.  The version currently
installed with the latest MacPerl is 1.1602, while the latest IO:: is
something in the 1.18's.  So this may be taken care of by installing the
latest IO::, but Matthias Neeracher will have to do that for MacPerl
users.

The fix to LWP is simple.  In LWP/Protocol/http.pm, change

if (defined $content)

to 

if ($content)

on lines 98 and 134.

Gisle, is there any other protocol this might bite?  ftp seems to work,
but I haven't tested anything else yet.

}

-- 
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@leprss.gsfc.nasa.gov


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

Date: Mon, 02 Feb 1998 21:48:24 +0000
From: "Hugh J. Blair" <blairhj@intnet.net>
Subject: multi-line regexp help needed
Message-Id: <34D63F28.53F8@intnet.net>

Help !  I'm a perl newbie so this could make or break my perl career.
I'm trying to extract multi-line block of text from a very large file.
I can specify the begin pattern and the end pattern. The variation is a
string in the middle.
Any help will be greatly appreciated.

Thanks, Hugh Blair

-- 
_______________________________________________________ 
Some foolish people think science takes the wonder out of the universe;
          the exact opposite is true.
Genuine understanding is not only more useful than superstition or myth;
          it is always much more interesting.         Arthur C. Clarke
_______________________________________________________


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

Date: Tue, 03 Feb 1998 01:15:20 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Parsing Word Docs
Message-Id: <48125d07a6rhodri@wildebst.demon.co.uk>

In article <34D60F0B.96A@world.northgrum.com>,
 Charles Margolin <cmargoli@world.northgrum.com> wrote:
> That's very nice if you are receiving the Word file on a PC with
> Word installed, or if you can get the sender to do the SaveAs.
> The real problem is when a PC user forwards a Word file to a non-PC
> system.

My solution was to use network protocols:  I mailed the Word file back to
the sender together with a note reading "I SAID PLAIN TEXT, DAMMIT!".

-- 
Rhodri James  *-*  Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them

 ... but that's a herring of a different colour


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

Date: Tue, 03 Feb 1998 04:06:24 GMT
From: ekogan@mindspring.com (Eugene Kogan)
Subject: Please, help - rsh problem.
Message-Id: <34d6954c.1116822@news.mindspring.com>

Please, anyone! Any help would be greatly appreciated! 
I am having a problem with rsh. I execute rsh from my Solaris worksta.
by a perl script using system() call that executes a C-program on the
remote machine that setuid() to root, executing a start shell script
(also by a system() call) for a proxy server installed on the remote
machine that is also Solaris 2.5. The problem is that while the whole
process is done without any problems, the rsh never returns, it just
hangs even after the proxy is restarted. The C program is fine. I
tested it - when executed from a shell it returns with no problems at
all. Another thing, the rsh returns only when I stop the proxy server
(i.e., after I execute stop shell script that kills all proxy
children)

Sincerely,
Eugene Kogan


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

Date: Tue, 03 Feb 1998 01:28:16 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Q: What is the good way to process data like...
Message-Id: <48125e36f5rhodri@wildebst.demon.co.uk>

In article <886426896.2129133574@dejanews.com>,
 <dajen@globespan.net> wrote:
> Can anyone tell me what is the best way in Perl to text process a
> data structure like the following?

Well, you could read the whole file in, tokenise it, parse it into a
complicated recursive data structure, have your wicked way with it and
output the results.  Or you could do something simpler.  It all rather
depends on just what you mean by "text process".  Should we take it that
you are translating from one hardware description language to another? 
Would simple substitutions and reformatting do?  More information, please!

-- 
Rhodri James  *-*  Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them

 ... The trick is to remember which way is up


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

Date: Mon, 02 Feb 1998 21:02:21 -0500
From: Jason Boxman <benefits@cybertechs.com>
Subject: Re: removing a line from a file
Message-Id: <34D67AAD.25C2@cybertechs.com>

Chad R Cordero wrote:
> 
> How should I split a file into an array
> by line?

If I'm understanding your question, you should be able to do:

open(MYFILE, "$file");
while (<MYFILE>) {
	push (@filedata,$_);
}
close(MYFILE);

@filedata should contain each line of $file. So $filedata[0] has the
first line and so forth.

Jason Boxman
benefits@cybertechs.com


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

Date: 2 Feb 1998 19:26:06 -0800
From: rsr@shell3.ba.best.com (Roy S. Rapoport)
Subject: Re: removing a line from a file
Message-Id: <6b62oe$2p6$1@shell3.ba.best.com>

Jason Boxman  <benefits@cybertechs.com> wrote:
>> How should I split a file into an array
>> by line?
>
>If I'm understanding your question, you should be able to do:
>
>open(MYFILE, "$file");
>while (<MYFILE>) {
>	push (@filedata,$_);
>}
>close(MYFILE);

Or better yet --

open(MYFILE, "$file") || die ; 
@filedata = <MYFILE>  ;
close(MYFILE) ; 

Keep in mind that, in scalar context, <> handles give you one line;
but in an array/list context, they give you a list of the lines. 

-roy


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

Date: 3 Feb 1998 04:29:17 GMT
From: pwyc@ctcgp1.ih.lucent.com (-Chen,P.W.)
Subject: Re: replacement for ls command?
Message-Id: <6b66et$1m1@nntpb.cb.lucent.com>

In article <6ao9pb$lne$1@news.ml.com>,
Michael Wang <mwang@alhena.ibk.ml.com> wrote:
>>Is there an equivalent way of doing a Unix ls command?  For example,
>>	@found=`ls abc*/def*/some*.txt`;
>>
>>Without resorting to ``, or system, of course.
>
>I do not understand this. Is perl supposed to be a super set
>of C, ksh, or what? Otherwise why people constantly ask how do I
>do this and that in perl as I do in unix command, ksh, etc. 

Why, yes, that's a main reason I use perl.  Not to mention being a superset of
awk, sed, etc.  Several people have suggested using readdir, etc., I was
hoping there's a library somewhere that does this kind of thing so I don't
have reinvent it.  Heck, if someone thought it useful to provide "basename",
I'd think a "ls" would be at least as useful.

To rephrase my original question, I'm looking for something like:
	@found=&ls ("$pattern");
Surely someone has written something like that?  And before you flame me for
being lazy, please note laziness is one of the virtues extolled in the Camel
book.
-- 
Peter Chen	G__	Work to live.
		,>/-	Live to bike.
630-979-4679	O \O	Bike to work.


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

Date: Mon, 02 Feb 1998 23:40:33 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Bruce Hodo <bruceh@interaccess.com>
Subject: Re: s/// Usage Problems
Message-Id: <34D69FC2.C54D7F1F@coos.dartmouth.edu>

[posted and mailed]

Bruce Hodo wrote:
> 
> I'm guessing that I'm not doing something properly, but I can't figure
> out what. Here is my code:
> 
>           $field =~ s/'/\'/g;

The right side of a substitution is subject to double-quotish processing.
Your substitution is exactly equivalent to:

$field =~ s/'/'/g;

which is obviously not what you want.

Instead, you should be backslashing the backslash:

$field =~ s/'/\\'/g;

which puts a literal backslash in the string.

Chipmunk


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

Date: 3 Feb 1998 03:19:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: send mail bug... ;(
Message-Id: <6b62c5$qra$2@comdyn.comdyn.com.au>

In article <34D39559.8B5E9EBC@ica.net>,
	Alexander Kovalenko <luckycom@ica.net> writes:
> hey for some reason when I am sending e-mail , it sends without any
> SUBJECT !!! whatz wrong with the following script :

This is not a sendmail bug. Read the man pages.
You're not using perl to send mail.
Don't shout.
"what's" is not spelled whatz.

>   print SENDMAIL "To: ", $addressee, "\n\n";

One too many \n.

> so any ideaz wqhat did i do wrong?

The plural of "idea" is "ideas".

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: 3 Feb 1998 02:20:24 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: solution for multiline comments???
Message-Id: <6b5ut8$a2o$1@news.ml.com>

Dave Barnett  <barnett@houston.Geco-Prakla.slb.com> wrote:
>It's not terribly elegant, but how about a here document:
>#!/usr/local/bin/perl -w
>#
>$junk = "";	# to keep perl from complaining about typos
>$junk = <<EOF;
>	These are just some random comments.
>	They span multiple lines, and don't 
>	end until I put EOF on a line by
>	itself.
>EOF
>print "Hello\n";

I think the problems with here document:
1. All the lines get processed and hence wasting CPU time
2. There might be errors like in the here document, like $something
   not defined. 

if ( 0 ) {
put
comments
here
}
is a better solution. 



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

Date: Tue, 03 Feb 1998 03:40:32 GMT
From: cwinters@clark.net (Chris Winters)
Subject: Re: Where's a DBD-mSQL Module?
Message-Id: <34d79109.3725842@news.clark.net>

<also e-mailed to rsr@shell3.ba.best.com>

Since mSQL and MySQL have similar interfaces and audiences (and
more, I'm sure, but also less), the four modules (DBD::mSQL,
DBD::MySQL, Msql and Mysql) are packaged as one in:

Msql-Mysql-modules

I think the latest version is 1.1823.

look also in CPAN/modules/by-module/Msql

Good luck!

Chris

rsr@shell3.ba.best.com (Roy S. Rapoport) wrote:

>I must be missing something.
>
>I'm trying to use Perl to play with an mSQL database; I retrieved the
>DBI module, and went to the DBD module description where it explicitly
>mentioned a DBD:Msql module.
>
>But at least on ftp.cs.colorado.edu, there is no DBD-mSQL -- it goes
>from DBD-Ingres to DBD-NET.
>
>Is there a DBD:MSQL module? Where can I find it?
>
>-roy



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

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

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