[11654] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5254 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 29 22:07:20 1999

Date: Mon, 29 Mar 99 19:00:17 -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, 29 Mar 1999     Volume: 8 Number: 5254

Today's topics:
    Re: 8.3 problem / win32 perl pl2bat <srnels@facstaff.wm.edu>
        Getting parent process's environment variable to change <timothy.trinh@attws.com>
        Graphics in Perl link@ipass.net
    Re: Graphics in Perl <tripix@tdi-net.freeserve.co.uk>
    Re: How to create NT service in Perl? <cassell@mail.cor.epa.gov>
    Re: How to create NT service in Perl? <doug@mcbride.net>
        Including Perlscripts in SHTML (Server Side Includes) <larsplessmann@gmx.de>
        Intricacies of using strict? (Chris Tremblay)
    Re: Intricacies of using strict? <ebohlman@netcom.com>
    Re: module export not working (Ronald J Kimball)
        multiple perl_parse() and packages neil_cook@my-dejanews.com
    Re: Newbie: How to debug Perl CGI script on server nawkboy@yahoo.com
    Re: pro's & con's of *.db databases? (Bill Moseley)
    Re: Problem... <ebohlman@netcom.com>
    Re: Problem... <rick.delaney@home.com>
    Re: qe:operation on binary files <rick.delaney@home.com>
        search and replace <matthew_western@hotmail.com>
    Re: search and replace <ebohlman@netcom.com>
    Re: search and replace <matthew_western@hotmail.com>
    Re: Sendmail won't close <emschwar@rmi.net>
    Re: Sendmail won't close (Bill Moseley)
    Re: Why do we like Perl? <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 30 Mar 1999 02:29:25 GMT
From: "scott nelson" <srnels@facstaff.wm.edu>
Subject: Re: 8.3 problem / win32 perl pl2bat
Message-Id: <9GWL2.6421$6W3.10603261@firenze.visi.net>

Try using .cmd as the extension, rather than .bat. The 16-bit dos command
shell that interprets .bat files is command.com. the 32-bit command shell
that reads .cmd files is cmd.exe.


Scott Nelson
College of William and Mary

<rupert@no.spam.leeds.ac.uk> wrote in message news:36F2D8E9.3B0F@no.spam...
> > the problem is that the path info on the file that perl 'recieves' is
> > 8.3 (in other words /interf~1/blahbl~1/...).  My local machine as well
> > as the target machine both run the newest versions of dos and don't
> > normally constrain me to 8.3 directory names.  Is it the fact that
> > i'm running it as a batch file?  why is this happening?  anyone know
> > a work-around???
>
> Please don't take this as an endorsement for NT.
>
> That various operating systems differ in what they regard as
> good filenames is one of the more obvious problems when writing
> cross-platform scripts or tools.
>
> I think that you need to get access to the way that your OS
> encodes the real name into the short name that the directory
> structure understands. Maybe NT has a means to do this for
> you. There are numerous NT FAQ sheets on the web. If not, you
> will perhaps have to roll your own. Maybe the Microsoft
> documentation will help you.
>
> One alternative, which I have used successfully is to encode
> the files, the filenames, and the directory structure in a
> tar or ZIP file, whose name can be expressed in those characters
> which the OSes can handle correctly, you can then untar or unzip
> at your end and re-gain the correct names.
>
> Ben.




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

Date: Mon, 29 Mar 1999 17:23:06 -0800
From: Timothy Trinh <timothy.trinh@attws.com>
Subject: Getting parent process's environment variable to change when running a  perl script
Message-Id: <3700277A.8A20BFC3@attws.com>

I am currently running perl5 on WinNT4.0 inside of a Z-Shell.  From what
I understand, when ever you run a perl script, it is run in a child
process.  In the child process, you can access all the environment
variables and make any modification to them within the child process.
When the script is done executing any modification you have made to the
environment variable does not affect the parent process.  How can I get
the modification or creation of environment variables to stick to the
parent process?

Thanks,
Timothy



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

Date: Mon, 29 Mar 1999 23:03:40 GMT
From: link@ipass.net
Subject: Graphics in Perl
Message-Id: <7dp0s6$3b2$1@nnrp1.dejanews.com>

