[11389] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4989 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 16:17:29 1999

Date: Fri, 26 Feb 99 13:06:16 -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           Fri, 26 Feb 1999     Volume: 8 Number: 4989

Today's topics:
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        newbie - replace a line in a file? <rahulk@iname.com>
    Re: newbie - replace a line in a file? (Steve Linberg)
        Newbie needs help with Sockets <darreld@his.com>
        Newbie Q about regular expr <brandeda@se.bel.alcatel.be>
        Newbie Q about writing files <fossati@idea.it>
    Re: Newbie Q about writing files <mnag@exeter.nospam.please>
        newbie question: input from pipe <zlhu@iastate.edu>
    Re: newbie question: input from pipe (Larry Rosler)
    Re: newbie question: input from pipe (Ronald J Kimball)
    Re: newbie question: input from pipe (Ronald J Kimball)
    Re: newbie question: input from pipe (Larry Rosler)
    Re: newbie question: input from pipe (Tad McClellan)
        Newbie: find & replace over all files in folder (Owen Watson)
        newby needs help ... <ingo.fischer@apollon.de>
    Re: newby needs help ... <staffan@ngb.se>
    Re: newby needs help ... <kenhirsch@myself.com>
    Re: newby needs help ... <ingo.fischer@apollon.de>
        NT System Call Fix derek@seeray.com
        OK to post CGI.pm ?s here? <gwynne@utkux.utk.edu>
    Re: OK to post CGI.pm ?s here? (Steve Linberg)
    Re: OK to post CGI.pm ?s here? <gellyfish@btinternet.com>
    Re: OK to post CGI.pm ?s here? (I R A Aggie)
        OO Perl Opportunity crussell@analysts.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 22 Feb 1999 15:23:36 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <7arspo$t7m$2@info.uah.edu>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 15 Feb 1999 16:51:48 GMT and ending at
23 Feb 1999 03:24:39 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 1998 Greg Bacon.  All Rights Reserved.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  174 (49.4% of all posters)
Articles: 243 (27.0% of all articles)
Volume generated: 435.0 kb (25.7% of total volume)
    - headers:    173.2 kb (3,573 lines)
    - bodies:     258.2 kb (8,185 lines)
    - original:   193.9 kb (6,479 lines)
    - signatures: 3.4 kb (89 lines)

Original Content Rating: 0.751

Averages
========

Posts per poster: 1.4
    median: 1.0 post
    mode:   1 post - 128 posters
    s:      1.0 post
