[7377] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1002 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 9 18:07:26 1997

Date: Tue, 9 Sep 97 15:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 9 Sep 1997     Volume: 8 Number: 1002

Today's topics:
     Re: </.*?> vs. </[^>]*> <usenet-tag@qz.little-neck.ny.us>
     Calling a Perl Script... <gdoucet@ait.acl.ca>
     Re: DNS lookup with gethostbyaddr? (Matthew Cravit)
     Re: Escaping Newline in a HERE-document - HowTo ? <rootbeer@teleport.com>
     Help in search script (Marcantonio Fabra)
     Re: How to get keys of array? (Raphael Manfredi)
     Re: How to rename /etc/passwd ? (Jason Gloudon)
     Re: How to rename /etc/passwd ? (Brian Wheeler)
     Re: How to rename /etc/passwd ? (Jason Gloudon)
     Re: How to rename /etc/passwd ? <doug@tc.net>
     Re: Incredibly basic Newbie question <jreid.infocus@dnet.co.uk>
     Re: local array in subroutine (Jean-Damien Durand)
     Perl DBM file <irenewu@net.com>
     Re: Print an Image <rootbeer@teleport.com>
     Re: problems building 5.004_01 on HP-UXB.09.00 (Stuart McDow)
     Re: removing shell comments from ksh scripts (Kaz Kylheku)
     Re: Sending a file with mailx using perl <Gary.P.Fontenot1@lmtas.lmco.com>
     sumcheck generator wanted <dennis.kowalski@daytonoh.ncr.com>
     Re: Testing attempts fail.. <eric@garlic.com>
     Re: What does "regexp *+ operand could be empty" mean? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: What does "regexp *+ operand could be empty" mean? (Charles DeRykus)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 9 Sep 1997 18:34:12 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: </.*?> vs. </[^>]*>
Message-Id: <eli$9709091413@qz.little-neck.ny.us>

Tad McClellan <tadmc@flash.net> wrote:
> kendall shaw (kshaw@plight.lbin.com) wrote:
> : Is there ever a difference between the regular expressions: </.*?> and
> : </[^>]*>?
> 1) </[^>]*> works fine on multiline strings.
>    </.*?> would need the m//s modifier to get the same effect.
> 2) </[^>]*> is faster  ;-)

>From what I hear 5.004 optimizes the advantage of #2 away. I haven't
checked becuase I prefer non greediness for other reasons.

There is a third difference of some note. When this is only *part*
of a longer regular expression the two can be much different.

Take for example
	one: <[^/].*?>(.*?)</.*?>
	two: <[^/>]*>([^<]*)</[^>]*>

:r! perl -e '$a="<li><code>m/RE/s</code>";
	sub one { @_[0]=~m:<[^/].*?>(.*?)</.*?>:s; return $1 }
	sub two { @_[0]=~m:<[^/>]*>([^<]*)</[^>]*>:s; return $1 }
	$b=&one($a); print "one: $b\n";
	$b=&two($a); print "two: $b\n";'
one: <code>m/RE/s
two: m/RE/s

This particular example doesn't match </[^>]*> and </.*?> differently
but another (probably less clear, IMHO) example could. This does show
what might be considered equivilant REs matching different text,
though due to the way non-greediness works.

Elijah
------
non-greedy is often not appropriate


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

Date: Tue, 09 Sep 1997 15:37:20 -0300
From: Guy Doucet <gdoucet@ait.acl.ca>
Subject: Calling a Perl Script...
Message-Id: <3415975E.3DF34B61@ait.acl.ca>

(1)  I want to know how to call a Perl script from an HTML/JavaScript
document, other than the <form method="post"... or "get"... What I'm
getting at is I'd like to know if a JavaScript can call the Perl script
directly.

(2) I am running on a Novell Web Server and I was wondering how to call
a Perl script that doesn't return anything to the web page. When I try,
I get Document contains no data.

Guy Doucet - new to Perl



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

Date: 9 Sep 1997 09:48:14 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: DNS lookup with gethostbyaddr?
Message-Id: <5v3uke$9pu$1@shell3.ba.best.com>

In article <5v2gm8$24g$1@ha1.rdc1.sdca.home.com>,
Peter Tiemann <peter@preview.org> wrote:

>($nam) = (gethostbyaddr($address, 2))[0];
>this works - although I still do not understand why the stuff below is
>wrong.
>>($nam, $alias, $addrtype, $leng, @add) = gethostbyaddr($address, AF_INET);

Probably because you didn't do 

use Socket;

at the start of your script, so AF_INET was undefined. That made your first
attempt equivalent to:

	($nam, $alias, $addrtype, $leng, @add) = gethostbyname($address, undef);

The second code snippet you posted was the same as the first one (except
for the fact that it didn't allocate variables you didn't use). The only
difference which was significant to your problem was that it hard coded
the value of AF_INET (2), so that you were actually passing the right
things to gethostbyname.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: Tue, 9 Sep 1997 11:25:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: Escaping Newline in a HERE-document - HowTo ?
Message-Id: <Pine.GSO.3.96.970909111914.27604R-100000@julie.teleport.com>

On 9 Sep 1997, Helmut Jarausch wrote:

> Subject: Escaping Newline in a HERE-document - HowTo ?

Catch it before it escapes! :-)

> using a HERE-document and within it the famous construct
> @{[....]} it's sometimes desirable to escape the newline like in
> 
> print STDERR  <<EOS;
> at @{[printf("%2.2i/%2.2i/%2.2i %2.2i:%2.2i:%2.2i",
>    @{[gmtime(time)]}[5,4,3,2,1,0])]} I couldn't get rid of the newline
>    characters above.
> EOS

What a mess! :-)  If you must do this, don't print inside the print
statement! (Use sprintf instead of printf.)

    print STDERR <<EOS;
	at @{[ sprintf "%2.2i/%2.2i/%2.2i %2.2i:%2.2i:%2.2i",
		(gmtime time)[5,4,3,2,1,0]
	]} blah blah more text...
    EOS

Have fun with it!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 09 Sep 1997 13:19:36 -0200
From: fabra@ax.apc.org (Marcantonio Fabra)
Subject: Help in search script
Message-Id: <5v3svp$s31@ax.apc.org>


Hello,

I have a script that searches words received via STDIN in files of a directory.
I separate the words I want to search by blank. 
The script is functioning well.
Someone can help me in order to change the script, giving to it the capacity of
search composed words ?
For instance, "american theatre" (using the " in order to determine a composed
word). 

I thing the part that need to be changed is the parse_form routine on my script.
Here you have it :

sub parse_form {
 
   # Obtain the words
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 
   # Split the name-value pair
   @pairs = split(/&/, $buffer);
 
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);
 
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 
      $FORM{$name} = $value;
   }
}

Thank's in advance.


Regards,

Marcantonio Fabra



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

Date: 9 Sep 1997 13:19:59 GMT
From: Raphael_Manfredi@grenoble.hp.com (Raphael Manfredi)
Subject: Re: How to get keys of array?
Message-Id: <5v3idv$dok@isoit109.bbn.hp.com>

Quoting Randal Schwartz <merlyn@stonehenge.com> from comp.lang.perl.misc:
:>>>>> "Dave" == Dave Hoyt <dshoyt@worldnet.att.net> writes:
:Dave> while (<INFILE>) {
:Dave>            ($key, $line) = /^(.*):(.*)$/;
:Dave>            $MyHash{$key}=$line;
:Dave> }
:
:Or even more perverse and wonderful:
:
:	%MyHash = map /^(.*?):(.*)/, <INFILE>;
:
:Map rules!  (Giving us map-rules as well. :-)

Hiding the loop behind the curtain, however neat it may be, might have
tremendous impact on your stack usage. ;-)

Raphael


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

Date: 9 Sep 1997 18:35:38 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: How to rename /etc/passwd ?
Message-Id: <5v44tq$9rb$1@daily.bbnplanet.com>