I believe someone asked earlier if there was a way to draw pixels in Perl. 
I'm wondering the same thing.  I know Perl would be slower than C at doing
something like that, my interest is purely experimentation.  I personally
think Perl as the language itself could be capable of so much more.  If
anyone has any ideas at all on how to initilize and handle graphics please
tell me. Thank you, David Leblond

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


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

Date: Tue, 30 Mar 1999 00:22:31 +0100
From: "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk>
Subject: Re: Graphics in Perl
Message-Id: <7dp2bm$rum$1@news7.svr.pol.co.uk>


link@ipass.net wrote in message <7dp0s6$3b2$1@nnrp1.dejanews.com>...
>I believe someone asked earlier if there was a way to draw pixels in Perl.
>I'm wondering the same thing.  I know Perl would be slower than C at doing
>something like that, my interest is purely experimentation.  I personally
>think Perl as the language itself could be capable of so much more.  If
>anyone has any ideas at all on how to initilize and handle graphics please
>tell me. Thank you, David Leblond
>
which platform are you using?
have you looked at CPAN?

There are these modules:    GD             (draws to gifs/xbm, not directly
to the screen ),
                                                  OpenGL.

GD is available on Un*x and Win32.

Fancy porting the OpenGL to Win32, as it isn't on Activestate yet, is
anybody porting it at the moment?

Do you do any (spit) DirectX , fancy writing a C extention to perl as an
exersize?!

Regards

Wayne




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

Date: Mon, 29 Mar 1999 15:41:50 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: How to create NT service in Perl?
Message-Id: <37000FBE.51E5EAB5@mail.cor.epa.gov>

Doug McBride wrote:
> I see that the Win32::Service module lets me control services, but how
> do I create a new service?  I think there's a Win32 API call to do this,
> but has it been exported to Perl already?
> 
> Thanks!

Check out the Perl for Win32 FAQ that comes with ActiveState Perl.
Your question is already answered, in more detail than you're likely to
get in a newsgroup posting.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 29 Mar 1999 17:42:54 -0800
From: Doug McBride <doug@mcbride.net>
To: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: How to create NT service in Perl?
Message-Id: <37002C1E.876CE993@mcbride.net>

"David L. Cassell" wrote:
> 
> Doug McBride wrote:
> > I see that the Win32::Service module lets me control services, but how
> > do I create a new service?  I think there's a Win32 API call to do this,
> > but has it been exported to Perl already?
> 
> Check out the Perl for Win32 FAQ that comes with ActiveState Perl.
> Your question is already answered, in more detail than you're likely to
> get in a newsgroup posting.

Maybe I'm being dense, but I don't see anything about creating services
in a Perl script in the FAQ.  So my question still stands.

-- 
Doug McBride - doug@mcbride.net - n|c - http://www.nc.com - 650.631.5268


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

Date: 29 Mar 1999 23:39:11 GMT
From: Lars Plessmann <larsplessmann@gmx.de>
Subject: Including Perlscripts in SHTML (Server Side Includes)
Message-Id: <37000FF3.68D79D03@gmx.de>

I've got a problem in including Perl Scripts into a SHTML file.
On windows 95 it works correctly, but on my Linux and on other UNIX
Systems it doesn't work :-(
That's my SHTML file (I saved it as "haupt.shtml"):
----------
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
 <title>Testpage</title>
 </head>
 <body background="/graphik/backgd.jpg">

 <table COLS=3 WIDTH="100%" >
 <tr>
 <td WIDTH="50">
 <center><img SRC="/graphik/logo.gif" height=180 width=64
align=ABSCENTER></center>
 </td>

 <p><font face="Arial,Helvetica" size=3>
 Sehr geehrter Kunde,
 <p>
 Wir freuen uns, Sie als <!--#include virtual="/cgi-bin/counter.pl"-->.
Besucher auf unserer Seite begr&uuml;&szlig;en zu d&uuml;rfen!
 Sie k&ouml;nnen von dieser Seite aus, die aktuellen Hard- und
Softwareangebote abfragen und sogar gleich online bestellen.
 <p>

 <font size=4><u>Unser Angebot der Woche</u></font>
 <table cols=2 cellpadding=15 width="100%">
 <tr>
 <td><font face="Arial,Helvetica" size=4>
 <blockquote><B>
 <!--#include virtual="/cgi-bin/angebot.pl"-->
 </B></blockquote>
 </td>
 <td width=300><center>
 <img SRC="/graphik/computer.gif">
 </td>
 </tr>
 </table>

 Einen auf Ihren Bedarf angepassten PC stellen wir Ihnen gerne in