Message size: 1833.0 bytes
    - header:     729.9 bytes (14.7 lines)
    - body:       1088.0 bytes (33.7 lines)
    - original:   817.1 bytes (26.7 lines)
    - signature:  14.2 bytes (0.4 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

    9    22.4 (  7.7/ 14.7/  9.7)  Shane Nay <snay@no-junkformeprimenet.com>
    5     9.2 (  4.1/  5.1/  2.8)  joec@impacttech.com
    4    12.8 (  3.1/  9.7/  5.1)  "Kevin Howe" <khowe@performance-net.com>
    4     6.1 (  2.9/  3.2/  1.3)  t_alter@hotmail.com
    4     7.7 (  2.8/  4.9/  2.9)  darcys@.nbnet.nb.ca (Rod MacBain)
    4     6.0 (  3.1/  2.9/  1.7)  asssi@my-dejanews.com
    3     4.1 (  2.1/  1.7/  0.7)  Christopher Creutzig <ccr@mupad.de>
    3     3.5 (  1.7/  1.8/  1.4)  "Christopher Pieper" <curweb@cur.org>
    3     5.3 (  2.3/  3.0/  2.3)  abbott in Northfield <jabbott@dingo.smig.net>
    3     6.5 (  2.4/  4.1/  2.7)  "John Chronakis" <vamp71@freemail.gr>

These posters accounted for 4.7% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  22.4 (  7.7/ 14.7/  9.7)      9  Shane Nay <snay@no-junkformeprimenet.com>
  13.8 (  0.8/ 13.0/ 12.9)      1  Giancarlo Pinerolo <ping@alt.it>
  12.8 (  3.1/  9.7/  5.1)      4  "Kevin Howe" <khowe@performance-net.com>
   9.2 (  4.1/  5.1/  2.8)      5  joec@impacttech.com
   8.5 (  1.6/  6.9/  2.3)      2  Richard.Mayston@mfat.govt.nz
   7.7 (  2.8/  4.9/  2.9)      4  darcys@.nbnet.nb.ca (Rod MacBain)
   7.2 (  1.2/  6.0/  5.8)      2  "Anonymous" <dstern@aschwebhosting.com*nospam*>
   7.2 (  0.7/  6.5/  5.5)      1  "Paul Russell" <pauljrussell@hotmail.com>
   7.1 (  0.6/  6.5/  5.5)      1  "Paul Russell" <Look@sig.please>
   6.5 (  2.4/  4.1/  2.7)      3  "John Chronakis" <vamp71@freemail.gr>

These posters accounted for 6.0% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.839  (  0.5 /  0.6)      3  "Adam Rudnick" <arudnick@inet.net>
0.783  (  2.3 /  3.0)      3  abbott in Northfield <jabbott@dingo.smig.net>
0.781  (  1.4 /  1.8)      3  "Christopher Pieper" <curweb@cur.org>
0.662  (  2.7 /  4.1)      3  "John Chronakis" <vamp71@freemail.gr>
0.661  (  9.7 / 14.7)      9  Shane Nay <snay@no-junkformeprimenet.com>
0.589  (  2.9 /  4.9)      4  darcys@.nbnet.nb.ca (Rod MacBain)
0.570  (  1.7 /  2.9)      4  asssi@my-dejanews.com
0.547  (  2.8 /  5.1)      5  joec@impacttech.com
0.524  (  5.1 /  9.7)      4  "Kevin Howe" <khowe@performance-net.com>
0.397  (  1.3 /  3.2)      4  t_alter@hotmail.com

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.783  (  2.3 /  3.0)      3  abbott in Northfield <jabbott@dingo.smig.net>
0.781  (  1.4 /  1.8)      3  "Christopher Pieper" <curweb@cur.org>
0.662  (  2.7 /  4.1)      3  "John Chronakis" <vamp71@freemail.gr>
0.661  (  9.7 / 14.7)      9  Shane Nay <snay@no-junkformeprimenet.com>
0.589  (  2.9 /  4.9)      4  darcys@.nbnet.nb.ca (Rod MacBain)
0.570  (  1.7 /  2.9)      4  asssi@my-dejanews.com
0.547  (  2.8 /  5.1)      5  joec@impacttech.com
0.524  (  5.1 /  9.7)      4  "Kevin Howe" <khowe@performance-net.com>
0.397  (  1.3 /  3.2)      4  t_alter@hotmail.com
0.391  (  0.7 /  1.7)      3  Christopher Creutzig <ccr@mupad.de>

11 posters (6%) had at least three posts.


Top 10 Crossposters
===================

Articles  Address
--------  -------

       6  Bosco Tsang <bosco@ipoline.com>
       3  newapps@my-dejanews.com
       3  backwardsentropy@my-dejanews.com
       2  Harald Boegeholz <hwb@heise.de>
       2  Hajo Pflueger <Hajo@hadiko.de>
       2  Charles_Long@Dell.com
       2  Yan Ge <yage@waksman.rutgers.edu>
       2  "Shao-Ju Chao (Bruce)" <schao1@nycap.rr.com>
       2  nectarsys@home.com (Carl Spalletta)
       1  Jamie Kucab <jkucab@acm.org>


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

Date: Wed, 24 Feb 1999 04:56:00 -0600
From: Rahul K <rahulk@iname.com>
Subject: newbie - replace a line in a file?
Message-Id: <36D3DAC0.BCE0010A@iname.com>

Hi,

I am trying to figure out what I am doing wrong. I am trying to open a
file and replace a string with another string.

--------snip---------
open (IN, "+<$dir/$file");
                while (<IN>) {
                                s/$fields[$kount]/$fields[$kount+1]/eg;
                                print "replacing $fields[$kount]  with
$fields[$kount+ 1]\n";
                        }
                        }
                }
                close (IN);
--------snip---------

Thanks in advance,

-rahul



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

Date: Wed, 24 Feb 1999 10:23:55 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: newbie - replace a line in a file?
Message-Id: <linberg-2402991023550001@ltl1.literacy.upenn.edu>

In article <36D3DAC0.BCE0010A@iname.com>, Rahul K <rahulk@iname.com> wrote:

> I am trying to figure out what I am doing wrong. I am trying to open a
> file and replace a string with another string.

PerlFAQ 5.2, "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"

