[6358] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 980 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 13:33:57 1997

Date: Thu, 20 Feb 97 10:00:21 -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           Thu, 20 Feb 1997     Volume: 7 Number: 980

Today's topics:
     $/ - input record separator <ktjuka@uta.fi>
     Re: $/ - input record separator <kentay@nortel.ca>
     Re: $/ - input record separator (Dave Thomas)
     backreferences in a character class? <dennerbw@lmco.lmtas.com>
     Bogus warning from suidperl with -U flag? (Nathan Torkington)
     Can I use sockets with Perl for Win95/NT? <webmaster@surewould.com>
     Determine perl program memory usage mg@obd.com
     Re: efficiency of many fixed strings vs one regex <jander@jander.com>
     Re: efficiency of many fixed strings vs one regex (Dave Thomas)
     escaping quotes/#? (Jeff Welch)
     futur de perl et java-script <Dominique.BAGOT@cetp.ipsl.fr>
     Re: futur de perl et java-script (Nathan V. Patwardhan)
     Re: Gregorian date function (Jonathan Peterson)
     Help needed - Modifying existing test files <bruce@zeuter.com>
     Re: Help needed - Modifying existing test files (Tad McClellan)
     Re: How to become a member ......? <afsypng@sphinx.cmc.doe.ca>
     Re: How to become a member ......? (Abigail)
     Re: How to do case statements in perl <rdarnese@nortel.ca>
     Re: html -> text (Matthew D. Healy)
     Re: Making sure 'perl -v' works (Mik Firestone)
     Most efficient way to do a killfile-like regexp test? (Christopher Russo)
     Re: newbie: To get me started... <jander@jander.com>
     Perl as a shared library? <marius@funcom.com>
     Re: Perl as a shared library? (Ollivier Robert)
     Re: perl help  ... (Tom Grydeland)
     Re: Perl Sockets reprise (Tom Grydeland)
     Re: Perl Sockets reprise <merlyn@stonehenge.com>
     printing date of a file to html page <rjhodgz1@homer.louisville.edu>
     Re: printing date of a file to html page (Tad McClellan)
     Re: printing date of a file to html page <jander@jander.com>
     Program to expand directory structures <dduncan@realogic.com>
     Re: Regexp to do minimal email validation (Matthew D. Healy)
     Re: Simple way to split up a string <mcontois@sig.bsh.com>
     Re: tail -f in perl <dduncan@realogic.com>
     Re: The Power And Peril Of Writing Perl CGI Code - Lan  <karp@hpl.hp.com>
     Re: Why doesn't gethostbyaddr return a value? <rra@cs.stanford.edu>
     Re: Why is perl different from perl -w on shebang line? (Tom Grydeland)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 20 Feb 1997 14:54:01 GMT
From: Jussi Kallioniemi <ktjuka@uta.fi>
Subject: $/ - input record separator
Message-Id: <5ehoi9$mbi@cc.tut.fi>

Q: Why does the changing of the input record separator change the number of 
the input records?

Why does: 

#!/usr/bin/perl

$count = 0; 

open (FOO, "foobar") || "Bleh\n";
while (<FOO>) {
	$count++;
}
print $count;

print out 3 if I run it on file which has 3 lines, but 
produces 4 if I set $/ = "Barf!"; and run it on file which 
contains: 
Barf!Barf!Barf!	

My little mind is all blurred. 

Cheers, 

--
Jussi Kallioniemi <jukal@infosto.fi>


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

Date: Thu, 20 Feb 1997 10:43:59 -0500
From: Ken Taylor <kentay@nortel.ca>
Subject: Re: $/ - input record separator
Message-Id: <330C713F.AA7@nortel.ca>

Are you counting EOF? If your 3 line file with default input record
separator is "1\n2\n3" then with "Barf!" as an input separator the
equivalent would be "1Barf!2Barf!3"

|/
|\en


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

Date: 20 Feb 1997 16:07:27 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: $/ - input record separator
Message-Id: <slrn5gotgt.mes.dave@fast.thomases.com>

On 20 Feb 1997 14:54:01 GMT, Jussi Kallioniemi <ktjuka@uta.fi> wrote:
> Q: Why does the changing of the input record separator change the number of 
> the input records?
 ....
> print out 3 if I run it on file which has 3 lines, but 
> produces 4 if I set $/ = "Barf!"; and run it on file which 
> contains: 
> Barf!Barf!Barf!	


OK - lets start with the default, '\n'

     line1
     line2
     line3
     line4
     
File with 4 lines, right?

OK - make it into a linear string - same data, different layout

     line1\nline2\nline3\nline4\n
     
Get rid of the last \n. We still have data on 4 lines - the last just isn't
terminated:

     line1\nline2\nline3\nline4
     
Get rid of the first three lines of data:

     \n\n\nline4
     
Still 4 lines (nothing up my sleeve).


Change the line terminator to Barf!

     Barf!Barf!Barf!line4
     
Still 4 lines

Now, this is stored in a line, right. So in reality, you have a (real) \n at
the end of the line (probably). So lets use that as the data instead of the
string 'line4'.

     Barf!Barf!Barf!\n
    
With $? set to "Barf!", that string has four lines.

For my next trick...

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Thu, 20 Feb 1997 10:52:32 -0600
From: Brett Denner <dennerbw@lmco.lmtas.com>
Subject: backreferences in a character class?
Message-Id: <330C8150.41C6@lmco.lmtas.com>

Can I use a backreference in a character class?