unserem Fachgesch&auml;ft zusammen.
 Lassen Sie sich von uns beraten und betreuen. Sie werden von unseren
Leistungen positiv &uuml;berrascht sein.
 <p><font face="Arial,Helvetica" size=4><u>Preisliste f&uuml;r
Einzelteile (erfragen Sie unsere Bundlepreise)</u></font>
 <p>
 <form action="/cgi-bin/preise.pl" name="Liste" method=get>
 <select name="Produkt">
 <option>Geh&auml;use
 <option>Mainboards
 <option>Prozessoren
 <option>Speichermodule
 <option>Festplatten IDE
 <option>Festplatten SCSI
 <option>CD-ROM + Writer
 <option>Grafikkarten
 <option>Soundkarten + Boxen
 <option>Tastaturen, M&auml;use
 <option>Scanner
 <option selected>Drucker
 <option>Monitore
 <option>Internet (DF&Uuml;)
 </select>&nbsp;&nbsp;&nbsp;<input type=submit
value="Produktinformationen anzeigen...">
 </form>
 Unsere Rechner werden vollst&auml;ndig konfiguriert und Ihnen nach
einer Vorf&uuml;hrung &uuml;bergeben. Sie brauchen Ihren PC zu Hause nur
an die Stromversorgung anschlie&szlig;en und es kann losgehen.
 Selbstverst&auml;ndlich bieten wir PC-Schulungen in angenehmer
Atmosph&auml;re und mit individueller Betreuung f&uuml;r jeden einzelnen
Kursteilnehmer an. Erfragen Sie unsere Termine.<br>
 Ihre Zufriedenheit ist unser Erfolg.<p>
 <font size=1>Preisg&uuml;ltigkeit <!--#include
virtual="/cgi-bin/update.pl"-->, Irrt&uuml;mer und Preis&auml;nderungen
durch Tagespreise bei Arbeitsspeicher und Prozessoren
vorbehalten.</font>
 <p>
 <p><font face="Arial,Helvetica" size=4><u>Unsere
&Ouml;ffnungszeiten</u></font>
 <p>
 <table cols=2>
 <tr><td width=125><font face="Arial,Helvetica" size=3>Mo., Mi. und
Fr..</td><td><font face="Arial,Helvetica" size=3>9.00 - 13.00 + 15.00 -
19.00 Uhr</td></tr>
 <tr><td width=125><font face="Arial,Helvetica" size=3>Di. u.
Do.</td><td><font face="Arial,Helvetica" size=3>15.00 - 19.00
Uhr</td></tr>
 <tr><td width=125><font face="Arial,Helvetica" size=3>Sa.</td><td><font
face="Arial,Helvetica" size=3>9.00 - 13.00 Uhr</td></tr>
 </table>
 </p>
 Di. und. Do. vormittag nach Terminvereinbarung.
 </p><font size=4><center>
 <A HREF="kontakt.htm" onMouseOver="javascript:self.status='Kontakt mit
uns...'; return true" onMouseOut="javascript:self.status='';return
true">[Kontakt]</A>&nbsp;&nbsp;&nbsp;
 <A HREF="feedback.htm" onMouseOver="javascript:self.status='Weitere
Fragen? Verbesserungsvorschldge? Sonstige Informationen...'; return
true" onMouseOut="javascript:self.status='';return
true">[Feedback]</A>&nbsp;&nbsp;&nbsp;
 <A HREF="nletter.htm" onMouseOver="javascript:self.status='Lassen Sie
sich die aktuellen Angebote per Email zukommen...'; return true"
onMouseOut="javascript:self.status='';return true">[Newsletter]</A><p>

 <hr><center>
 <br><font face="Arial"><font size=1>Letzte &Auml;nderung: <!--#include
virtual="/cgi-bin/update2.pl"-->.</font></font></center>

 </body></html>
----------
Why doesn't the #include tags work? Even the #exec tag does not work.
I tried to save it as haupt.sht and haupt.shtm, but that didn't work,
too.

May anybody help me?


 - lars (larsplessmann@gmx.de)



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

Date: Tue, 30 Mar 1999 01:29:28 GMT
From: anne@NOstormSPAM.ca (Chris Tremblay)
Subject: Intricacies of using strict?
Message-Id: <37002810.7576051@news.storm.ca>