Look in Perlfaq5, included with your distribution.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Wed, 24 Feb 1999 14:40:03 -0500
From: Darrel Davis <darreld@his.com>
Subject: Newbie needs help with Sockets
Message-Id: <919885481.721063027@news.his.com>

I'm trying to work through some sample code to understand
how I can use perl in my server code.  I basically want to 
create a client that will connect to a server and take part
in a conversation with the server.  The communications
protocol we're using has no '\n' at the end of the line.  I
know from the first 10 bytes how many bytes to get.

Anyway,  In the following sample, I'm trying to do a 'recv'
after I send a string to the server.  The server does send
an akcnowlegement, but I get garbage in the sample code.

Any help appreciated.

#!/usr/bin/perl -w
# client2way.pl - a client that writes to
# and reads from a server
use strict;
use IO::Socket;
my $host = shift || 'darreld.his.com';
my $port = shift || 4271;
my $sock = new IO::Socket::INET(
                  PeerAddr => $host,
                  PeerPort => $port,
                  Proto    => 'tcp');
$sock or die "no socket :$!";
# send message to server
print $sock "0000000058LOGIN     02000000001901darreld000000001701hippy";
# print server response to STDOUT
my $bufr = '';
my $mRec;
$mRec = recv($sock, $bufr, 100, 0);
print "Got a response from server: mRec = $mRec\n";
print "$bufr\n";

I just want a string of bytes to land in $bufr.  I'm using recv 
because there is no CR or LF to terminate a string.  

Please no flames.  I really want to know.

-darrel


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

Date: Mon, 22 Feb 1999 15:55:36 +0100
From: David Van den Brande <brandeda@se.bel.alcatel.be>
Subject: Newbie Q about regular expr
Message-Id: <36D16FE8.5C87F516@se.bel.alcatel.be>

Hi,

How must I define my Pattern to get the numbers (215 61584 A1AA DT,
222-61222-A1AA-QQ) out of this page

<TR VALIGN=BOTTOM>
<TD ALIGN=RIGHT>1</TD>
<TD ALIGN=LEFT>TRS - Service Applicability</TD>
<TD ALIGN=CENTER>KDTX</TD>
<TD ALIGN=CENTER><b><a href="http://XXX/view.cgi?215-61584-A1AA-DT">215
61584 A1AA DT</a></b></TD>
</TR>
<TR VALIGN=BOTTOM>
<TD ALIGN=RIGHT>1</TD>
<TD ALIGN=LEFT>TRS - Service Applicability</TD>
<TD ALIGN=CENTER>KDTX</TD>
<TD ALIGN=CENTER><b><a href="http://XXX/view.cgi?222-61222-A1AA-QQ">222
61222 A1AA QQ</a></b></TD>
</TR>
______________________________________________

my $data = get($url);		# I read the HTML source via LWP::Simple;
				# the url is given through a web form
@splitted = split (/\n/,$data);
for each $split (@splitted)
{
	if (grep /?????????????????????????/,$split) {
$number=???????????????????????????? }
}

-- 
          V              David Van den Brande, Trainee at
  -----------------      Alcatel Switching VE27
 |  A L C A T E L  |     Fr. Wellesplein 1 - 2018 Antwerp - Belgium
  -----------------      mailto:brandeda@se.bel.alcatel.be


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

Date: Mon, 22 Feb 1999 15:16:53 +0100
From: "Alberto Fossati" <fossati@idea.it>
Subject: Newbie Q about writing files
Message-Id: <7arncu$5hf@news.global-one.it>

Perl on a Unix system.

I've to read a text file, read in the first string (it's a one time
password), and then delete it from the file as it becomes no longer usable.

The only way I can do that is:
Read all the file storing it somewhere.
Write everything back without the used string.

The problem is that the file is very big and I'm wordering how I can just
read the string and delete it without loading everything.

TNX for an example.


--
Alberto Fossati
[fossati@idea.RIMUOVI.it]




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

Date: Mon, 22 Feb 1999 09:52:25 -0500
From: "Manish Nag" <mnag@exeter.nospam.please>
Subject: Re: Newbie Q about writing files
Message-Id: <p7eA2.919$HF4.2389992@brnws01.ne.mediaone.net>

You may want to look into the perl calls sysread, syswrite, and sysseek to
do byte level reading and writing if you know the precise location of the
text you wish to replace.  You'll have to understand the UNIX methods for
performing "read" and "write" and "seek" for io operations.  Refer to the
perlfunc docs for more info.