In article <8o5M5om00WB90VOqs0@andrew.cmu.edu>,
Robert J Migliore  <migliore+@andrew.cmu.edu> wrote:
>Excerpts from netnews.comp.lang.perl.misc: 9-Sep-97 How to rename
>/etc/passwd ? by Benarson Behajaina@swh.s 
>> I'm running Linux 2.0.27. Since there's no tool which may remove user,
>> I would like to write a short script that will do this.
>> I couldn't rename the /etc/passwd file, 'cause 'man perlfunc' says:
>> rename OLDNAME, NEWNAME
>>             Change the name of file. Will not work accross file system
>>             boundaries.
>>  
>> So my question is, how to write a Perl script that could update or
>> rename this file ?
>
>Not to avoid your question, but how do people go about copying files in
>general.. ?  I've been using shell commands and to my knowledge there is
>no copy function (at least in any of the perl books I own).
>
>
>-Rob

Try using the File-Tools module. If you are using at least Perl5.003 it
should already be installed.

Jason Gloudon


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

Date: 9 Sep 1997 18:36:56 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: How to rename /etc/passwd ?
Message-Id: <5v4508$cpg$1@dismay.ucs.indiana.edu>


In article <34156264.DCD24A8D@swh.sk>,
	Benarson Behajaina <Benarson.Behajaina@swh.sk> writes:
>I'm running Linux 2.0.27. Since there's no tool which may remove user,
>I would like to write a short script that will do this.
>I couldn't rename the /etc/passwd file, 'cause 'man perlfunc' says:
>rename OLDNAME, NEWNAME
>            Change the name of file. Will not work accross file system
>            boundaries.
>
>So my question is, how to write a Perl script that could update or
>rename this file ?

	Seems dangerous to rename it and try to put it back...what if the
machine needs that file before you've completly rebuilt it?  Or worse, if
it goes down between rename and rebuild?

	If you're still wanting to do this, keep these things in mind:

	1) the warning in rename is if you try to rename a file and the oldname
and newname are on different devices (i.e.  /dev/hda1 as / and /dev/fd0 as 
/mnt.  It will fail if you try rename("/myfile","/mnt/myfile.bak")).

	2) your program has to have permission to modify the /etc directory 
(for the rename and creation of a new file)

	3) make sure you set the permissions back to they way they should be
on /etc/passwd

	4) instead of doing 
		rename('/etc/passwd','/etc/passwd.bak');
		# do your thing -> /etc/passwd
	 do
		# do your thing -> /etc/passwd.new
		# copy /etc/passwd -> /etc/passwd.bak
		# rename(/etc/passwd.new,/etc/passwd)

	5) consider looking for userdel or deluser for linux.  I know it comes
with slackware, but seems to be missing from redhat.


	
>
>    Thanks,
>
>    Benarson.
>

-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: 9 Sep 1997 18:58:23 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: How to rename /etc/passwd ?
Message-Id: <5v468f$bml$1@daily.bbnplanet.com>

In article <5v44tq$9rb$1@daily.bbnplanet.com>,
Jason Gloudon <jgloudon@bbn.com> wrote:
>In article <8o5M5om00WB90VOqs0@andrew.cmu.edu>,
>Robert J Migliore  <migliore+@andrew.cmu.edu> wrote:
>>Excerpts from netnews.comp.lang.perl.misc: 9-Sep-97 How to rename
>>/etc/passwd ? by Benarson Behajaina@swh.s 
>>> I'm running Linux 2.0.27. Since there's no tool which may remove user,
>>> I would like to write a short script that will do this.
>>> I couldn't rename the /etc/passwd file, 'cause 'man perlfunc' says:
>>> rename OLDNAME, NEWNAME
>>>             Change the name of file. Will not work accross file system
>>>             boundaries.
>>>  
>>> So my question is, how to write a Perl script that could update or
>>> rename this file ?
>>
>>Not to avoid your question, but how do people go about copying files in
>>general.. ?  I've been using shell commands and to my knowledge there is
>>no copy function (at least in any of the perl books I own).
>>
>>
>>-Rob
>
>Try using the File-Tools module. If you are using at least Perl5.003 it
>should already be installed.
>
>Jason Gloudon

To the original poster :

You could create your new copy of the password file on the same filesystem or 
even the same directory even, and then use rename -after making a dated backup 
copy of the current passwd file in case something goes wrong-which it will.

But unless you implement some kind of locking on the password file, you will
eventually end up with a corrupted password file.

Jason Gloudon


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

Date: 09 Sep 1997 15:08:27 -0400
From: Douglas McNaught <doug@tc.net>
Subject: Re: How to rename /etc/passwd ?
Message-Id: <m24t7unw44.fsf@ono.tc.net>