I want to start using strict in Perl but when it comes to declaring
variables to make it compile, I assume there is more than just
throwing "my" in front of it. 

What I want to know is: Is there anywhere on the web that can explain
what and why I woud need to do to make my scripts strict-compliant?
I have the faq's but it doesn't explain it thoroughly enough is there
anywhere else?
Respond here or email me at anne at storm do ca! No I don't want spam!
Also respond here cause I am sure someone else could use this info
too.
Thanks in advance!


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

Date: Tue, 30 Mar 1999 01:53:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Intricacies of using strict?
Message-Id: <ebohlmanF9Dx9n.CLC@netcom.com>

Chris Tremblay <anne@NOstormSPAM.ca> wrote:
: I want to start using strict in Perl but when it comes to declaring
: variables to make it compile, I assume there is more than just
: throwing "my" in front of it. 

: What I want to know is: Is there anywhere on the web that can explain
: what and why I woud need to do to make my scripts strict-compliant?
: I have the faq's but it doesn't explain it thoroughly enough is there
: anywhere else?

It's best to start of by remembering that 'use strict' is really a 
combination of three different pragmas (directives):

1) use strict 'refs': This says that symbolic references are not 
allowed.  IOW, if you have a string variable whose value is the name of 
another variable, you can't use the first variable to get at the value of 
the second.

Without this restriction in effect, you can do things like:

$v1='Hello ';
$v2='world!';
for ($i=1;$i<2;++$i) {
  $r="v$i";
  print $$r;
}

use strict 'refs' disallows this.  Many people think they want to use 
symbolic references, but generally what they want to do is better done 
using arrays or hashes.  Symbolic references make it easy to create 
hard-to-track down bugs, so they should only be used in special cases.

Note that symbolic or "soft" references are entirely separate from true 
or "hard" references.

2) use strict 'subs': This says that barewords cannot be used to invoke 
subroutines that haven't been declared earlier on in the file.  It helps 
catch bugs where a subroutine's name has been misspelled (without this 
pragma, you'd get a run-time error rather than a compile-time one).

3) use strict 'vars': This requires that any variable names you use must
be declared, fully-qualified or imported before they're used.  Variables
can be *declared* either as lexical variables using 'my' or as global
variables using 'use vars'.  Variables can be fully qualified by
prepending their package names followed by '::'.  Variables are imported
when you use a module that exports them.  This pragma helps catch bugs
where you inadvertently use two different names (e.g. $count and $counter)
when you mean the same variable. 

All these pragmas require to think about your code in terms of its 
overall design rather than on a purely line-by-line basis.  The extra 
discipline they impose makes it easier to write reliable code.



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

Date: Mon, 29 Mar 1999 21:40:55 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: module export not working
Message-Id: <1dpg620.flcjpeh222q8N@p39.block2.tc6.state.ma.tiac.com>

Jim and Paula <gemhound@gemhound.com> wrote:

> @EXPORT = qw( sayHello); 
> 
> $VERSION = '1.00';

You seem to be missing:

@ISA = qw(Exporter);


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 30 Mar 1999 00:30:22 GMT
From: neil_cook@my-dejanews.com
Subject: multiple perl_parse() and packages
Message-Id: <7dp5uu$7rr$1@nnrp1.dejanews.com>

I am having a problem with some embedded perl.

I call perl_parse() at many points in my program, in order to load new
scripts when needed. Each script that I load has a unique package name, to
avoid symbol table clashes. However, some package names may be "children" of
other packages, for example package Foo, and package Foo::Bar.

My problem is this:

I load (using perl_parse()) the script (actually a set of perl subroutines
according to an API specification) with the declaration package Foo::Bar. I am
able to call the subroutines in the package without any problems, e.g.
perl_call_pv("Foo::Bar::parameters",...).

However, if I do a subsequent perl_parse() of the package Foo, I cannot then
make calls into the package Foo::Bar. I get the error message "Undefined
subroutine &Foo::Bar::parameters called."

It looks like the symbol table for Foo::Bar is being overridden by the
perl_parse() for the package Foo. Is this a bug, or a feature? If the latter,
I would like to make a case for the former. Due to the way the software
works, it would be difficult to reverse the order of the calls.

Neil.

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


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

Date: Tue, 30 Mar 1999 00:26:49 GMT
From: nawkboy@yahoo.com
To: jrnoorda@worldnet.att.net
Subject: Re: Newbie: How to debug Perl CGI script on server
Message-Id: <7dp5o0$7he$1@nnrp1.dejanews.com>