_________________________
Manish Nag
Furnace Blast Technologies, Inc.
1800 Massachusetts Ave #31
Cambridge, MA 02140
(617) 868-9080
mnag@geocities.com


>The problem is that the file is very big and I'm wordering how I can just
>read the string and delete it without loading everything.





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

Date: Thu, 25 Feb 1999 11:09:14 -0600
From: Zhiliang Hu <zlhu@iastate.edu>
Subject: newbie question: input from pipe
Message-Id: <36D583B9.14992B4B@iastate.edu>

This is a newbie question but I didn't find proper answer from the perl
books I have and from browsing through the old posts on this group -- so
here it is:

I am writing a perl program to process certain mail messages.  This perl
script is invoked by mails and takes the input from the mail, do some
processing and save the outcome to a file.  I wonder how to make the
perl "read" properly from the mail "piped" to it?  (I guess this is the
same as "cat filename | perl.pl").  I tried (simplified example):

#! /usr/bin/perl -w
$savefile="/home/hu/tmp/output.file";
open(FILE, ">>$savefile") || die "cannot open $savefile";
   foreach ($buffer=<STDIN>) {
   s/\t\t/\t-\t/g;
   s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
   print FILE "$buffer";
   }
close(FILE);
exit 0;

NOTE: I don't understand why "foreach" printed only first line while it
works for a whole file when used as:

#! /usr/bin/perl -w
$infile = "input.file";
$outfile = "output.file";
open(IN, "$infile"); open(OUT, ">$outfile");
   foreach (<IN>) {
   s/\t\t/\t-\t/g;
   s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
   print FILE "$buffer";
   }
close(IN); close(OUT);

Thanks in advance!

Zhiliang



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

Date: Thu, 25 Feb 1999 10:27:50 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie question: input from pipe
Message-Id: <MPG.113f35fd732ac5cd989689@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36D583B9.14992B4B@iastate.edu> on Thu, 25 Feb 1999 11:09:14 
-0600, Zhiliang Hu <zlhu@iastate.edu> says...
 ...
>    foreach ($buffer=<STDIN>) {
>    s/\t\t/\t-\t/g;
>    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;

The above two substitutions operate on $_, but you have not assigned 
anything to $_.  Are you sure you didn't get a warning (from your '-w') 
about using an uninitialized variable?

>    print FILE "$buffer";

The quotes aroung $buffer are misleading, and should be avoided.

>    }
 ... 
> NOTE: I don't understand why "foreach" printed only first line while it
> works for a whole file when used as:

I also don't understand.  There are enough inconsistencies in your two 
programs to make me wonder whether you have cut-and-pasted the exact 
code rather than trying to type it in correctly.

 ...
> open(IN, "$infile"); open(OUT, ">$outfile");
>    foreach (<IN>) {
>    s/\t\t/\t-\t/g;
>    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
>    print FILE "$buffer";
>    }

Now you are assigning lines to $_ and modifying them, but you are 
printing $buffer, which is uninitialized.  Again, you should get a 
warning.  Also, you are writing to the filehandle FILE, which is not 
opened.

Please resubmit with the exact code that was executed in your two 
programs.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 25 Feb 1999 15:05:14 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: newbie question: input from pipe
Message-Id: <1dnsek9.5p6c5fu25ctyN@bay3-164.quincy.ziplink.net>

Zhiliang Hu <zlhu@iastate.edu> wrote:

> #! /usr/bin/perl -w
> $savefile="/home/hu/tmp/output.file";
> open(FILE, ">>$savefile") || die "cannot open $savefile";
>    foreach ($buffer=<STDIN>) {
>    s/\t\t/\t-\t/g;
>    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
>    print FILE "$buffer";
>    }
> close(FILE);
> exit 0;
> 
> NOTE: I don't understand why "foreach" printed only first line while it
> works for a whole file when used as:
> 
> #! /usr/bin/perl -w
> $infile = "input.file";
> $outfile = "output.file";
> open(IN, "$infile"); open(OUT, ">$outfile");
>    foreach (<IN>) {
>    s/\t\t/\t-\t/g;
>    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
>    print FILE "$buffer";
>    }
> close(IN); close(OUT);