I need to do a pattern match with the following format:

    $_ = q/ "Hi, 'Fred', or whoever you are." /;

    /(["'])([^$1]*)$1/ and $string = $2;

    print "$string\n";

    # Which should print:       
    #     Hi, 'Fred', or whoever you are.
    # if backreferences in character classes work.

I am trying to match the first " or ' in a string, and then match every
character except a " or ' (whichever I first matched) up till the next
matching " or ' (again, whichever I first matched).  Unfortunately, this
will only work if I can use the backreference $1 in the character class
[^$1], which doesn't seem to work in Perl 5.003.  I've looked in the
Camel 2 book, the FAQ, and man pages without finding a definitive
answer.

Should backreferences work in character classes, and if not, is there
another way to accomplish this?

Thanks,
Brett

----------------------------------------------------------------------- 
Brett W. Denner                          
Brett.W.Denner@lmtas.lmco.com


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

Date: 20 Feb 1997 10:46:09 -0700
From: gnat@frii.com (Nathan Torkington)
Subject: Bogus warning from suidperl with -U flag?
Message-Id: <5qpvxvweu6.fsf@elara.frii.com>

The following program:
	#!/usr/bin/perl -w -U
	print "success\n";
complains when chmod u+s:
	Args must match #! line at ./test line 1.
but prints "success" when not chmod u+s, or when the -U flag is removed.
	% perl -v | grep version
	This is perl, version 5.003_26

Is this a bug or am I definitely not supposed to be able to use -U
with setuid scripts (in which case, the warning could be made
clearer)?

Nat


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

Date: Thu, 20 Feb 1997 10:36:55 -0500
From: Chris <webmaster@surewould.com>
Subject: Can I use sockets with Perl for Win95/NT?
Message-Id: <330C6F97.79BF@surewould.com>

Well can I?

 - Chris
-- 
 ~~~~~*~~~~~*~~~~~*~~~~~*~~~~~*~~~~~*~~~~
|@                                      ^|
|            Sherwood Design             |
|        http://www.surewould.com        | 
|~                                      #|
 ~~~~~*~~~~~*~~~~~*~~~~~*~~~~~*~~~~~*~~~~




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

Date: Thu, 20 Feb 1997 09:21:17 -0600
From: mg@obd.com
Subject: Determine perl program memory usage
Message-Id: <856450932.31102@dejanews.com>

Is it possible to determine the amount of memory a perl program
is using?  I have a long running program that seems to consume
more memory that I would expect and want to determine the
memory usage a various points in the program.  A unix only
solution is OK.

	-Morris (mg@obd.com)

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


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

Date: 20 Feb 1997 09:07:02 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: efficiency of many fixed strings vs one regex
Message-Id: <d8tvsha1.fsf@jander.com>

ilya@math.ohio-state.edu (Ilya Zakharevich) writes:

> 
> [A complimentary Cc of this posting was sent to Rahul Dhesi
> <dhesi@22245864.trackme.com>],
> who wrote in article <5egfan$spn@samba.rahul.net>:
> >    /\@somedomain\.com/ && &found;
> >    /\@anotherdomain\.com/ && &found;
> >    /\@yetanother\.com/ && &found;
> >    /\@fourthdomain\.com/ && &found;
> > 
> > Is it better if I combine them into the following?
> > 
> >    /\@(somedomain|anotherdomain|yetanother|fourthdomain)\.com/ && &found;
> 
> a) All the questions like this one should be solved by using
> Benchmark.pm.

According to Jeffrey, p.284, the Benchmark module in not appropriate
for use with regexps due to "problems" with $&. He gives an example of
what he uses to Benchmark.

> b) If you want to explain results from these tests, you may need to
> read the Hip-Owl book by Jeffrey Friedl.
> 
> c) One may expect that the particular regexp above _might_ be improved
> by merging, but this is very dangerous to assume anything when perl's speed
> is concerned. Too many optimizations/pessimizations may be triggered
> behind the scene.
> 
> Ilya

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 20 Feb 1997 14:20:17 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: efficiency of many fixed strings vs one regex
Message-Id: <slrn5gon81.lt6.dave@fast.thomases.com>

On 20 Feb 1997 04:46:53 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> > Is it better if I combine them into the following?
> > 
> >    /\@(somedomain|anotherdomain|yetanother|fourthdomain)\.com/ && &found;
> 
> c) One may expect that the particular regexp above _might_ be improved
> by merging, but this is very dangerous to assume anything when perl's speed
> is concerned. Too many optimizations/pessimizations may be triggered
> behind the scene.

Or by extracting the string in question and checking it using a hash:

   /\@(.*?)\.com/ && $okDomain{$1};
   
Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Thu, 20 Feb 1997 17:47:06 GMT
From: jwelch@world.std.com (Jeff Welch)
Subject: escaping quotes/#?
Message-Id: <E5wxEI.2tH@world.std.com>


I'm modifying a script I've set up and need some help. I'm trying to
change the line

print NEWFILE "<body>\n"  (which works fine)

to output the line "<body bgcolor="#FFFFFF">\n" instead of just
                   "<body>\n"

I've tried escaping the quotes and the pound sign but neither seem to work.
How would I do this?

Thanks, 

Jeff




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

Date: Thu, 20 Feb 1997 15:25:17 +0100
From: Dominique BAGOT <Dominique.BAGOT@cetp.ipsl.fr>
Subject: futur de perl et java-script
Message-Id: <330C5ECD.5CBB@cetp.ipsl.fr>

Bonjour a tous,

	A votre avis, Perl est-il condamne ?
	Je veux dire : Java script ne le remplacera-t-il pas ?

Dom
Dominique.BAGOT@cetp.ipsl.fr


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

Date: 20 Feb 1997 14:50:19 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: futur de perl et java-script
Message-Id: <5ehobb$ab5@fridge-nf0.shore.net>

Dominique BAGOT (Dominique.BAGOT@cetp.ipsl.fr) wrote:

: 	A votre avis, Perl est-il condamne ?
: 	Je veux dire : Java script ne le remplacera-t-il pas ?

Non non non.  Ce n'est vrai pas.

Javascript and Perl are two completely different entities, as are Java
and Javascript.  Each has nothing to do with the other.  Java runs on the
client-side.  Perl is a language that many people have found useful for
CGI programming.