In article <7bpch9$akd@bgtnsc01.worldnet.att.net>,
  "JR Noorda" <jrnoorda@worldnet.att.net> wrote:
>
>
> Perl and Linux are new to me.
>
> I would like to get the Perl CGI script to invoke a debugger on the
> server with output to a terminal on the server.
>
> The environment is 2 computers connected by ethernet cards.
> Server is Caldera Linux, Netscape FastTrack Server.
> Client machine is Windows 95.
>
> So far, no success.
>
> I have created a   .perldb   It's contents are
> $DB::TTY='/dev/tty3/'
>
> I have modified the first statement of the Perl script:
> #!/usr/local/bin/perl -dT
>
> The page sent to the browser is a form with the following HTML:
>     <FORM METHOD ="post" ACTION = "web_store.cgi">
>
> The output from the server gets sent to the client browser and looks like
> this:
>
> Loading DB routines from perl5db.pl version 1 Emacs support available. Enter
> h or `h h' for help. main::(/home/httpd/html/web_store.cgi:70): 70: $| = 1;
> DB<1> Insecure dependency in eval while running with -T switch at
> /usr/lib/perl5/perl5db.pl line 1158, chunk 1. DB::eval called at
> /usr/lib/perl5/perl5db.pl line 1067 DB::DB called at
> /home/httpd/html/web_store.cgi line 70
> DB::fake::(/usr/lib/perl5/perl5db.pl:2084): 2084: "Debugged program
> terminated. Use `q' to quit or `R' to restart."; DB<2>
>
> This looks like the output of a debugger.   How does one get it redirected
> to a terminal
> on the server??
>
> Thanks and hope to be contributing to the newsgroup in the future
> John Noorda
>

Does anyone know the answer to this question?  Has the author figured it out
yet?
>

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


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

Date: Mon, 29 Mar 1999 17:44:16 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: pro's & con's of *.db databases?
Message-Id: <MPG.1169cc507910126b9896ff@206.184.139.132>

In article <36fff23e.410246601@nntp.ix.netcom.com>, 
75474.133@compuserve.com says...
> Can anyone briefly describe the simple pros/cons of using *.db files
> for databases, especially when compared to delimited text files.
> ...
> I've yet to see a word written about them here. I would be
> particularly interested in file size limitations, risks of multiple
> simultaneous accesses (if that's even possible), etc.

Look at Programming Perl (you have that, right?) or perldoc AnyDBM_File 
for a table that compares the various DBM options.  Berkeley DB seems to 
be a popular and powerful choice.

You will want to use locking of some sort for multiple accesses.  How 
that's done depends on what you are doing.

I'd use a text files if your data is small, or you don't need random 
access, and you don't want to build a relational database.

I'd like to hear the reasons why and when to use, say, MySQL or other 
high-level data base solution over DBM if building from the ground up.



-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 30 Mar 1999 01:37:17 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Problem...
Message-Id: <ebohlmanF9DwI5.BGy@netcom.com>

Frank de Bot <debot@xs4all.nl> wrote:
: I've started to build my own searchengine.
: I have this Keyword: "Perl"
: I have this string to look for matches:  "Free Perl scripts, Get your
: Perl Scripts here" .

: Perl exist 2 times in that string. How can I make the script that it
: count the number of "Perl" (in this case). This should be 2. How can I
: do that automatic?

You might want to take a look at the Text::Query::Simple module available 
on CPAN; it will take something pretty much resembling an AltaVista 
"simple" query and match text against it, counting the matches.



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

Date: Tue, 30 Mar 1999 01:42:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Problem...
Message-Id: <37002DF6.5333EDF7@home.com>

[posted & mailed]

Frank de Bot wrote:
> 
> Perl exist 2 times in that string. How can I make the script that it
                                     ^^^^^^^^^^

> count the number of "Perl" (in this case).
  ^^^^^^^^^^^^^^^^^^^

perldoc perlfaq4

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 30 Mar 1999 02:26:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: qe:operation on binary files
Message-Id: <3700365D.BD42B57E@home.com>

[posted & mailed]

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <36FFB6AC.9A6099DE@ltt.ntua.gr> on Mon, 29 Mar 1999 20:21:48
> +0300, Costis Angelis <loulou@ltt.ntua.gr> says...
> >
> > I am not very experienced, almost not at all, but having faced a similar
> > situation recently, check reverse in a scalar context. I could be all
> > wrong of course.
> 
> You might have looked at the documentation for the reverse() function
> before posting a conjecture about it.  It very explicitly reverses the
> order of the bytes in a string, not the order of bits.

[snip quote]

> As Jonathan Feinberg responded, unpack() and pack() have the needed
> capabilities ('b' and 'B' formats).

Indeed, but I don't think that reverse was a crazy suggestion.

($x)    = unpack 'B16', $foo;
$y      = reverse $x;
$bar    = pack   'B16', $y;

This, in fact, produces the results asked for.  Well, maybe not since
the original poster wants to exclude "the trivial solution of
translating  it into ASCII".

However, the following might not do what one thinks, because of
pack/unpack's byte-aligning.

($x)    = unpack 'B16', $foo;
$bar    = pack   'b16', $x;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 30 Mar 1999 11:01:24 +0930
From: "Matthew Western" <matthew_western@hotmail.com>
Subject: search and replace
Message-Id: <3700295b@news1.us.ibm.net>

Hi,
Is there a search and replace string function?  Or do I need to muck around
with substr, index and all those other things?
Matthew




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

Date: Tue, 30 Mar 1999 02:07:03 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: search and replace
Message-Id: <ebohlmanF9Dxvr.Dvp@netcom.com>

Matthew Western <matthew_western@hotmail.com> wrote:
: Is there a search and replace string function?  Or do I need to muck around
: with substr, index and all those other things?

The former.  You must have missed it in the documentation because 1) it's 
an operator rather than a function, so it's described in perlop rather 
than perlfunc (though the latter has a "see also" for it) and 2) it's 
called 's' (for substitute) rather than "search and replace."  Using it 
properly requires a basic command of regular expressions, so you probably 
want to read perlre as well.




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