foreach ($buffer=<STDIN>) {
         ^^^^^^^^^^^^^^^

Scalar context.  <STDIN> reads in one line, and assigns it to the scalar
variable $buffer.  foreach() then iterates over the one-element list
($buffer).


foreach (<IN>) {
         ^^^^

List context.  <IN> reads in the entire file by lines, and stores the
lines in an anonymous list.  foreach() then iterates over this
multi-element anonymous list.


What you really want there is:

while (defined($buffer=<IN>)) {
               ^^^^^^^^^^^^^^^

Scalar context.  <IN> reads in one line, and assigns it to the scalar
variable $buffer. while() makes this happen over and over again until
there are no more lines in the file.


-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

Date: Thu, 25 Feb 1999 15:05:15 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: newbie question: input from pipe
Message-Id: <1dnser9.4qguqb106kblsN@bay3-164.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> In article <36D583B9.14992B4B@iastate.edu> on Thu, 25 Feb 1999 11:09:14
> -0600, Zhiliang Hu <zlhu@iastate.edu> says...
> ...
> >    foreach ($buffer=<STDIN>) {
> >    s/\t\t/\t-\t/g;
> >    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
> 
> The above two substitutions operate on $_, but you have not assigned 
> anything to $_.  Are you sure you didn't get a warning (from your '-w')
> about using an uninitialized variable?

Actually, the foreach aliases $_ to $buffer, so $_ is not unitialized.
The confusion comes from using foreach() where while() is expected.  :-)

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -e'for(sort keys%main::){print if $$_ eq 1}
        ' -s  -- -' Just' -' another ' -'Perl ' -'hacker 
' http://www.ziplink.net/~rjk/  [rjk@linguist.dartmouth.edu]


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

Date: Thu, 25 Feb 1999 13:27:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie question: input from pipe
Message-Id: <MPG.113f602babe53f4998968d@nntp.hpl.hp.com>

In article <1dnser9.4qguqb106kblsN@bay3-164.quincy.ziplink.net> on Thu, 
25 Feb 1999 15:05:15 -0500, Ronald J Kimball 
<rjk@linguist.dartmouth.edu> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > In article <36D583B9.14992B4B@iastate.edu> on Thu, 25 Feb 1999 11:09:14
> > -0600, Zhiliang Hu <zlhu@iastate.edu> says...
> > ...
> > >    foreach ($buffer=<STDIN>) {
> > >    s/\t\t/\t-\t/g;
> > >    s/author1- /\n\%\%\n<B>Authors:<\/B> /g;
> > 
> > The above two substitutions operate on $_, but you have not assigned 
> > anything to $_.  Are you sure you didn't get a warning (from your '-w')
> > about using an uninitialized variable?
> 
> Actually, the foreach aliases $_ to $buffer, so $_ is not unitialized.
> The confusion comes from using foreach() where while() is expected.  :-)

It sure did, and your other response is much clearer.  Time for new eye-
glasses!

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 25 Feb 1999 15:31:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie question: input from pipe
Message-Id: <lvb4b7.hu2.ln@magna.metronet.com>

Zhiliang Hu (zlhu@iastate.edu) wrote:
: This is a newbie question but I didn't find proper answer from the perl
: books I have and from browsing through the old posts on this group -- so
: here it is:


   Books are down a bit on the list of resources to check when
   Perl things aren't going as expected.

   Searching the newsgroup is high on the list, but only in 2nd place.

   The number one place is the standard docs that came with your perl.

   Always start there. They are unquestionably the best Perl 
   resource that there is.


: I am writing a perl program to process certain mail messages.  This perl
: script is invoked by mails and takes the input from the mail, do some
: processing and save the outcome to a file.  I wonder how to make the
: perl "read" properly from the mail "piped" to it?  (I guess this is the
: same as "cat filename | perl.pl").  I tried (simplified example):

: #! /usr/bin/perl -w

   Warnings enabled. Kudos!

   But you are not supposed to just ignore the warning messages 
   that are issued as a result of enabling them!

   :-)



: $savefile="/home/hu/tmp/output.file";
: open(FILE, ">>$savefile") || die "cannot open $savefile";
:    foreach ($buffer=<STDIN>) {


   It looks like the only thing of substance that you changed
   between your two versions is the foreach() part...

   ... better go look up foreach() in the standard docs then...

   Yikes! There's a huge gaping clue in the very first sentence
   (my emphasis added):

---------------------
=head2 Foreach Loops

The C<foreach> loop iterates over a normal list value and sets the
                                  ^^^^^^^^^^^^^^^^^^^
variable VAR to be each element of the list in turn.
---------------------


   So, perl expects a list where you have '$buffer=<STDIN>'.
   
   In true DWIM fashion, perl then "promotes" the single scalar
   that you gave it into a one-element list, then iterates
   over that (really short) list.

   By assigning to a scalar, you have forced a scalar context.



   Perl gave you what you asked for.

   Try asking for something else  :-)


      while ($buffer=<STDIN>) {

   or

      foreach $buffer (<STDIN>) {

   
:    s/\t\t/\t-\t/g;
     ^^^^^^^^^^^^^^

   Isn't -w complaining about using an uninitialized variable ($_) there?

   Did you mean to do the substitution on $buffer instead?



: NOTE: I don't understand why "foreach" printed only first line while it
: works for a whole file when used as:


   Hopefully you understand why now...


:    foreach (<IN>) {


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 26 Feb 1999 21:15:30 +1300
From: owen@nospam.paradise.net.nz (Owen Watson)
Subject: Newbie: find & replace over all files in folder
Message-Id: <owen-2602992115310001@d218.kelly.paradise.net.nz>

I'm using a Mac, and have about 16000 text files to clean up. I was using
Nisus (an excellent WP with grep) but it was a bit slow and someone
suggested I try MacPerl instead. I want to replace
"/news
with
"/hdrs/news
which I think would be the same in grep.

All the files are contained in one folder (with other folders below it,
with the files 3 deep in the hierarchy.

Ta!


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

Date: Tue, 23 Feb 1999 15:16:20 +0100
From: Ingo Fischer <ingo.fischer@apollon.de>
Subject: newby needs help ...
Message-Id: <36D2B834.6F45DB18@apollon.de>

Hi !!

I have a small problem where I don't know what to do !

I'm new to perl ... but I will learn it now !

I have an textfile with some lines of text-value. Now I have an
FORM-field (ok I have this value alraedy in perl), but now I have to
read the text from the textfile line by line and compare this with the
FORM-Filed-Value.

If the FORM-Field is not equal to one of the texts from the textfile
then an error-message have to be shown ...

Can anyone help me please with the 'is equal'-part of the code ...

many Thanx !!

Greetings,

Ingo Fischer

-- 
_____________________________________________________________________
      NOF-Components    : http://www.apollon.de/Components/
      Component-Support : http://www.apollon.de/support/
      Privat-Pages      : http://www.apollon.de/Privat/ 
      Developer-Pages   : http://www.apollon.de/Developer/
___  ____  __  __  ___ ______________________________________________
    / /  |/  \/  \/ _/  Homepage   : http://www.apollon.de
  _/ / ^ | ^ / ^ / _/   E-Mail     : ingo.fischer@apollon.de 
_/__/_/|_|/\_\/\_\__/________________________________________________
                         | ICQ-# : 3183043 |
                         |_________________|


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

Date: Tue, 23 Feb 1999 17:31:42 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: newby needs help ...
Message-Id: <36D2D7EE.D1026626@ngb.se>

Ingo Fischer wrote:
> I have a small problem where I don't know what to do !

Can you please post at least a little bit of code? 

> Can anyone help me please with the 'is equal'-part of the code ...

if($thisstring eq $thatstring) {
	# OK
}
else {
	# not OK
}

Staffan


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

Date: Tue, 23 Feb 1999 12:05:49 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: newby needs help ...
Message-Id: <7aun44$6cu$1@fir.prod.itd.earthlink.net>

Please use a more descriptive subject line.

Ingo Fischer wrote in message <36D2B834.6F45DB18@apollon.de>...
>I have an textfile with some lines of text-value. Now I have an
>FORM-field (ok I have this value alraedy in perl), but now I have to
>read the text from the textfile line by line and compare this with the
>FORM-Filed-Value.


If they have to match EXACTLY, you can use something like this:
open(FILE, "<list.txt") or die "Error opening list.tx: $!\n";
@searchlist = <FILE>;
close(FILE);

%okvalues = map { chomp; ($_, 1) } @searchlist;

# Do the above just once--obvious, I hope
# then your if statement is just:

if (not defined($okvalues{$fieldvalue})) {
  # give an error
}


--------------
You may want to clean up the field value a little before the test, e. g.

One or more of these might be appropriate (or not):
$fieldvalue =~ s/\s//g;  # to get rid of any spaces
$fieldvalue = lc $fieldvalue;  # map to lower case


Ken Hirsch
Carrboro, NC








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

Date: Wed, 24 Feb 1999 08:56:42 +0100
From: Ingo Fischer <ingo.fischer@apollon.de>
Subject: Re: newby needs help ...
Message-Id: <36D3B0BA.3A643723@apollon.de>

thanx to both of you !!!

Ingo

Ingo Fischer wrote:
> 
> Hi !!
> 
> I have a small problem where I don't know what to do !
> 
> I'm new to perl ... but I will learn it now !
> 
> I have an textfile with some lines of text-value. Now I have an
> FORM-field (ok I have this value alraedy in perl), but now I have to
> read the text from the textfile line by line and compare this with the
> FORM-Filed-Value.
> 
> If the FORM-Field is not equal to one of the texts from the textfile
> then an error-message have to be shown ...
> 
> Can anyone help me please with the 'is equal'-part of the code ...
> 
> many Thanx !!
> 
> Greetings,
> 
> Ingo Fischer
> 
> --
> _____________________________________________________________________
>       NOF-Components    : http://www.apollon.de/Components/
>       Component-Support : http://www.apollon.de/support/
>       Privat-Pages      : http://www.apollon.de/Privat/
>       Developer-Pages   : http://www.apollon.de/Developer/
> ___  ____  __  __  ___ ______________________________________________
>     / /  |/  \/  \/ _/  Homepage   : http://www.apollon.de
>   _/ / ^ | ^ / ^ / _/   E-Mail     : ingo.fischer@apollon.de
> _/__/_/|_|/\_\/\_\__/________________________________________________
>                          | ICQ-# : 3183043 |
>                          |_________________|

-- 
_____________________________________________________________________
      NOF-Components    : http://www.apollon.de/Components/
      Component-Support : http://www.apollon.de/support/
      Privat-Pages      : http://www.apollon.de/Privat/ 
      Developer-Pages   : http://www.apollon.de/Developer/
___  ____  __  __  ___ ______________________________________________
    / /  |/  \/  \/ _/  Homepage   : http://www.apollon.de
  _/ / ^ | ^ / ^ / _/   E-Mail     : ingo.fischer@apollon.de 
_/__/_/|_|/\_\/\_\__/________________________________________________
                         | ICQ-# : 3183043 |
                         |_________________|


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

Date: Sun, 21 Feb 1999 23:18:17 GMT
From: derek@seeray.com
Subject: NT System Call Fix
Message-Id: <7aq47j$mpb$1@nnrp1.dejanews.com>

I would like to post a solution for System calls from Perl scripts on NT.

I searched and found so many people having difficulty with this issue.

I would like to thank Yoram Last for his solution and mention his URL...
http://www.geocities.com/SiliconValley/Horizon/7772/webrsh.html

The problem is..... When performing a system call from Perl on NT with IIS
and trying to spawn that call as a new process while returning control back
to the perl script while the spawned call is running in the background.  The
standard SYSTEM("START COMMAND.EXE"); works great from the localhost but when
you move this over to a web interface the STDIN/OUT/ERR starts playing a
major roll and since NT is an ill manored beast....well enough about NT but
here is the fix.....

Yoram Last's words:

The general principles here are:
a) It is indeed an issue.
b) The precise behavior depends on the server software (namely, a script
doing what you need might work well on one server, but fail with
another). The Perl interpreter you are using might also make a
difference.
c) Make sure your script gets executed as a CGI script. Not ISAPI or
something similar.
d) The main technical issue that enters is that various file handles
  (STDIN,STDOUT,STDERR) need to be closed, so neither the server nor
  your command will wait forever for something to appear from one
  of these handles.
e) Your best chance to do something that would work in most cases
  is probably to mimic the way WebRSH is doing it. Namely, try

THIS IS THE PROPER WAY TO CALL A PROCESS FROM A PERL SCRIPT ACROSS THE WEB:

close(STDERR); # Assuming you don't really need STDERR for the rest of the
script.
open(FHANDLE,"start \"Window_Title\" \"command.exe\"|");
close(FHANDLE);

Note that Window_Title will just be the window title for the spawned
command.exe program. You can put here what you want.

f) WinNT is a crazy system. Your life would be simpler if you where
using a better OS (such as Linux).