--
Nathan V. Patwardhan
nvp@shore.net
"The Average American has the attention 
span of a ferret on a double expresso
Dennis Miller"


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

Date: 20 Feb 1997 17:47:25 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: Gregorian date function
Message-Id: <jon-2002971744120001@amx11.amxdigital.com>

In article <330AEFA1.913@club-internet.fr>, pascal amram
<pamram@club-internet.fr> wrote:

> ------------56EF5CC0620F0
> Content-Transfer-Encoding: 7bit
> Content-Type: text/plain; charset=us-ascii
> 
> I would like to know a script or algorythm to create a function that
> return me the name of the day from a date format. For example
> &which_day("19/02/97") return "Wednesday".
> The problem is to get this function with a SIMPLE perl script (no .PM no
> more external addins etc) just a good and old perl script..
> 
> Many thanks from a newbie
> 

Look at the ctime function in the perl library and the localtime function
(in built) If you really don't like external libs, cut and paste the ctime
function in. It's very short.

man perlfunc will give you details (on unix)


And _please_ don't use Netscape's ability to send HTML codes. This is
Usenet, not the WWW. (just my opinion, of course).
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300

"You wouldn't believe the things I've seen with your eyes."


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

Date: Thu, 20 Feb 1997 11:59:50 -0500
From: Bruce Ritchie <bruce@zeuter.com>
Subject: Help needed - Modifying existing test files
Message-Id: <330C8305.76A@zeuter.com>

I am trying to modify an existing text file on a unix web server that is
in the multimegabyte size range. 

What I need to do is delete a variety of lines from this file from time
to time, but I would like to do it without reading the whole file into
memory and then rewriting it back to disk minus the offending lines - I
have limited memory to work with and I am concerned with running out of
memory.

The script I ahve come up with receives input via CGI ($input{aName})
and is supposed to upon finding that name delete the name and 9
consecutive lines - but it doesn't work.
I have tested it and found it is not writting to the file, I believe I
am not using the tr/// operator correctly but I am stuck - the perl
manual doesn't help me much on this one.

Any help would be greatly appreciated.

The offending subroutine is as follows:

sub DelLines {

######### initialize local variables

$count=0;
$matchFound = "false";

######### read file till name is found, then delete 10 lines, inclusive
######### we know that name is in the file, since we have previously
scanned the file
######### for the name and found it

open (aTextFile, "+<./textfile.bak");
while (<aTextFile>) {            
       if (m/$input{aName}/) {
        	tr/\w*//;
	        $count++;
		$matchFound = "true";
       }
       if (($count < 10) && ($matchFound eq "true")) {
       		tr/\w*//;
        	$count++;
       }
} #endwhile
} #endsub


Bruce Ritchie
bruce@zeuter.com


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

Date: Thu, 20 Feb 1997 11:42:54 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help needed - Modifying existing test files
Message-Id: <ue2ie5.7t2.ln@localhost>

Bruce Ritchie (bruce@zeuter.com) wrote:
: I am trying to modify an existing text file on a unix web server that is
: in the multimegabyte size range. 

: What I need to do is delete a variety of lines from this file from time
: to time, but I would like to do it without reading the whole file into
: memory and then rewriting it back to disk minus the offending lines - I
: have limited memory to work with and I am concerned with running out of
: memory.


You know, of course, that is is _virtual_ memory that you need be
concerned with. Do you have enough swap space, or can you increase it?

I assume that _disk_ space is not a concern?


: The script I ahve come up with receives input via CGI ($input{aName})
: and is supposed to upon finding that name delete the name and 9
: consecutive lines - but it doesn't work.
: I have tested it and found it is not writting to the file, I believe I
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Maybe because you don't have any print statements  ;-)

ie. You haven't _told_ perl to write anything. 

It only does what you tell it...


: am not using the tr/// operator correctly but I am stuck - the perl
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You are correct there ;-)


: manual doesn't help me much on this one.
: Any help would be greatly appreciated.

: The offending subroutine is as follows:
: sub DelLines {
: ######### initialize local variables
                       ^^^^^

That comment is misleading.

They are _global_ variables...

: $count=0;
: $matchFound = "false";

my $count=0;
my $matchFound = "false";


: ######### read file till name is found, then delete 10 lines, inclusive
: ######### we know that name is in the file, since we have previously
: scanned the file
: ######### for the name and found it

: open (aTextFile, "+<./textfile.bak");
: while (<aTextFile>) {            
:        if (m/$input{aName}/) {
:         	tr/\w*//;


The perlop man page says:

=item tr/SEARCHLIST/REPLACEMENTLIST/cds

No mention of EXPR or regexs or anything there.

'cause they're not EXPR or regexs or anything ;-)

They are strings (lists of characters actually).

The above should delete any of the three chars: '\'  'w'  '*',
leaving everything else untouched...

You probably wanted s/// there.


: 	        $count++;
: 		$matchFound = "true";
:        }
:        if (($count < 10) && ($matchFound eq "true")) {
:        		tr/\w*//;
:         	$count++;
:        }
: } #endwhile
: } #endsub


You will, in addition to adding some print statements, need to seek()
back to the beginning of the file to write it back out.


If this was my job to do, I would just scrap all of the above, and
process it line by line (UNTESTED, but it should be close):


------------
open(ATEXTFILE, "./textfile.bak") || die "could not open  $!";
# use all UPPER CASE for filehandles

open(NEW, ">tempfile")|| die "could not open tempfile  $!";

while (<ATEXTFILE>) {
   if (m/$input{aName}/) {
      foreach (1..9) { <> }   # skip 9 more lines
      next;
   }
   print NEW $_;
}
rename "tempfile", "./textfile.bak"; # mv tempfile over the original
------------


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 20 Feb 1997 08:58:42 -0500
From: Jacques Marcoux <afsypng@sphinx.cmc.doe.ca>
Subject: Re: How to become a member ......?
Message-Id: <y2eu3n737fx.fsf@sphinx.cmc.doe.ca>