jgloudon@bbn.com (Jason Gloudon) writes:

> To the original poster : You could create your new copy of the
> password file on the same filesystem or even the same directory
> even, and then use rename -after making a dated backup copy of the
> current passwd file in case something goes wrong-which it will.  But
> unless you implement some kind of locking on the password file, you
> will eventually end up with a corrupted password file. 

To be more specific: unless you find out your system's locking
mechanism for /etc/passwd and use it, you *will* collide with
/bin/passwd and anything else that changes the file.  Different
systems use different locking mechanisms.  Since the original poster
was using RedHat, he/she can just UTSL...

-Doug
-- 
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";


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

Date: Tue, 09 Sep 1997 19:09:59 +0100
From: John Reid <jreid.infocus@dnet.co.uk>
To: Fred@nospam.com
Subject: Re: Incredibly basic Newbie question
Message-Id: <341590F6.F1E872B7@dnet.co.uk>

Hi Fred

Just looking at the answers posted to your query. Have you downloaded a Perl
interpretter yet?
If not, you need to. Try http://www.activeware.com . Their version works
well and is easy enough to install.

Fred wrote:

>  My problem is that I have no idea how to run the damn
> thing (under Windows95).  I typed it as text with Notepad, then changed
> the filetype to .prl  but when I try to run it via the Start/Run
> function of Windows95, it simply opens it as a text file. Do I have to
> go to the MS.DOS window? What exact steps do I have to take to run it?
>

You can run the program in one of two ways.    i.    type perl
programname.prl
    ii.    associate the extension with perl.exe and then type the program
name. This step may only work properly with NT but it is worth a try.


> Can it be run on a p.c. or does it need to be uploaded first to a UNIX
> system?
>

UNIX runs on p.c.s too.

> If it can be run from a p.c., do I need to compile it first, or is that
> part of the run fuction? Do I need a program/compiler that is not part
> of the general Windows95 system (and if so, which one, and how do I
> install it?)
>

As mentioned at the start of this post you need a copy of the interpretter.
This is not part of the windows distribution (It is probably too usefull to
be given away as standard :-} )

> (Can someone point me to a tutorial or book which covers such elementary
> basics?)

Try Learning Perl published by O'Reilly and Associates

Hope this helps

John Reid
In Focus Multimedia



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

Date: Tue, 9 Sep 1997 15:27:52 GMT
From: ddurand@hpplus18.cern.ch (Jean-Damien Durand)
Subject: Re: local array in subroutine
Message-Id: <EG8yyG.Lzw@news.cern.ch>



In article <341559A9.7989@intercept.com>, Shawn M. Worsencroft <shawn_worsencroft@intercept.com> wrote:
>I am trying to make an array local to a subroutine, and return it to
>main.  
>
>The code works when the array is left as a global.
>It looks something like this.
>
>sub read_configuration {
>
># code
>
>return( @array )
>
>} # end sub
>
>This works fine, but if I try to make the declaration my @array at 
>the beginning of the sub routine it does not.  My understanding is that
>arrays get returned as lists and I don't understand why there is a
>difference when a local array is implemented.  Please explain.

  I would also suggest you to read the following excerpt of the "Effective Perl
Progamming" book at:
http://www.5sigma.com/perl/ex-mylocal.pdf
  Yes, its title is: "Understand the difference between my and local."
  This is interesting, give it a shot.

  Cheers,                  Jean-Damien.

ps: you'll need acroread (.pdf format).
--
       *******************************************************
       *   Jean-Damien Durand (Jean-Damien.Durand@cern.ch)   *
       *         www : http://wwwcn.cern.ch/~ddurand/        *
       *******************************************************


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

Date: Tue, 09 Sep 1997 13:14:21 -0600
From: Irene Wu <irenewu@net.com>
Subject: Perl DBM file
Message-Id: <873828337.28334@dejanews.com>

Have anyone tried to copy a database from one format to another using
Perl? Due to the huge disk usage of my NDBM file, I need to convert it
into SDBM file. However, it doesn't seem to work. When I tie a hash to
the result SDBM file, most values in the hash is empty. The weird
thing is that I can see all contents of the SDBM File (*.pag) using
Unix command "strings". The following is the program which does the
conversion. It will be really nice if someone can help me on this.
Thank you in advance.