I hope this helps.

Sincerely,
Derek Rayburn
http://www.outerworlds.com
derek@seeray.com






-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 22 Feb 1999 14:51:09 -0500
From: "Robert Gwynne" <gwynne@utkux.utk.edu>
Subject: OK to post CGI.pm ?s here?
Message-Id: <7ascea$a3i$1@gaia.ns.utk.edu>

Is it appropriate to post CGI.pm questions in c.l.p.m?  I have a problem
with hidden fields that I need help with and figure that I can get  "more
better" answers here than in the cgi newsgroup, but don't want Abigail,
etc., telling me to go somewhere else.

Bob
---------------------------
Bob Gwynne
gwynne@utkux.utk.edu
Speech Comm
University of Tennessee, Knoxville

JAPN (Just Another Perl Newbie)





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

Date: Mon, 22 Feb 1999 16:41:29 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: OK to post CGI.pm ?s here?
Message-Id: <linberg-2202991641290001@ltl1.literacy.upenn.edu>

In article <7ascea$a3i$1@gaia.ns.utk.edu>, "Robert Gwynne"
<gwynne@utkux.utk.edu> wrote:

> Is it appropriate to post CGI.pm questions in c.l.p.m?  I have a problem
> with hidden fields that I need help with and figure that I can get  "more
> better" answers here than in the cgi newsgroup, but don't want Abigail,
> etc., telling me to go somewhere else.