Baskaran Tranquebar <baskaran@isi.com> writes:

> 
> 	I would like to enroll myself in this news group. May I ask for your
> advise in how should I do that?.
> 

Best way is to get (and read) the FAQ
http://www.perl.com/perl/info/documentation.html 

-- 
	______                                    ______ 
	___/ /_______________________________________/ /_
	/_  __//_____//_Jacques_//_Marcoux_//_____/_  __/
	 /_/                                       /_/   
	       jmarcoux@ec.gc.ca 514.421.4794



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

Date: Thu, 20 Feb 1997 17:01:37 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: How to become a member ......?
Message-Id: <E5wvAp.1DF@nonexistent.com>

On 20 Feb 1997 01:09:26 GMT, Nathan V. Patwardhan wrote in comp.lang.perl.misc:
++ Baskaran Tranquebar (baskaran@isi.com) wrote:
++ 
++ : 	I would like to enroll myself in this news group. May I ask for your
++ : advise in how should I do that?.
++ 
++ You have to leave your house and run around the block two times. 
++ 
++ Well, okay, by posting to this newsgroup, and asking/answering questions
++ (or just reading), you're a member!  Welcome!
++ 

Djee, you should have told him he would have to become
a member of the Perl institute.


Abigail



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

Date: 20 Feb 1997 14:21:47 GMT
From: Richard Arnesen <rdarnese@nortel.ca>
Subject: Re: How to do case statements in perl
Message-Id: <5ehmlr$pj2@nrtphc11.bnr.ca>

Jagadeesh Venugopal <jvenu@ctp.com> had nothing better to do and thus wrote:
: In article <5ef8jl$5h5@nrtphc11.bnr.ca> Richard Arnesen <rdarnese@nortel.ca> writes:
: >The subject line says it all.
: >
: >-- 
: >Richard D. Arnesen Jr.              "Bill Clinton's Promises have the

: Please look in the 2d edition Camel Book page 103. 

Okay that's pretty simple.

Thanks to everyone who answered my question.

: -- 
:  /\/\ |Jagadeesh K. Venugopal, jvenu@ctp.com |http://w3.ctp.com/~jvenu 
: / /_.\|Cambridge Technology Partners, Inc.   |http://www.ccs.neu.edu/home/jkvg 
: \  /./|304 Vassar St.  Cambridge, MA 02139   |
:  \/\/ |Phone: 617.374.2028 FAX: 617.374.8300 +

-- 
Richard D. Arnesen Jr. - Unix DCA Support, Nortel, RTP
----------------------------------------------------------------
"..but I now know who he is, and what he is. There is nothing he
won't do, he is immune from shame...you find absolutely nothing,
nothing but an appetite" - Jesse Jackson speaking of Bill Clinton
----------------------------------------------------------------
The opinions stated above are mine and not that of Nortel 


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

Date: Thu, 20 Feb 1997 12:15:04 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: html -> text
Message-Id: <Matthew.Healy-2002971215040001@pudding.med.yale.edu>

In article <alpfe5.ua3.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:

 
> 
> If this were _my_ task to do, then I would use 'lynx -dump',
> and then process the output of _that_.
> 

Exactly what I do.  And, drifting a little bit off-topic, I often say 

!!lynx -source http://whatever.wherever/dir/subdir

from within vi when I want to grab the source of some URL to play with
it, or lynx -dump when I want to grab the text.  Sometimes I also
pipe it through grep or something...

lynx is your friend.  And it's a lot more robust than Nutscape or M$IE.

---------
Matthew.Healy@yale.edu
http://paella.med.yale.edu/~healy
Go and share the Gospel.  Use words only if necessary --St Francis


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

Date: 20 Feb 1997 14:17:09 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: Making sure 'perl -v' works
Message-Id: <5ehmd5$ib0$1@mail.lexington.ibm.com>

In article <01bc1f20$60ae9540$7ce42ac2@steve>,
Stephen K. Bohler <skbohler@ix.netcom.com> wrote:
>I've just tried to determine the version of Perl running on my client's
>server and it tells me that it is version 4. However, they have the
>/usr/local/lib/perl5 libraries on it.
[snip]
>Can anyone explain this discrepancy?
>

Find out where your perl -v is going.  To make a random guess, I would
also suggest looking for /usr/local/lib/perl5 ( or something similar ).  It
is not uncommon to keep the perl4 binaries named perl when there is a great
deal of code that depends on perl4isms.

-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #33: No matter how attractive certain members of the
rebellion are, there is probably someone just as attractive who is not
desperate to kill me. Therefore, I will think twice before ordering a
prisoner sent to my bedchamber. 


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

Date: 20 Feb 1997 17:46:31 GMT
From: crusso@mit.edu (Christopher Russo)
Subject: Most efficient way to do a killfile-like regexp test?
Message-Id: <5ei2ln$apf@senator-bedfellow.MIT.EDU>

Hi everybody-

I've been working on a script that has reads in a file, and then throws out 
certain lines if they meet certain user-definable regexps - very similar to 
having a user definable killfile.  What I'm doing is eval-ing an array of 
regexps and then testing it against each line of the file, but I know that 
there must be a faster way to do it.  I suppose I could string together a long 
series of "regexp1 || regexp2..." and then eval it, but this seems awfully 
inefficient.  Right now, I'm doing something like:

	foreach $line (@lines) {
		foreach (user-definable-regexp) {
			if ($line =~ eval-ed regexp) {
				do whatever...
			}
		}
	}

Anybody know a faster way to do this, or am I just being greedy?  :)


Chris Russo
crusso@mit.edu



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