use Fcntl;
$oldfile = "DATABASE";
$newfile = $oldfile.".new";

use NDBM_File;
dbmopen(%oldhash, $oldfile, 0666);

use SDBM_File;
dbmopen(%newhash, $newfile, 0666);

foreach $family (keys %oldhash) {
    $newhash{$family} = $oldhash{$family};
}

dbmclose(%oldhash);
dbmclose(%newhash);

----------------------------------------------------------------------
Irene Wu (irenewu@net.com)
Network Equipment Technologies

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 9 Sep 1997 11:08:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephen Hill <buck@huron.net>
Subject: Re: Print an Image
Message-Id: <Pine.GSO.3.96.970909085539.27604N-100000@julie.teleport.com>


On Tue, 9 Sep 1997, Stephen Hill wrote:

> Can you have a PERL script output an image? If so how do you do it?

    $image = &get_image;	# image in some form your output
				# device can utilize

    print DEVICE $image;	# That's all folks!

(You may need to use binmode() for proper output.) To find out how to
format the image for your output device, check its docs and FAQs. Good
luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Sep 1997 19:23:30 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: problems building 5.004_01 on HP-UXB.09.00
Message-Id: <5v47ni$ej3@ns1.arlut.utexas.edu>

smcdow@arlut.utexas.edu (Stuart McDow) writes:
> 
>         LD_RUN_PATH="/lib" ld -o ../../lib/auto/POSIX/POSIX.sl  -b -L/usr/local/lib POSIX.o    -lm 
> ld: supplemental symbol table required for module /lib/libm.a
> ld: (Warning) did not generate an output file
> *** Error code 1

Taking out the '-lm' seems to have fixed that problem.

--
Stuart McDow                                      Applied Research Laboratories
smcdow@arlut.utexas.edu                       The University of Texas at Austin


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

Date: 9 Sep 1997 09:18:56 -0700
From: kaz@helios.crest.nt.com (Kaz Kylheku)
Subject: Re: removing shell comments from ksh scripts
Message-Id: <5v3stg$5dk$1@helios.crest.nt.com>