If your question is about Perl, it is welcome here.  If it is a CGI or
HTML question, it belongs in newsgroups dedicated to those topics.  If you
have a question about how to implement hidden fields in Perl using CGI.pm
(that's explained at length in CGI.pm's documentation, btw), then it's
OK.  If it's a question about how hidden fields work, then that sounds
like a CGI/HTML question.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: 22 Feb 1999 23:31:21 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: OK to post CGI.pm ?s here?
Message-Id: <7aspc9$3uc$1@gellyfish.btinternet.com>

On Mon, 22 Feb 1999 14:51:09 -0500 Robert Gwynne wrote:
> Is it appropriate to post CGI.pm questions in c.l.p.m?  I have a problem
> with hidden fields 

But Perl doesnt have 'hidden fields' does it ...

>                     that I need help with and figure that I can get  "more
> better" answers here than in the cgi newsgroup, 

I really hope that is not the case - and if so I worry for us and the 
denizens of the CGI newsgroups.

>                                                  but don't want Abigail,
> etc., telling me to go somewhere else.
> 

If your question is only tangentially to do with Perl then we'll see what
happens - I think there are reasons for having a hierarchy of newsgroups.

/J\
-- 
Jonathan Stowe <jns@btinternet.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: 22 Feb 1999 20:56:57 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: OK to post CGI.pm ?s here?
Message-Id: <slrn7d3h9j.lv4.fl_aggie@enso.coaps.fsu.edu>