Date: 20 Feb 1997 12:09:26 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: newbie: To get me started...
Message-Id: <bu9fs8u0.fsf@jander.com>

"Daniel Pepermans" <danielp@tma.co.za> writes:

> 
> If someone can show me what is required to print "Hello world!" on the
> screen, I can figure the rest out for myself.
> 
> I have Perl5 installed on my NT4.0 workstation
> 
> I need to know what to type at the command prompt to get "hello world" to
> print. i.e. is it PERL PRINT "HELLO WORLD" - understand my situation?
> 
> Also what to pass to perl when I want it to run commands from a script file
> - something.pl.

1) perl -e 'print "Hello World\n"'

2) perl something.pl, or just 'something.pl' if you have the 1st line
of the script setup accordingly.

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 20 Feb 1997 16:56:17 +0100
From: Marius Kjeldahl <marius@funcom.com>
Subject: Perl as a shared library?
Message-Id: <52zpwz1nfi.fsf@ace.funcom.com>

I have seen a couple of postings about this with regards to making
stand-alone executables of perl scripts. In addition, I have the
following questions:

1) Will upcoming versions (5.004?) have support for building perl as a
shared library (typically with a small executable that fires up this
library)? I have been told that someone at SGI did this with 5.003.

2) If so, what are the implications for using perl for scripting? Will
the startup time be significantly smaller (assuming the OS "caches"
the shared library in memory)?

Thanks in advance..

Marius


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

Date: 20 Feb 1997 16:48:22 GMT
From: roberto@eurocontrol.fr (Ollivier Robert)
Subject: Re: Perl as a shared library?
Message-Id: <5ehv8m$k2i$1@polaris.eurocontrol.fr>

    [courtesy cc of this posting sent to cited author via email]

In article <52zpwz1nfi.fsf@ace.funcom.com>,
Marius Kjeldahl  <marius@funcom.com> wrote:
> 1) Will upcoming versions (5.004?) have support for building perl as a
> shared library (typically with a small executable that fires up this
> library)? I have been told that someone at SGI did this with 5.003.

Yes. On many architectures you can build a libperl.so (or whatever your
shared library scheme name it).

-- 
Ollivier ROBERT   -=- Eurocontrol EEC/TS -=-   Ollivier.Robert@eurocontrol.fr
Usenet Canal Historique


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

Date: 20 Feb 1997 14:27:19 GMT
From: tom@palver.nospam.eiscat.no (Tom Grydeland)
Subject: Re: perl help  ...
Message-Id: <TOM.97Feb20152719@palver.nospam.eiscat.no>

In article <330BF659.2C19@egames.com> Devin Ben-Hur <dbenhur@egames.com> writes:
> ck lam wrote:
[snip example input]
> :         I just want to replace the all "xm3" found in sub circuit
> : pdp...something and change it to xm5. So I need a perl to match
> : expression subckt pdp and begin replace operation until I come across
> : a ends subckt.

To which Devin replied:

> this should do the trick:
> 
> $dosubst = 0;
> while (<>) {
> 	if (/^\.subckt pdp/) { $dosubst = 1 }
> 	elsif (/^\.ends subckt/) { $dosubst = 0; }
> 	else { s/xm3/xm5/g; }
> 	print;
> }

But perl already has the range operator .. to keep this kind of state

perl -pe 's/xm3/xm5/g if /^\.subckt pdp/../^\.ends subckt/' files

or in a script

#!/usr/local/bin/perl -wp

if (/^\.subckt pdp/../^\.ends subckt/) {
	s/xm3/xm5/g;
}

for in-place editing, combine this with the -i flag.

#!/usr/local/bin/perl -w

while (<>) {
	if (/^\.subckt pdp/../^\.ends subckt/) {
		s/xm3/xm5/g;
	}
	print;
}

> Devin Ben-Hur      <dbenhur@egames.com>

//tom


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

Date: 20 Feb 1997 14:07:24 GMT
From: tom@palver.nospam.eiscat.no (Tom Grydeland)
Subject: Re: Perl Sockets reprise
Message-Id: <TOM.97Feb20150724@palver.nospam.eiscat.no>

In article <856399272.7057@dejanews.com> msosteri@yesic.com writes:
> In article ,
>   tom@palver.nospam.eiscat.no (Tom Grydeland) wrote:
> > From the pink camel, p.174 or the blue camel, p.211:
> Bizarre, obscure AND NITPICKY, in my "RED" Camel the select Function
> is on page 177.

Not in my book.  It's on p. 174.  I have 1st printing, from
January 1991.  What do you have?

> >   select((select(STDERR), $|=1)[0])
> 
> I think I got it. This cryptic incantation "selects" STDERR, gives PERL
> control over output buffering and then "selects" the previous filehandle
> (whatever that was) via the return value of the inner select. But select
> returns the previously selected filehandle as a scalar? Why the array
> offset [0]?

The inner parentheses construct the list consisting of the previously
selected *filehandle* (not scalar) and the result of the assignment
(e.g. 1).  This list is then

(FILEHANDLE, 1)

and the index [0] will pick the first element of this list
(i.e. FILEHANDLE) and this will be the argument to the outer select().

Hope this helps.

//tom


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

Date: 20 Feb 1997 08:24:51 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: msosteri@yesic.com
Subject: Re: Perl Sockets reprise
Message-Id: <8csp2r8pq4.fsf@gadget.cscaper.com>

>>>>> "msosteri" == msosteri  <msosteri@yesic.com> writes:

>> 
>> select((select(STDERR), $|=1)[0])

msosteri> I think I got it. This cryptic incantation "selects" STDERR,
msosteri> gives PERL control over output buffering and then "selects"
msosteri> the previous filehandle (whatever that was) via the return
msosteri> value of the inner select. But select returns the previously
msosteri> selected filehandle as a scalar? Why the array offset [0]?