Date: Tue, 30 Mar 1999 12:16:15 +0930
From: "Matthew Western" <matthew_western@hotmail.com>
Subject: Re: search and replace
Message-Id: <37003b01@news1.us.ibm.net>

I read all that stuff and am even more confused.  I'm a VB programmer not a
c programmer.

I have "4,654,399,787" in a string.  I want to get rid of the commas so I
can make it a number and and it together.

Please help?
Matt






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

Date: 29 Mar 1999 17:44:02 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Sendmail won't close
Message-Id: <xkfu2v3dcx9.fsf@valdemar.col.hp.com>

Jesse Nover <jesse.n@home.com> writes:
> Has anyone had a problem sending mail with perl through sendmail? 

No.  Nobody anywhere has ever had any problems with sendmail.  Sendmail
is perfect.

> The script simply opens sendmail and prints to the mail stream, but it
> fails to succefully close sendmail.

Why?

> Please help.

Please post code.  What you've said so far is something akin to calling
your mechanic, and saying, "My car won't start.  Please help."  If you
don't give us any code, we can't tell you why it doesn't work.

-=Eric




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

Date: Mon, 29 Mar 1999 17:30:33 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Sendmail won't close
Message-Id: <MPG.1169c918592f4e539896fe@206.184.139.132>

In article <36FFDC6B.D23EED55@home.com>, jesse.n@home.com says...
> Has anyone had a problem sending mail with perl through sendmail? The
> script simply opens sendmail and prints to the mail stream, but it fails
> to succefully close sendmail.

As others have said, you need to post some code and the error messages 
you are receiving.

But,  I had similar problems.  I was using:

    # $params is path to sendmail and switches

    unless (open MAIL, $params ) {
        return "Failed open of sendmail:$sendmail:$!";
    }

    print MAIL $body;
    return "Failed close of sendmail:$sendmail:$!" unless (close MAIL);

And every once in a great while I was receiving:

  "Failed close of sendmail:/usr/lib/sendmail:"

without any additional message from $!.

Not much help.  I could never determine if the failed close indicated 
that the mail didn't get sent.

I now capture both sendmail's STDOUT and STDERR, as suggested by 
Zenin, to look for any errors output by sendmail.  But as luck would have 
it, I haven't seen any errors yet, including a failed close().  Oh well.

I'll post the way I'm currently sending mail -- maybe it can help in your 
case (and maybe someone will spot a bug that I missed, or mention a way 
to make better looking code....)


   
use FileHandle;
use IPC::Open3;