On Mon, 22 Feb 1999 14:51:09 -0500, Robert Gwynne <gwynne@utkux.utk.edu> wrote:

+ Is it appropriate to post CGI.pm questions in c.l.p.m?  I have a problem
+ with hidden fields that I need help with and figure that I can get  "more
+ better" answers here than in the cgi newsgroup, but don't want Abigail,
+ etc., telling me to go somewhere else.

Depends...are your questions perl-related, or generic CGI-related?
I suspect you'll get more, better answers over there, since not everyone
who does CGI in perl reads this newsgroup...

James


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

Date: Tue, 23 Feb 1999 20:46:56 GMT
From: crussell@analysts.com
Subject: OO Perl Opportunity
Message-Id: <7av43u$i9$1@nnrp1.dejanews.com>

Analysts International Corporation's Raleigh, NC branch has an immediate
opening for an OO Perl Developer.  This project includes many layers of
design and development, and will involve 'derisking' large and complex
systems written in C and C++.  Will be all new development primarily using OO
Perl, with some Java and C++.

If you are interested in hearing more about this opportunity, or to apply for
this position, please contact:

Carolyn Russell
Analysts International Corporation
crussell@analysts.com
919/460-4384

Company Info: Analysts International is a National Leader in Information
Systems Consulting Services.  We are a publicly-held corporation with more
than 5,000 employees and annualized revenues of over $250 million.  Forbes
Magazine recently rated AiC as one of the "Worlds Best Small Companies", and
Financial World included Analysts International in its list of the "100
Hottest Small Companies" (October, 1996).  The statistic we are most proud
of, however, is that while we continue to grow, more than 85% of our total
revenues in fiscal year 1997 were from existing clients.  We provide our
employees with comprehensive benefits that include 401(k), stock purchase,
major medical and dental insurance, tuition reimbursement, vacation/sick
leave, hardware/software reimbursement, and paid overtime.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

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

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