The inner op is a literal slice:

	(LIST)[0]

which picks out the 0th element of LIST.  Without the 0, you'd have
just a comma operator (if select is prototyped $), or a list
constructor (if select is prototyped @).  If it was a comma operator,
you'd get the value $|=1 (1).  If it was a list constructor, you'd get
invalid syntax (there's no 2-arg form of select).

So yes, the [0] is quite necessary.

I'm trying to recall Perl history... but I think *I* was the one
responsible for this hack.  Nice. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 558 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 20 Feb 1997 09:35:37 -0500
From: Jeff Hodge <rjhodgz1@homer.louisville.edu>
Subject: printing date of a file to html page
Message-Id: <Pine.HPP.3.95.970220093101.2185A-100000@homer.louisville.edu>

Hello all,
I would like to know if there is a way to use perl to read the date of a
file, in this case it is group of documents, anyway, the script would then
take the system date on each file and print them to an html
page.  I would like to be able to have this system automatically print
the last updated date of the files on the screen, rather than doing it
by hand each time.  Can this be done using perl?
Thanks



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

Date: Thu, 20 Feb 1997 09:28:11 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: printing date of a file to html page
Message-Id: <biqhe5.4v1.ln@localhost>

Jeff Hodge (rjhodgz1@homer.louisville.edu) wrote:
: Hello all,
: I would like to know if there is a way to use perl to read the date of a
: file, in this case it is group of documents, anyway, the script would then
: take the system date on each file and print them to an html
: page.  I would like to be able to have this system automatically print
: the last updated date of the files on the screen, rather than doing it
: by hand each time.  Can this be done using perl?
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Yes.

see stat() and localtime() in the perlfunc man page.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 20 Feb 1997 12:12:58 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: printing date of a file to html page
Message-Id: <914js8o5.fsf@jander.com>

Jeff Hodge <rjhodgz1@homer.louisville.edu> writes:

> Hello all,
> I would like to know if there is a way to use perl to read the date of a
> file, in this case it is group of documents, anyway, the script would then
> take the system date on each file and print them to an html
> page.  I would like to be able to have this system automatically print
> the last updated date of the files on the screen, rather than doing it
> by hand each time.  Can this be done using perl?

See the 'stat' function.

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Thu, 20 Feb 1997 10:53:37 -0500
From: Diana Duncan <dduncan@realogic.com>
Subject: Program to expand directory structures
Message-Id: <330C7381.75AC@realogic.com>

About a week ago I read a message from someone asking if there were a
program written to expand directory structures, printing a formatted
"tree"-type listing of the files and directories.  I posted back that
the Perl class I was teaching was solving this problem for a homework,
and that I would post the result.  I must apologize for not following
the thread, but I can't find the messages!

Anyway, here's the program.  It will work for both Unix and Win32, and
should work for other platforms as well.  The FTP feature will not
currently work in Win32 environments -- if anyone can fix this, let me
know!

By the way, this is somewhat long (6 pages) but I wanted to demonstrate
many concepts to my class.

#!/usr/local/bin/perl
# explorer.pl
#
# Usage: $0 [-u] [-f FTPsite,uname,pass] [-d dir] [-o outfile] [-s
search] [-l level]

$debug = 0;
if ($debug) { print "Operating System is $^O\n"; }

use Getopt::Std;
eval 'use Win32; 1' if $^O eq 'NT' or $^O eq 'MSWin32';
eval 'use Cwd; 1' unless $^O eq 'NT' or $^O eq 'MSWin32';
eval 'use Net::FTP; 1' unless $^O eq 'NT' or $^O eq 'MSWin32';
use File::Basename;

# Define the formats
#
format OUTFILE_TOP =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#items
"Expanding directory $dir", $col2_heading
-------------------------------------------------------------------
------
 .
format OUTFILE =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@>>>>>
$item, $count
 .

sub print_tree {
  my ($tree) = shift;
  $count = '';

  if ($debug) { print "Starting print_tree with $tree\n"; }
  while (@$tree) {
    $item = shift @$tree;
    write OUTFILE;
  }
  return $tree;
}

sub display_tree {
  my ($tree) = shift;
  my $entry = '';

  print "Current tree $tree contains:\n";
  foreach $entry (@$tree) {
    print "\t$entry\n";
  }
}