In article <34156270.506F1420@mltsa.uk.lucent.com>,
James Hunt  <jhunt@mltsa.uk.lucent.com> wrote:
>This is a multi-part message in MIME format.
>--------------2BFF8D90CA8F77A200AA39A3
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>Does anybody know of a reliable way/have a program to remove comments
>from ksh scripts?
>
>This should have been a simple C program, but the problem I'm up against
>is how to handle lines like this...
>
>k=${j##*/}	# comment
>
>...where the program has to know that the 1st hash isn't a comment
>character.

Your program has to do some rudimentary lexical and syntactic analysis of the
script. You simply cannot do this reliably without paying attention to the
grammar of the shell language.

The ${x##y} parameter expansion schema isn't the only problem. Have you 
considered quoted text?

	COMMENT="# blah"

This is a valid statement in the language, with no comment.

Also, there is this:

    if [ $# -lt 3 ] ; then
	echo this script requires at least 3 arguments
	exit 1
    fi

An easy algorithm that is likely to work well is one that will recognize the
comment character only if it does not appear within nested delimiters or quote
delimiters.  That is, you set up some state machine that recognizes quotes
and () {} delimiters. Whenever you see a # character, you only treat it
as a comment if you are not between any delimiters, and if you are not scanning
a $# . You can tell that you are not by examining the state of the state
machine.  When you see a # character that is in a context where it must be
treated as a comment, you simply scan to the end of the line discarding all
encountered characters. Your program should probably also do the safe thing
and bail out with diagnostic messages if it sees some problem in the source,
such as unbalanced delimiters.

I'd read a document that describes the grammar of the scripting language to be
absolutely aware of all the pitfalls. The Korn shell isn't exactly POSIX,
so a comment stripper that works on the POSIX language might not quite work
for all possible Korn scripts.

>begin:          vcard
>fn:             James Hunt
>n:              Hunt;James
>org:            Lucent Technologies Network Systems UK Ltd
>adr:            Lucent Technologies;;Swindon Road;Malmesbury;Wiltshire;SN16 9NA;England
>email;internet: jhunt@mltsa.uk.lucent.com

>title:          Software Engineer

You are a software engineer and you need help with this programming triviality?
It seems that anyone can call him or herself a ``Software Engineer'' these
days.
-- 
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
	-- Blair P. Houghton


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

Date: Tue, 09 Sep 1997 12:34:39 -0500
From: Gary Fontenot x34237 <Gary.P.Fontenot1@lmtas.lmco.com>
Subject: Re: Sending a file with mailx using perl
Message-Id: <341588AF.6168@lmtas.lmco.com>

Okay, I found the problem.  $myfile had not been closed in
the perl script before referencing it in the mailx command.

Perl decided not to pass along the contents of the open
resource.

My apologies for any inconvenience.


Gary Fontenot x34237 wrote:

> 
> Hello
> 
> Here's a question about how to use a shell command in perl.
> 
> I want to send the contents of a file ($myfile) in a mail message.
> Since it seems that mailx does not directly provide the
> ability to do that, the following command with /bin/ksh has
> been used:
> 
> <$myfile mailx -s "My Subject" $MAIL_RECIPIENT
> 
> Why doesn't the following work in perl (it sends a message with
> a correct subject, but an empty body ($myfile is missing))?:
> 
> system("<$myfile mailx -s 'My Subject' $MAIL_RECIPIENT");
> 
> Thanks
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Gary P. Fontenot                          |Lockheed Martin TAS
> Gary.P.Fontenot1@lmtas.lmco.com           |P.O. Box 748
> (817) 763-4237                            |Mail Zone 5845
>                                           |Ft. Worth, TX 76101
> 
> "Zathras warn, but no, nobody listen to poor Zathras, no..."

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gary P. Fontenot                          |Lockheed Martin TAS
Gary.P.Fontenot1@lmco.com                 |P.O. Box 748
(817) 763-4237                            |Mail Zone 5845
                                          |Ft. Worth, TX 76101

"Zathras warn, but no, nobody listen to poor Zathras, no..."


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

Date: Tue, 09 Sep 1997 13:59:33 -0400
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: sumcheck generator wanted
Message-Id: <34158E85.44C5@daytonoh.ncr.com>

Execuse this question. It may relate to NT instead of Perl.
But then again, maybe the solution is in Perl.

Does anyone know of a sumcheck generator similar to the UNIX sum command 
that will run in a NT/WIN95 environment ?

It can be a .exe or perl script.


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

Date: Tue, 09 Sep 1997 11:09:16 -0700
From: Eric Hilding <eric@garlic.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Testing attempts fail..
Message-Id: <341590CC.4DEE@garlic.com>

Tom Phoenix wrote:
> 
> On Mon, 8 Sep 1997, Eric Hilding wrote:
> 
> > I'm trying to modify a perl script which processes info from a web
> > form, but first testing the proposed mods first on my PC.  I've tried
> > various syntax combinations one at a time and would like to know where
> > I'm screwing up.  Thanks for any help.
> 
> > #$FORM{'e2'} eq "Test Name";
> > #$FORM{'e2'} eq 'Test Name';
> 
> Those two expressions (commented out) are equivalent. (And they're
> useless, unless you use the expression in some larger statement, of
> course.)
> 
> > #$FORM{'e2'} eq {'Test Name'};
> 
> This is making a reference to a defective anonymous hash and testing that
> for string equality. Shouldn't work.
> 
> > #$FORM{'e2'} eq  /'Test Name'/;
> 
> This is doing a pattern match (against $_ by default) and seeing whether
> the result of that matches the %FORM variable as a string. Maybe you
> wanted =~ instead. Hope this helps!

Ugh...I changed my data for testing but it still won't print anything
for the $Subject string.  I ###'d everything out simply for the
posting...
had tried each individually.

I'm using the same if <blah> type of =~ matches that work find in the
rest
of the exiting script...what I'm trying to to is modify the Subject:
line
based upon certain info that comes in, so I can use .procmail recipies
for
routing to different mailboxes based upon the different Subject: lines.

There must be some way to get it to work but I'm stumped.  Some of the
if {
} tests may be cross-duplicative, but they make sense for what I want to
do.

I bought the "Mastering Regular Expressions" book am am struggling along
slowly...think my tests for City name(s) are okay.

I've tried it now, but still no luck, with:

###### Testing Testing #######
#### Various Combinations ####

$FORM{'e2'} =~ 'Test Name';
$FORM{'e4'} =~ 'Morgan Hill';
$FORM{'r9'} =~ 'r9a';
$FORM{'r9'} =~ 'r9b';

###### End Testing Attempts ######

if ($FORM{'r9'} =~ /r9a/)   
 {
  $Subject eq "WWW Inquiry & Referral - $FORM{'e2'}\n\n";
 }
if ($FORM{'r8'} =~ /r8a/)   
 {
  $Subject eq "WWW Possible Agent - $FORM{'e2'}\n\n";
 }
if ($FORM{'r9'} =~ /r9b/)   
 {
  $Subject eq "WWW NON-REFER - $FORM{'e2'}\n\n";
 }
if ($FORM{'e4'} =~ /[\s]?.*(Morgan Hill|Gilroy|San
Martin|Hollister)\s.*/)
 {
  $Subject eq "WWW Local - $FORM{'e2'}\n\n";
 }
if ($FORM{'loc'} =~ /[\s]?.*(Morgan Hill|Gilroy|San
Martin|Hollister)\s.*/)
 {
  $Subject eq "WWW Local - $FORM{'e2'}\n\n";
 }

print "Subject: $Subject\n";  # To test output ... don't get $Subject
data

------

*** FYI, the following work absolutely fine in the actual script for
other
purposes in the mailed text body.

print MAIL "OK Referral: Authorized\n" if ($FORM{'r9'} =~ /r9a/);
print MAIL "      ALERT: DO NOT REFER --- CHECK STATUS\n" if
($FORM{'r9'} =~ /r9b/);

Tnx for any additional clarification as to what's wrong.


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

Date: Tue, 09 Sep 97 14:18:32 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: What does "regexp *+ operand could be empty" mean?
Message-Id: <3415958d$4$ofn$mr2ice@speaker.kf8nh.apk.net>

In <3414687D.41C6@lmtas.lmco.com>, on 09/08/97 at 04:05 PM,
   Brett Denner <Brett.W.Denner@lmtas.lmco.com> said:
+-----
|   $_ = 'abc = 10 20 30';
|   s<\b(abc \s* = \s*) (\d* \s*)*><$1 20>x;
> ( . . . )
|   /(abc = )(\d*\s*,?)*/: regexp *+ operand could be empty at (eval 5) line
| 2, <IN> chunk 2.
+--->8

It's complaining about

    (\d*\s*)*

Which says:  zero or more of ( zero or more digits followed by zero or more
spaces )

Since the part in parentheses can be empty, the outer * can go insane trying
to figure out whether a null match belongs inside or outside :-)

I'd use something along the lines of:

    /^\s*(\w+)\s*=\s*((\d+\s+)*\d+)\s*$/

giving me the variable name in $1 and the list of numbers in $2.  Replace "\w"
with whatever pattern variable names will take.  I would *not* hardcode "abc =
" unless I knew for certain that I'd never need any other variable name or
spacing.  (And probably not even then, since the half-life of "for certain" is
about a month.  :-)

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)           FORZA CREW!
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org



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

Date: Tue, 9 Sep 1997 17:53:49 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: What does "regexp *+ operand could be empty" mean?
Message-Id: <EG95pq.6x9@bcstec.ca.boeing.com>

Cc: 

In article <5v2d90$oan@agate.berkeley.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>In article <EG7r0I.Btq@bcstec.ca.boeing.com>,
 >Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
   >>  > 
   >> other words \d* could match nothing. Ditto for \s* and the whole 
   >> backref. The space between \d* and \s* is the only thing that can't 
   >> be nullified. But even that lone survivor could be eaten by the 
   >> trailing \s* in the first backref. Is it any wonder Perl issues an 
   >> error :) 
  >
 >There is no space between \d* and \s*! ;-)
 >
 >You overlooked the s<><>x modifier.

Thanks, I had always assumed the x modifier was operative only if 
there were embedded comments. 

I knew I was missing something from Jeffrey's course :). 

--
Charles DeRykus


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

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

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