sub send_mail_via_sendmail {

    my ($sendmail, $body) = @_;

    # $sendmail = path to sendmail
    # $body     = really the entire email message, including headers

    #  sendmail switches:
    #    -t    : read addresses from headers
    #    -oi   : ignore ".\n"
    #    -oem  : mail error messages
    #    -odq  : just queue the message (sendmail returns faster?)
    #    -f    : set sender envelope


    my $params = "$sendmail -t -oi -oem";


    # Grab sender to set envelope in Sendmail

    foreach ( split( /\n/, $body ) ) {
        last unless $_;

        # this isn't really required.
        if ( /^from:.*?([^<|\s]*@[^>|\s]*)/i ) {  
            $params .= " -f '$1'";
            last;
        }
    }

    my $in  = new FileHandle;
    my $out = new FileHandle;
    my $err = new FileHandle;

    

    STDOUT->flush;  # flush STDOUT so child doesn't get copy

    open3( $in, $out, $err, $params )
        or return "Failed open of sendmail:$sendmail:$!";


    my $message;    # error message to return

    $in->print($body, "\n")
        or $message = "Failed print to sendmail:$sendmail:$!";

    unless ( $message ) {
        $in->close
	        or $message = "Failed close of sendmail:$sendmail:$!";
	}


    # now check for STDERR or STDOUT messages
    
    my $tmp = join( '/', <$out> );
    $message .= " STDOUT:$tmp" if $tmp;

    $tmp = join( '/', <$err>);
    $message .= " STDERR:$tmp" if $tmp;


    return $message;  # returns true with message if errors.
}

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Mon, 29 Mar 1999 15:38:52 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Why do we like Perl?
Message-Id: <37000F0C.D4048634@mail.cor.epa.gov>

Hugh_Dunne@nospam.com wrote:
> [snip of previous message]
> I'm not too familiar with personality models, but I think it definitely takes
> a certain type of personality to be good at perl and enjoy using it.

Perhaps.  But I've always felt that there were more than enough adequate
languages around, so why should I mess with one I didn't like?

>                                                                       I am not
> a newby, I have been programming for 15+ years and I have never met a more
> bizarre and frustrating language than perl. I am constantly being tripped up
> by booby traps, and finding that the simplest script fails to work because I
> didn't know I had to use some obscure piece of black magic which is nowhere
> explained in the books. It is a constant struggle to get perl to do what I want.

Sorry to hear you feel that way.  My experience is the reverse, if in part
because I'm the type who likes to read lots of docs first before trying
things out.  I've found that if I looked, the Perl docs and my Perl books
would tell me what bone-headed thing I was doing, and help me fix it.

> Something that I could whip up in a few minutes in tcl/tk, and have work right
> the first time, is a major ordeal in perl.

I'm glad you have some choices that work well for you.  I found a few
annoyances with Tcl that led me to drop it as a high-priority tool.  But
then, as the Perlites say, TIMTOWTDI.

>                                             It seems that so much of the
> language is deliberately made obscure because it appeals to a certain rather
> geeky sense of humor.

Well, I have that.  But I feel that so much of the language is *inclusive*.
Instead of having to resort to a library to do *anything* useful, I can get
a lot of stuff done quickly, in only a couple lines, using the base dis-
tribution.  And the modules are easy to pop in if I want to.

>                       Plus the attitude of many of the regulars in this group
> is very "fundagelical" - anyone who doesn't accept that perl is the one true
> language is a heretic, and you should never use anything other than perl
> regardless of the application.

I hope not.  My experience is [once again] opposite of yours.  The people
I have read have generally been more respectful of other languages than in
other language newsgroups I read or have read.  Have you read what people
in this group have said about Python?  Tcl?  I have some fairly generous
statements, as opposed to some hardcore love-my-language-or-die-in-pain
comments I have hit elsewhere.  After all, Perl is a *glue* language too.
It is designed to play nice with other children [although not the only
language designed this way, as you know].

>                                Well I'm sorry but I don't want to live next to
> a nuclear power station controlled by perl...

Me neither.  In fact, the FAQ says Perl is not for every app.  Perl does
have a nice feature set, but it's not perfect.  On the other hand, I can't
think of a language I would want to have controlling a nuclear power
station upwind of my house.
 
> Hugh Dunne, Chandler, The Arid Zone
 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

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

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