# list_directory is a recursive procedure that lists out the contents of
# a given directory, then calls itself for any sub-directories that it
# encounters.
# 
# In the case of a search_string, it does NOT print anything unless
# a match is found.  Once a match is found, the procedure prints out
# the saved tree and the match.  Therefore, the tree variable is only
# used in the case of a search_string.
#
# tree is a reference to an array.  In the case of search_string, the 
# number of items is irrelevant and is not printed.
#
sub list_directory {
  my ($dir, $level, $tree) = @_;
  my ($indent, $newdir, $newlevel, $saveitem);
  my @items = ();
  my @sorted = ();
  my @fields = ();

  if (not defined $level) {
    $level = 0;
  }
  $indent = '    ' x $level;
  if ($debug) { print "Starting list_directory with dir = $dir, level =
$level, tree = $tree\n"; }
  if (defined $opt_s and not defined $tree) {
    $tree = [];		# initialize the anonymous array reference
    if ($debug) { print "Created new tree $tree\n"; }
  }

  # Handle the c:\ and d:\ cases, which are volumes instead of
directories,
  # so they need an extra \ at the end.  DOS - the Dumb Operating
System.
  #
  if ($dir =~ /[a-zA-Z]:\\$/) {
    $dir .= '\\';
  }

  if (defined $opt_f) {
    @items = grep !/^\.\.?/, $ftp->lsl($dir);
  } else {
    opendir DIR, $dir or die "Cannot open $dir: $!";
    @items = grep !/^\.\.?/, readdir DIR;
    closedir DIR;
  }
  my ($name, $path) = fileparse($dir);
  my $separator = substr $path, -1, 1;
  $item = sprintf("%s%s", $indent, $name);
  $count = @items;

  if (defined $opt_s) {
    push @$tree, $item;
    if ($debug) { print "Pushing $item onto $tree\n";
display_tree($tree); }
  } else {
    write OUTFILE;
  }

  # If the requested level has been met or exceeded, return from the
  # subroutine
  #
  if (defined $opt_l and $level >= $opt_l) {
    return;
  }

  # do the correct sorting
  #
  if ($opt_r) {
    if (defined $opt_f) {
      @sorted = sort { 
	my @arra = split / /, $a;
	my @arrb = split / /, $b;
	lc($arrb[$#arrb]) cmp lc($arra[$#arra]) 
      } @items;
    } else {
      @sorted = sort { lc($b) cmp lc($a) } @items;
    }
  } else {
    if (defined $opt_f) {
      @sorted = sort { 
	my @arra = split / /, $a;
	my @arrb = split / /, $b;
	lc($arra[$#arra]) cmp lc($arrb[$#arrb]) 
      } @items;
    } else {
      @sorted = sort { lc($a) cmp lc($b) } @items;
    }
  }

  # loop through the directory entries
  #
  ITEM: foreach $item (@sorted) {
    if ($debug) { print "item = $item\n"; }
    if (defined $opt_f) {
      $dir_byte = substr($item, 0, 1);
      @fields = split / /, $item;
      $item = pop @fields;
      if ($debug) { print "item = $item, dir_byte = $dir_byte\n"; }
      if ($item =~ /^\.\.?/) {
        next ITEM;
      }
    }
    $newdir = $dir . $separator . $item;
    $newlevel = $level + 1;
    if (defined $opt_s and $item =~ /$opt_s/i) {
      $saveitem = $item;
      push @$tree, sprintf("%s%s", '    ' x $newlevel, $item);
      if ($debug) { print "Found match for $opt_s in $item, pushing onto
$tree\n"; display_tree($tree) }
      $tree = print_tree($tree);
      $item = $saveitem;
    }

    # If this is a directory, and if we have not met the requested
    # number of levels, list the directory
    #
    if ((-d $newdir or (defined $opt_f and $dir_byte eq 'd')) and
((defined $opt_l and $level < $opt_l) or (not defined $opt_l))) {
      if ($debug) { print "Calling list_directory with dir = $newdir,
level = *$newlevel*, tree = $tree\n"; }
      list_directory($newdir, $newlevel, $tree);
      if (defined $opt_s) {
        pop @$tree;
        if ($debug) { print "Popping from $tree\n"; display_tree($tree)
}
      }
    } else {
      $item = sprintf("%s%s", '    ' x $newlevel, $item);
      $count = '';
      if (!defined $opt_s) {
        write OUTFILE;
      }
    }
  }
}


# main:
#
getopts('rf:s:ud:o:l:') or $opt_u = 1;

if ($opt_u) {
  print <<"EOU";
Usage: $0 [-u] [-f FTPsite,uname,pass] [-d dir] [-o outfile] [-s search]
[-l level]
	Options include:
		-u = usage text
		-f = FTP site to connect to,username,password (separated by
			commas * This does not work for DOS-based systems *
		-d = directory to explore
		-o = output file
		-r = sort in reverse order
		-s = a search string -> only print out matches
		-l = directory level to expand to
EOU
  exit;
}

# If the user attempts FTP on a DOS-based system, warn them
#
if (defined $opt_f and ($^O eq 'NT' or $^O eq 'MSWin32')) {
  die "Access to a FTP site is not available on this operating system.";
}

if (defined $opt_f) {
  ($ftpsite, $uname, $password) = split /,/, $opt_f;
  if ($debug) { print "ftpsite = $ftpsite, uname = $uname,
password=$password\n"; }
  $ftp = Net::FTP->new($ftpsite) or die "Can't get new FTP object: $!";
  $ftp->login($uname, $password) or die "Can't login: $!";
}

if ($opt_d) {
  $dir = $opt_d;
} elsif (defined $opt_f) {
  $dir = $ftp->pwd();
  if ($debug) { print "pwd = " . $ftp->pwd() . "\n"; }
} elsif ($^O eq 'NT' or $^O eq 'MSWin32') {
  $dir = Win32::GetCwd;
} else {
  $dir = cwd() or die "Can't get cwd: $!";
}

if ($debug) { print "dir = $dir\n"; }

if ($opt_o) {
  $outfile = $opt_o;
} else {
  $outfile = "-";
}
if ($debug) { print "outfile = $outfile\n"; }
if (defined $opt_s and $debug) { print "opt_s = $opt_s\n"; }

open OUTFILE, ">$outfile" or die "Can't open $outfile as an output file:
$!";

list_directory($dir);

close OUTFILE;

END {
  if (defined $opt_f) {
    $ftp->quit;
  }
}

-- 
Diana Duncan	     | My opinions are my own.
Sr. Consultant	     | 
REALOGIC, Inc.	     | Excitement, Adventure and
dduncan@realogic.com | Really Wild Things - Z.B.


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

Date: Thu, 20 Feb 1997 11:59:05 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: Regexp to do minimal email validation
Message-Id: <Matthew.Healy-2002971159050001@pudding.med.yale.edu>

 ...
> *can't*.  You can't.  There's no point.  Send the mail, and if it gets
> to them, it's the right address.  <fred&barney@stonehenge.com> is a
> valid address, and would have been falsely rejected by your regexp.

I just tried it, and it worked the _SECOND_ time, because the first
time I forgot to put single quotes around the address, causing Unix
to put mail into the background because the shell got to that
ampersand before mail did...

Cute, Randal, really cute.

I would add that there is not necessarily any relationship between
one's email address and the IP address from which one browses the
Web.  I know several people who regularly browse from machines on
the Yale campus, but prefer their email be sent to their ISP.  So
there's NO WAY to determine whether xxx.xxx@foo.com really is the
correct email address except by trying it out.

---------
Matthew.Healy@yale.edu
http://paella.med.yale.edu/~healy
Go and share the Gospel.  Use words only if necessary --St Francis


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

Date: Thu, 20 Feb 1997 12:18:28 -0500
From: Mark Contois <mcontois@sig.bsh.com>
Subject: Re: Simple way to split up a string
Message-Id: <330C8764.2781@sig.bsh.com>

Richard Arnesen wrote:

> Let's say I have a string of this format...
> 
> Richard (asds)
> 
> Okay I want to ignore everything after the first whitespace.
> What's the easiest way to do this??

$foo = 'Richard (asds)';
($string_u_want) = split(/\s/, $foo);

The parentheses around $string_u_want force the interpretation
of 'split' in a list context; without them, you'd get the scalar
version, which is the number of whitespace-separated elements in
your original string.

Mark

-- 
Mark Contois                 | Actual Windows NT error message:
Strategic Interactive Group  |       "No keyboard found.
Boston, MA                   |        Press F1 to continue."


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

Date: Thu, 20 Feb 1997 10:20:20 -0500
From: Diana Duncan <dduncan@realogic.com>
To: Torfinn Keringen <tor@kmd.dk>
Subject: Re: tail -f in perl
Message-Id: <330C6BB4.49A@realogic.com>

Torfinn Keringen wrote:
> 
> Hey, I some help,
> 
> I have this script who makes logfiles, D0220 - D0221 - DYYMM and
> so on, one each day.
> 
> What I need is a script that work like tail -f, but in addition
> find out if there is a new file, if there is continue reading
> that file, else wait for a new file.
> 
> I think you understand the problem.

Check out the Blue Perl 5 book, pg. 209 (function definition of seek),
or the perlfunc manpage under seek.

-- 
Diana Duncan	     | My opinions are my own.
Sr. Consultant	     | 
REALOGIC, Inc.	     | Excitement, Adventure and
dduncan@realogic.com | Really Wild Things - Z.B.


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

Date: Thu, 20 Feb 1997 08:33:09 -0800
From: Alan Karp <karp@hpl.hp.com>
Subject: Re: The Power And Peril Of Writing Perl CGI Code - Lan Times
Message-Id: <330C7CC5.46DF@hpl.hp.com>

jim@netcom.com wrote:
> 
> The Power And Peril Of Writing Perl CGI Code - Lan Times
> 
> Find this article at:
> 
> NewsLinx Daily Web News (2/14/97)
> 
> http://www.newslinx.com/

A general comment for posts like this one.  How about giving a link
directly to the article in question?  By the time I read the posting, a
new issue of newslinx was out.  It took a bit of poking around to find
the article (mostly due to newlinx bad interface to back issues).
-- 
Alan Karp
Hewlett-Packard Labs
1501 Page Mill Road
Palo Alto, CA 94304
(415) 857-6766, (415) 813-3381 (fax)


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

Date: 20 Feb 1997 08:29:29 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Why doesn't gethostbyaddr return a value?
Message-Id: <qumeneb30gm.fsf@cyclone.stanford.edu>

Matti Hultstrand <matti-hu@dsv.su.se> writes:

> Yes, running "nslookup 199.45.129.30" from the prompt gives me the host
> name "perl.com" (also works vice versa).  But the simple script below
> doesn4t print anything.

> #!/usr/local/bin/perl
> $hostname = gethostbyaddr("199.45.129.30", AF_INET);
> print "$hostname\n";

For the folks following along at home, the problem was that
gethostbyaddr() takes packed addresses, not dotted quads in the form of a
string.  gethostbyaddr (inet_aton ("199.45.129.30", AF_INET)) worked
correctly.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 20 Feb 1997 14:37:45 GMT
From: tom@palver.nospam.eiscat.no (Tom Grydeland)
Subject: Re: Why is perl different from perl -w on shebang line?
Message-Id: <TOM.97Feb20153745@palver.nospam.eiscat.no>

In article <5eg8j9$erl$1@darla.visi.com> lehman@visi.com (Todd Lehman) writes:

> Here's a weird Perl/Unix question.  I want to invoke a perl script add.pl
> on the shebang line and feed the rest of the script not to perl but to
> add.pl.  This works when my shebang line is
> 
> #!/bin/perl add.pl
> 
> but not when it is
> 
> #!/bin/perl -w add.pl

You're only allowed to put one single bundle of switches after the
program name/path on the shebang line.

When the file addtest1 begins with the line

> #!/bin/perl add.pl

what the kernel will execute is

/bin/perl add.pl addtest1

When the file addtest2 begins with the line

> #!/bin/perl -w add.pl

what the kernel will execute is

/bin/perl -w addtest2

And that should explain the following error messages:

> --------begin output--------
> Number found where operator expected at addtest2 line 3, near "2"
>         (Missing semicolon on previous line?)
> syntax error at addtest2 line 3, near "2"
> Number found where operator expected at addtest2 line 4, near "3"
>         (Missing semicolon on previous line?)
> Number found where operator expected at addtest2 line 5, near "4"
>         (Missing semicolon on previous line?)
> Number found where operator expected at addtest2 line 6, near "5"
>         (Missing semicolon on previous line?)
> Execution of addtest2 aborted due to compilation errors.
> --------end output--------


> Obviously perl is loading and interpreting addtest2 and ignoring
> add.pl.  Why is this?  Is there any way around it?

I don't know why, and I don't think there's a (simple) way around it.

You could of course add $^W=1 or something like that in add.pl

> I don't see anything in the sh manpages or in Kernighan & Pike or in the
> Perl FAQs on this.

Try unix FAQs

> --Todd Lehman

//tom


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 980
*************************************

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