[7753] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1378 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 16:12:49 1997

Date: Thu, 27 Nov 97 13:00:26 -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, 27 Nov 1997     Volume: 8 Number: 1378

Today's topics:
     Re: ?: in lhs <jan.krynicky@st.mff.cuni.cz>
     camel vs llama <c-keyes@mail.dec.com>
     Re: Conditional compilation? (Jason Gloudon)
     Re: Conditional compilation? (Andrew M. Langmead)
     Re: Finding the longest common prefix over a list of st (Ken Fox)
     Re: For the pro's ? repost: Leaving HTML tags alone (Tushar Samant)
     form results to both email and text file dwexler@zeusnet.com
     getopts on NT? (Jeff Kehoe)
     Re: getopts on NT? <see.my.sig@nospam.com>
     Got to be a cleaner Way randy.paries@avex.com
     Re: Got to be a cleaner Way (Jim Allenspach)
     Re: Got to be a cleaner Way <tycage@infi.net>
     Re: Got to be a cleaner Way <cmargoli@world.northgrum.com>
     Re: Got to be a cleaner Way (I R A Aggie)
     Re: Got to be a cleaner Way <dboorstein@ixl.com>
     Re: MailTools problems <jan.krynicky@st.mff.cuni.cz>
     Re: Net::FTP docs ? <ckpwong@undergrad.math.uwaterloo.ca>
     Re: Newbie question.   Do you recommend moving from C? <pmcgovern@sherikon.com>
     Re: Newbie question.   Do you recommend moving from C? (Jim Turner )
     Re: Newbie question. Do you recommend moving from C? <roedy@BIX.com>
     Re: open(), seek() and email monitoring <jan.krynicky@st.mff.cuni.cz>
     Re: OS/2: s/// statement still crashing (Ilya Zakharevich)
     Re: PERL Hourly Rates (brian d foy)
     Perl on Win32: Output file redirection clobbers file? <denis_haskin@iacnet.com>
     readdir() and Win32 Perl <ScottMcGee@cyber-wizard.com>
     Re: Removing HTML tag (Faust Gertz)
     Re: Strange 'print Location:' problem with Perl (Andre L.)
     Re: strange problem with regular expression memory vari (Jason Gloudon)
     Re: Text Matching <markm@nortel.ca>
     Re: Text Matching (Tushar Samant)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Nov 1997 20:23:33 -0800
From: Jan Krynicky <jan.krynicky@st.mff.cuni.cz>
Subject: Re: ?: in lhs
Message-Id: <347CF5C5.3EBB@st.mff.cuni.cz>

Jason Gloudon wrote:
> 
> Ed Young (youngej@magpage.com) wrote:
> : Dirk Vleugels wrote:
> 
> 
> : I have no idea why this failed, it did for me also,
> : but I have the workaround:
> 
>  It is a bug.
> 
> : @data = qw( yes !no !nyet si ja !nien);
> : foreach (@data)
> : {
> :   push @{/^!/ ? 'reject' : 'accept'}, $_;
> : }
> 
>  This won't work compile with use strict nor will it work if reject or accept
>  are lexical variables.
> 
> Jason Gloudon

What about

	push(@{/^!/ ? \@reject : \@accept},$_);

Seems to work OK with lexical vars and with use strict vars;

Jenda


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

Date: Wed, 26 Nov 1997 14:50:11 -0500
From: Joe Keyes <c-keyes@mail.dec.com>
Subject: camel vs llama
Message-Id: <347C7D73.5101@mail.dec.com>

I have seen mention made on this group of the
llama book being for programming newbies, and
camel book being for programmers' reference in
learning perl.

Is that asessment accurate?

Isn't the camel only up to 5.003? 

Joe Keyes


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

Date: 26 Nov 1997 18:59:28 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Conditional compilation?
Message-Id: <65hrig$hpl$6@daily.bbnplanet.com>

Thilo Goetz (goetz@watson.ibm.com) wrote:
: Hi all,

: and could not find an answer to my question.

: So here it goes.  I wrote a lengthy perl script that uses some features
: of perl5, so it won't compile under perl4.  If somebody tries to run
: this script with an older version of perl, I'd like a controlled death
: like so:

: if ($] < 5.0) { die "$0 error: needs perl v. 5 or better, aborting.\n";
: }

Put it in a BEGIN block :

BEGIN { 
	if ($] < 5.0) { die "$0 error: needs perl v. 5 or better, aborting.\n"
}

Jason Gloudon


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

Date: Wed, 26 Nov 1997 20:12:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Conditional compilation?
Message-Id: <EK9s4E.D7B@world.std.com>

jgloudon@bbn.remove.com (Jason Gloudon) writes:

>Put it in a BEGIN block :

>BEGIN { 
>	if ($] < 5.0) { die "$0 error: needs perl v. 5 or better, aborting.\n"
>}


But the BEGIN construct was added in perl 5, so that won't help. (If
you only need to differentiate between different versions of perl 5,
then all you need to say "require 5.004"

The only thing that I can think of is to wrap the script in an eval.

die "$0 error: needs perl v. 5 or better, aborting.\n" unless $] < 5.0;
eval <<THIS_SCRIPT_NEEDS_PERL_5;
# the script goes here.
THIS_SCRIPT_NEEDS_PERL_5



-- 
Andrew Langmead


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

Date: 26 Nov 1997 20:00:22 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Finding the longest common prefix over a list of strings
Message-Id: <65hv4m$a83@eccws1.dearborn.ford.com>

abigail@fnx.com (Abigail) writes:
> Ken Fox (fox@pt0204.pto.ford.com) wrote:
> ++ ... it has run-time T(k*N+f) where N is the number of words in the
> ++ input, k is the length of the common prefix, and f is the number of
> ++ false prefix matches that are tested (f < N).
> 
> I'm not familiar with big-T. Or is that T as in Theta?

I was taught that big-T is simply used to denote theoretical actual
run time, i.e. the sum of all operations an algorithm performs.  (My
algorithm analysis coursework was only a portion of a data structures
class I took a *long* time ago.  I'm probably messing up notation as
it is taught now.  Sorry.)

> ++ So regex is linear in N, but geometric in k.  If we know that the common
> ++ prefix is short, then it's probably ok to use it.  (Keep in mind that
> 
> No, no, no. My k isn't the length of the common prefix, my k is the
> length of the longest word. The regex is quadratic in the word *length*,
> regardless of the length of the common prefix.

I think this algorithm is equivalent to the regex:

  PREFIX: for (i = length(word[0]); i >= 0; --i) {
    prefix = substr(word[0], 0, i)
    for (j = 1; j < N; ++j) {
      if (prefix ne substr(word[j], 0, i)) {
        next PREFIX;
      }
    }
    last;
  }

It looks like this algorithm will scan the input at most length(word[0])
times.  Each scan of a word does at most length(word[0]) work.  So I
agree with you that the regex is quadratic in (the first) word length,
iff the input is pathological.  I think in actual practice the average
run times will be linear (or nearly linear), but proving the average
case performance is beyond my ability.  This seems like the same problem
QuickSort has -- quadratic worst case performance but very good average
performance.

The regex solution can also be made more stable by putting the
shortest word at the head of the array.  This can be done in linear
time.

> Well, if you want to see k as a constant, then certainly all the
> mentioned algorithms are linear.

You're right, I'm not sure what I was thinking...  Maybe I wasn't
thinking.  ;)

> For both my solution and the regex solution, the worst case situation
> depends on the order of the words; you reach the regex worst case
> if the first cN words share a prefix of dk length. (N the number of
> words, k the maximum length of the words, c, d constants > 0).
> 
> Your solution if fairly independent of the order of the words.

Agreed.

> ++ Abigail's algorithm is superior to the regex from a theoretical view,
> ++ but it fails miserably.  Why?  Because Big-O notation ignores
> ++ computational "constants" and "implementation details".  :-)  Perl is
> ++ *much* faster at regex execution than it is at "normal" code execution.
> ++ The total work done in opcode dispatch, argument passing, etc. for
> ++ Abigail's optimized solution exceeds the regex execution, even though
> ++ the regex has poorer performance bounds.
> 
> Not so fast. If you don't take word lengths/prefix lengths into account,
> the constant that disappears in the big-O *will* depend on the maximum
> word length. For Ilya's, yours and mine, that constant is linear on the
> maximum word length. For the regex solution, that constant is quadratic
> in the maximum word length.

I'm only saying that the regex (with modern perl on a modern OS on a
modern machine when given normal input) outperforms your algorithm by
a large margin.  How could that be when analysis clearly indicates
regex to be the worst performer?  Why don't *you* explain?  ;)

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 26 Nov 1997 14:59:58 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: For the pro's ? repost: Leaving HTML tags alone
Message-Id: <65i2ke$94a@shoga.wwa.com>

noemail@use.net writes:
>I want to replace the text in a HTML document...
>but i don't want to change the HTML code...

Embarrassing but true -- here is approximately what I would do:

1. Download striphtml from "Tom's Kickass Scripts":

<http://www.perl.org/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz>

2. Take the first two patterns in it (comments and tags), stick a
   "|" between them and parentheses around them, split the HTML on
   the pattern, apply your substitution to every even-indexed element,
   join 'em up with "".

Note: I haven't tested this.



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

Date: Wed, 26 Nov 1997 16:03:30 -0600
From: dwexler@zeusnet.com
Subject: form results to both email and text file
Message-Id: <880580529.28323@dejanews.com>

I am looking for a script that can send form results to both a comma
delimited text file and to an email address.  This is for a UNIX server.
Any suggestions?

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


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

Date: 26 Nov 1997 20:23:34 GMT
From: kehoe@fc.hp.com (Jeff Kehoe)
Subject: getopts on NT?
Message-Id: <65i0g6$o3f@fcnews.fc.hp.com>

Is there something special I need to do to use getopts() for perl on NT?

I tried the following on Unix & the command line argument (-h) is found.
On NT ARGV seems to be null/empty.

#!C:\mksnt\perl

use Getopt::Std;

getopts('h');
if($opt_h) {
  print("Found the h...\n");
}
else {
  print("Didn't find the h...\n");
}


Thanks in advance for the help,
Jeff Kehoe


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

Date: Wed, 26 Nov 1997 13:13:04 -0800
From: Lokisdog <see.my.sig@nospam.com>
Subject: Re: getopts on NT?
Message-Id: <347C90E0.27B8@nospam.com>

Jeff Kehoe wrote:
> 
> Is there something special I need to do to use getopts() for perl on NT?
> 

< snipped>

This works on NT:

++++++++++++++  Start Code Snippet  ++++++++++++++

require "getopt.pl" || die "No getopt.pl";

# =============> Extract the command line switch arguments

&Getopt (se);
   
$start = $opt_s;     
$end = $opt_e;       
 
# ============> Print them out to test

print "Start is $start\n";
print "End is $end\n";

+++++++++++++++++++  End Code Snippet +++++++++++++++


The output looks like this:

D:\PerlScripts>opts.pl -s dog -e cat
Start is dog
End is cat


_______________________________

Eric Arnold                     earnold@hitech.eds.com
Information Systems Engineer    408.524.2844
EDS/Philips, Sunnyvale


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

Date: Wed, 26 Nov 1997 13:11:36 -0600
From: randy.paries@avex.com
Subject: Got to be a cleaner Way
Message-Id: <880571349.16963@dejanews.com>

Hello ,
I have a string that looks like
-rw-r--r--   1 2300     2300        1658 Oct 14 06:00 interse_log.971014

I want to do a @f = split / /g,$str

the problem is that I have multiple spaces @ a time, and it is unknow how
many there may be.

So I have to do $str =~ s/  / /g; but I have to do it four times in a row
to get the ones that have a bunch of spaces.

Theres got to be a clean way to do this.

Thanks

randy paries

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


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

Date: 26 Nov 1997 14:08:23 -0600
From: jima@REMOVE.ME.mcs.com (Jim Allenspach)
Subject: Re: Got to be a cleaner Way
Message-Id: <65hvjn$68h$1@Venus.mcs.net>


>Theres got to be a clean way to do this.

	There is. A small modification to the search pattern:

	@f = split(/\s+/,$str);  # split on multiple whitespace chars

	Hope this helps.
jma

--
Jim Allenspach                          jima at mcs dot com
http://www.streams.com/                Streams Online Media Development
Danger is my beer                       Chicago, IL
telnet://wayga.ratatosk.org:9999       Y I 0A .... 


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

Date: Wed, 26 Nov 1997 15:27:31 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Got to be a cleaner Way
Message-Id: <347C8633.6363C9E9@infi.net>

Jim Allenspach wrote:
> 
> >Theres got to be a clean way to do this.
> 
>         There is. A small modification to the search pattern:
> 
>         @f = split(/\s+/,$str);  # split on multiple whitespace chars
> 
>         Hope this helps.
> jma

I always like to use ' ' instead of /\s+/ as in
@f = split(' ',$str);
That way if $str has leading whitespace in it, I won't get a null first
field in my array.  

' ' is a special case to split.  Check the perlfunc man page for
details.

Just an idea. =)

Hope it helps,
  Ty

+---+
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78  B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------


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

Date: Wed, 26 Nov 1997 19:54:01 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Got to be a cleaner Way
Message-Id: <347C7E59.9B2@world.northgrum.com>

randy.paries@avex.com wrote:
> 
> Hello ,
> I have a string that looks like
> -rw-r--r--   1 2300     2300        1658 Oct 14 06:00 interse_log.971014
> 
> I want to do a @f = split / /g,$str
> 
Although what you did with / /g doesn't generate a diagnostic,
it does look a little strange.  What you want is a regular expression
(between the slashes) that describes those multiple spaces.  So try

@f = split / +/, $str;

-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: Wed, 26 Nov 1997 15:20:21 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Got to be a cleaner Way
Message-Id: <-2611971520210001@aggie.coaps.fsu.edu>

In article <880571349.16963@dejanews.com>, randy.paries@avex.com wrote:

+ Hello ,
+ I have a string that looks like
+ -rw-r--r--   1 2300     2300        1658 Oct 14 06:00 interse_log.971014
+ 
+ I want to do a @f = split / /g,$str

+ Theres got to be a clean way to do this.

Indeed, there is.

 use File::Listing;
 for (parse_dir(`ls -l`)) {
     ($name, $type, $size, $mtime, $mode) = @$_;
     next if $type ne 'f'; # plain file
     #...
 }

I believe that's what you want...

James

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Wed, 26 Nov 1997 15:32:20 -0500
From: Dan Boorstein <dboorstein@ixl.com>
Subject: Re: Got to be a cleaner Way
Message-Id: <347C8754.2E0ADF1A@ixl.com>

Jim Allenspach wrote:
> 
> >Theres got to be a clean way to do this.
> 
>         There is. A small modification to the search pattern:
> 
>         @f = split(/\s+/,$str);  # split on multiple whitespace chars
> 
>         Hope this helps.

and if you can cram $str into $_ (not too hard usually), then you can
simply use:

 @f = split;  # splits $_ on whitespace

dan boorstein


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

Date: Wed, 26 Nov 1997 21:28:48 -0800
From: Jan Krynicky <jan.krynicky@st.mff.cuni.cz>
To: Kostas Vlassis <lonewolf@compulink.gr>
Subject: Re: MailTools problems
Message-Id: <347D0510.624D@st.mff.cuni.cz>

Kostas Vlassis wrote:
> 
>     Well I tried to use perl with the Send module as described in the
> book
> "Web Programming with Perl 5" and the latest MailTools package I got
> from my closest cpan mirror, it was 1.X and installed it succesfully,
> I think....
> 
>     The book gives the following listing that does not seem to work:
> 
> use Mail::Send
> 
> $msg = new Mail::Send
> $msg->from($info{'email'});
> $msg->to("myself@some.com");
> $msg->subject("Sample mail");
> print $fh "This is a sample mail line 1.\n";
> print $fh "This is a sample mail line 2.\n";
> $msg->close();
> 
>     The to email I get from a form... Any ideas why I never get any mail
> ?
> 
>     Thanks in advance,
>                     Kostas Vlassis (lonewolf@compulink.gr)

Probably because you are misusing the module, or maybe
something failed and you didn't notice.

Anyway, what should the $fh mean, how is it connected to the mail
message?
Didn't you omit something like
$fh=$msg->socket();   
?

Try to add a few checks !!!

And reread the docs.

Jenda

BTW, I do not know this module, but I'd expect something like
$msg=new Mail::Send("mail.server.com");
or maybe
$msg->smtp("mail.server.com");


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

Date: Wed, 26 Nov 1997 19:13:34 GMT
From: Cindy Wong <ckpwong@undergrad.math.uwaterloo.ca>
To: "Jeremy D. Zawodny" <jzawodn@wcnet.org>
Subject: Re: Net::FTP docs ?
Message-Id: <Pine.SUN.3.95q.971126141133.27207E-100000@napier.uwaterloo.ca>

> >Hi,
> >
> >Does anybody know where I can get some documentation for net::FTP
> >
> >or better still could you tell me how to check a Transfer has got to
> >it's destination?
> 
> The docs are included, aren't they?

Do a "perldoc Net::FTP" for docs.  Most docs of the modules are embedded
in the module itself in pod format.

Regards,
Cindy



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

Date: Wed, 26 Nov 1997 14:06:33 -0500
From: Patrick McGovern <pmcgovern@sherikon.com>
Subject: Re: Newbie question.   Do you recommend moving from C?
Message-Id: <347C7339.DC9150F3@sherikon.com>

This is a multi-part message in MIME format.
--------------76E595FB51794CF45F4D1A17
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Would you use a hammer to insert a screw? Use the right tool for the
right job....C is compact when it's assembled linked....Visual Basic has
to generate from some algorithm all the code that it takes to make a
string class. Comparing C to Visual Basic is comparing apples to
spaceships.

Programming wrote:

> I have been experiencing
> "the joy of C" the past few months.
>
> My big complaint of using c is
> that it has no string type.
> This also involves memory, pointers,
> syntax, etc.  Massive learning curve.
>
> So, what would be 2 statements in say Visual Basic,
>
> dim ls_temp as string
> ls_temp = "testing"
>
> becomes many statements in c.
>
> int     li_temp;        /* local integer */
> char    *ls_temp;
>
> li_temp = strlen("testing");
> ls_temp = (char *) malloc( ( li_temp + 1) );
>
> /* if statements to check if malloc worked. */
>
> /* And finally, functions to copy the string to the
> pointer, and to null terminate it. (if I don't
> null terminate, I usually get problems )
> */
>
> strncpy (ls_temp, "testing", li_temp );
> strncpy (&ls_temp[li_temp], "\0",  1);
>
> Yet, the supposed advantage of C is that it is,
> get this, compact!   Imagine Oracle making
> a database, that would have no string field.
> You could have date fields, integers, reals,
> boolean, individual characters,
> but no string fields.  Get real!
>
> I have heard that both Java, and Perl have
> string types.
>
> Does anyone have any experience moving from
> C to either of these two languages on AIX.
> What have your experiences been?  Would
> you recommend it, or just stick with C?
>
> What I am concerned with is:
> - software/code that is reliable!
> - relatively short learning curves.
> - simple business that is simple, not complicated
> (ie. assign the string to the variable)
> - what works one year, will work 10 years from now
> (no frequent upgrades and code changes required)
> - compilers that give meaningful error messages
> - code interfaces easily with Oracle, and can do
> embedded SQL.
>
> I am looking at this from a manager's standpoint.
> Can we use the language as a reliable tool that
> will do what we expect a language to do for us?
> That is, in creating and writing full blown
> business applications.
>
> Another question would be, are there any special
> considerations that need to be taken into
> account when using either of these languages?
> Special compilers, etc.
>
> All comments welcome.
>
> Regards,
>
> Rodger



--------------76E595FB51794CF45F4D1A17
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick McGovern
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Patrick McGovern
n:              McGovern;Patrick
org:            SHERIKON, Inc
email;internet: pmcgovern@sherikon.com
title:          Technical Manager - Web Technologies
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------76E595FB51794CF45F4D1A17--



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

Date: 26 Nov 1997 20:11:30 GMT
From: turnerj@cliffy.lmtas.lmco.com (Jim Turner )
Subject: Re: Newbie question.   Do you recommend moving from C?
Message-Id: <65hvpi$p911@quest.lmtas.lmco.com>

Programming (sysdev@mb.sympatico.ca) wrote:
: I have been experiencing 
: "the joy of C" the past few months. 
: 
: My big complaint of using c is
: that it has no string type. 
: This also involves memory, pointers,
: syntax, etc.  Massive learning curve. 
: 
: So, what would be 2 statements in say Visual Basic, 
: 
: dim ls_temp as string
: ls_temp = "testing"
: 
: becomes many statements in c.
: 
: 
: 
: int	li_temp;	/* local integer */ 
: char 	*ls_temp;
: 
: li_temp = strlen("testing"); 
: ls_temp = (char *) malloc( ( li_temp + 1) );
: 
: /* if statements to check if malloc worked. */
: 
: /* And finally, functions to copy the string to the
: pointer, and to null terminate it. (if I don't 
: null terminate, I usually get problems )
: */
: 
: strncpy (ls_temp, "testing", li_temp ); 
: strncpy (&ls_temp[li_temp], "\0",  1); 
: 
: 
: Yet, the supposed advantage of C is that it is, 
: get this, compact!   Imagine Oracle making 
: a database, that would have no string field. 
: You could have date fields, integers, reals, 
: boolean, individual characters, 
: but no string fields.  Get real! 
: 
: 
: I have heard that both Java, and Perl have 
: string types.  
: 
: Does anyone have any experience moving from
: C to either of these two languages on AIX.
: What have your experiences been?  Would
: you recommend it, or just stick with C?
: 
: 
: What I am concerned with is:
: - software/code that is reliable! 
: - relatively short learning curves. 
: - simple business that is simple, not complicated 
: (ie. assign the string to the variable) 
: - what works one year, will work 10 years from now
: (no frequent upgrades and code changes required)
: - compilers that give meaningful error messages
: - code interfaces easily with Oracle, and can do
: embedded SQL.
: 
: 
: I am looking at this from a manager's standpoint.
: Can we use the language as a reliable tool that 
: will do what we expect a language to do for us?  
: That is, in creating and writing full blown 
: business applications.
: 
: Another question would be, are there any special 
: considerations that need to be taken into 
: account when using either of these languages?
: Special compilers, etc.
: 
: All comments welcome.
: 
: 
: Regards,
: 
: Rodger

	I used to program mostly in C, now I program almost exclusively in 
Perl.
I Love it.  Anything I want to program, I can now do much easier in Perl with
much fewer bugs and hassles and in much less time!  I have looked at Java and
it appears to have a learning curve similar to C (you have to learn a lot of
classes, etc.) and I still can't get any graphics on my webpages to print :-(
So, I think I will stick with Perl, and would recommend the same to you, 
except I don't need any more competition ;-)

Enjoy the Ride!!!!


Jim Turner



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

Date: 26 Nov 1997 20:48:40 GMT
From: Roedy Green <roedy@BIX.com>
Subject: Re: Newbie question. Do you recommend moving from C?
Message-Id: <65i1v8$m22@lotho.delphi.com>

Programming wrote:
>What I am concerned with is:
>- software/code that is reliable! 
>- relatively short learning curves. 
>- simple business that is simple, not complicated 
>(ie. assign the string to the variable) 
>- what works one year, will work 10 years from now
>(no frequent upgrades and code changes required)
>- compilers that give meaningful error messages
>- code interfaces easily with Oracle, and can do
>embedded SQL.

YOUR code will have fewer bugs that with C.  I can't say the same about the
libraries.

Coding is simpler, mainly because Java handles memory management automatically.

The class libararies are complicated, but not as complicated as the ones
for say pure Windows development.

Java just went through a major set of changes from JDK 1.0 to 1.1.  The
language itself did not change much, but the whole event handling model
changed.  Java is still in flux.  I expect SQL interfaces to change
drastically. The current JDBC and JSQL are beyond awful.  Symantec has a
proprietary one that is beginning to look reasonable.

Check the Java glossary under Gotchas. It has a section on decoding
compiler error messages.  Like C, Java makes extensive use of () and {}
which mean compilers get hopelessly confused when they don't balance.

If you have used Pascal, Java FEELS more like Pascal than C, even though it
looks almost identical to C++.  Java mothers you. It won't let you cheat.

Roedy Green               Roedy rhymes with Cody   roedy@bix.com ICQ:5144242
Canadian Mind Products    contract programming     (250) 285-2954
POB 707 Quathiaski Cove   Quadra Island BC         Canada V0P 1N0 
http://oberon.ark.com/~roedy for CMP utilities and the Java glossary
-30-


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

Date: Wed, 26 Nov 1997 22:14:41 -0800
From: Jan Krynicky <jan.krynicky@st.mff.cuni.cz>
To: andrewe@technologyXchange.com
Subject: Re: open(), seek() and email monitoring
Message-Id: <347D0FD1.12BD@st.mff.cuni.cz>

Andrew Ellerton wrote:
> 
> Neil Briscoe wrote:
> >
> > In article <3475561B.F18CBAC7@technologyXchange.com>,
> > andrewe@technologyXchange.com (Andrew Ellerton) wrote:
> >
> > > Hi all,
> > >
> > > I'm trying to write some code to monitor email spool files and do
> > > anything once new email is received.
> > >
> > > Although the approach may be wrong, I'm presently trying this code
> > > virtually straight out of Programming Perl:
> > >
> > > for (;;) {
> > >         while (<SPOOL>) {
> > >
> > >                 process_in_whatever_way();
> > >         }
> > >         sleep $for_a_while;
> > >         seek SPOOL, 0, 1; # reset end-of-file error
> > > }
> > >
> > > Is the sleep-then-seek method a reasonable way to handle this? If anyone
> > > has any suggestions on an alternative, and/or the use of Mail::Header to
> > > extract header information, I'd be most thankful.
> > >
> <snipped>
> 
> Very good point. The reason I thought a forever loop would be
> appropriate is becuase the "answering machine" type applications (like
> this is sort-of intended to be) seem to reply very quickly, as if
> they're constantly monitoring the stream.
> 
> I agree though - calling the program by cron/at would certainly be much
> simpler than my current approach!
> 
> I had thought of emulating the behaviour of tail -f. What do you think
> of that idea? Aside from the cron-style scheduling of a process, is it
> possible (or wise?) to block on further input into the file, tail -f
> appears to?
> 
> I've also noticed that tail -f will note when the file has become
> shorter (e.g. the user downloaded their mail) by saying "input has been
> truncated"; yet I haven't been able to emulate this in perl yet. Any
> ideas?
> 
> Thanks again; any help is most appreciated.
> 
> Regards,
> Andrew

I think this is awrong approach (at least on unix).
Look at
	$ man forward
through this you may forward the incoming mail into your program.


Create a file .forward in your home directory containing
something like

	| /home/myself/the-script
	\myself

Now every time you get a new email, it is 
 1. stored in your mailbox
 2. passed to a new instance of the script as the standard input

! The script gets invoked again for each new mail !
! It processes only one email message !

If you want to delete some incoming messages you may consider
forwarding them only to the script and adding the data
to the spool by the script.

Do not forget to flock files, a new email may come before you had time
to process
some other.


Jenda


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

Date: 26 Nov 1997 19:21:12 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: OS/2: s/// statement still crashing
Message-Id: <65hsr8$cp7$1@agate.berkeley.edu>

X-Newsreader: TRN for OS/2
Cc: 

In article <347BF94A.5B9E@bigfoot.com>, Koos Pol  <koos_pol@bigfoot.com> wrote:
> $string  = 'a' x 1000;
>  $search  = 'b' x 1000;
>  $replace = 'c' x 1000;
>  $string  =~ s/$search/$replace/;
> 
> This script still crashes and dumps core. I used the default directories
> suggested by the installer. 

If you would read what I wrote the previous time, you would not need
to try this.  This bug is corrected in (lemme see... aha) Jumbo malloc
patch version 3.  The OS/2 binary was built with jumbo malloc patch
version 1.

If you want to rebuild, keep in mind that 5.004_54 needs a tiny patch:

--- perl.h      Thu Nov 13 06:13:44 1997
+++ perl.h.good Fri Nov 14 17:52:12 1997
@@ -116,7 +116,7 @@ register struct op *op asm(stringify(OP_
 # define STANDARD_C 1
 #endif

-#if defined(__cplusplus) || defined(WIN32)
+#if defined(__cplusplus) || defined(WIN32) || defined(OS2)
 # define DONT_DECLARE_STD 1
 #endif

Hope this helps,
Ilya


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

Date: Wed, 26 Nov 1997 16:59:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PERL Hourly Rates
Message-Id: <65i5mq$dbd@bgtnsc03.worldnet.att.net>

In article <toutatis-ya023180002611971227330001@news.euro.net>,
toutatis@no.mail.please (Toutatis) wrote:

> comdog@computerdog.com (brian d foy) wrote:
> 
> > toutatis@no.mail.please (Toutatis) wrote:
> > 
> > > Oh, by the way, there's a bug in your cgi program
> > > http://computerdog.com/Cgi/demo/wrap.cgi
> > > check your error log for a 500 response ;-)
> > 
> > i couldn't reproduce any error.  if you would like to submit a more helpful
> > bug report, please do so privately.  this sort of thing is not germaine to
> > the discussion.  i would respond in email but you've munged your address.
> 
> Thank you for perfectly illustrating my point. CGI scripting is _not_ as
> trivial as you're suggesting. The fact that you probably relied too much on
> Text::Wrap (with a die statement where it'd better not be) is foregivable.
> That you didn't test every condition under wich your script is used is
> somewhat understandable. You're a busy man. The fact you need additional
> information from me to reproduce the error leads me to believe you didn't
> properly configure your scripts 

the fact that i didn't reproduce any error is probably because i don't
know what you did to break it.  my guess would be that you gave it input
with greater than 80 consecutive characters without whitespace, which
in some versions of Text::Wrap causes a fatal error.  however, the 
reliance of any script on non-CGI modules has no relevance on the
complexity of CGI, and neither do any of the quick hacks that i offer
publically.  

however, you will have to go farther to illustrate your point.  i've
learned to always try to get as much information about the problem
before i start checking everything - i save quite a bit of time this
way.  any smart technical support person would do the same.  

if you want to support your point, as many others have done, you'll
need to lay aside the ad hominem attacks and outstanding example
tactics, both of which prove nothing.

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: Wed, 26 Nov 1997 16:28:07 -0500
From: Denis Haskin <denis_haskin@iacnet.com>
To: gsar@umich.edu
Subject: Perl on Win32: Output file redirection clobbers file?
Message-Id: <347C9466.BC792FE@iacnet.com>

Is this a known problem, and is it with perl or possibly the NT command
interpreter?

I just grabbed the binary of Gurusamy's perl5_00402-bindist04-bc.zip and
installed it on my NT workstation 4.0 system (Intel) (-V output attached
below).  It's working fine except command-line redirection when the
input and output file are the same isn't working, even with the -i
switch, and even with the -i switch with an extension (-i.bak).

Is this a known problem?  It's mentioned briefly in one of the FAQs but
there doesn't seem to be any indication that -i shouldn't work.  This is
a little new to me, although I've been using Perl on VMS for years
(where they have file versions... <grin>).

Thanks for any suggestions...

dwh

--- perl -V output ---

C:\vss\hits\spec>perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 02) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32
    uname=''
    hint=recommended, useposix=true, d_sigaction=undef
    bincompat3=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cl', optimize='-O', gccversion=
    cppflags='-DWIN32'
    ccflags ='-MD -DWIN32'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=n, randbits=15
  Linker and Libraries:
    ld='link', ldflags ='-nologo -subsystem:windows'
    libpth=c:\program files\devstudio\vc\lib
    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.li
b advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib
wsock32.
lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
    libc=msvcrt.lib, so=dll
    useshrplib=undef, libperl=undef
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='', lddlflags='-dll'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING
  Built under MSWin32
  Compiled at Aug  9 1997 21:42:37
  @INC:
    c:\perl\lib\site
    c:\perl\lib
    c:\perl\lib
    c:\perl\lib\site
    c:\perl\lib\site
    .




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

Date: Wed, 26 Nov 1997 13:36:36 -0700
From: Scott McGee <ScottMcGee@cyber-wizard.com>
Subject: readdir() and Win32 Perl
Message-Id: <347C8854.F28B8E03@cyber-wizard.com>

Hi all,

I have looked in the FAQ's and checked over the messages here, and 
don't see an answer to a problem I am having.

I am used to working in a UNIX (normally Solaris 2.4) environment, but
have just installed the Win32 version of Perl on my Win 95 box and
gotten it working with CGI and my Personal Web Server. One script I
wanted to use reads a directory and manipulates the filenames it finds.
The code, which works fine on Solaris 2.4 but not at all one Win 32
looks something like this:

opendir(DIR, "$dirpath\\$dirname") || print "Cannot open $dirname\n";
@files = grep(!/^\.\.?$/, readdir(DIR));
closedir(DIR);

while (<@files>) {
   print "$_ \n";
}

If I run this on the sun box, I get a directory listing. On Win32, I 
get nothing. If I insert a
  print @files;
line before the while loop, it will print a long string of all the 
files in the directory concatenated together, but the loop always 
fails to output anything.

Can anyone help here?

What I am trying to do is use a CGI script to generate a web page
containing all the files in a directory, and do some stuff like showing
smaller images with <IMG> tags as well as links, larger images as links
with size info, show subdirs as folders with links, and so one. What I
really need, though, is some help figuring out the directory list stuff
above. Am I using some lame method that has inherent problems, making
some newbie mistake, or what?

Thanks

Scott
--
Scott McGee: Salt Lake Community College Webmaster  | When in danger,
____________________________________________________| or in doubt,
Email: ScottMcGee@cyber-wizard.com (Scott McGee)    | run in circles,
Web: http://www.genealogy.org/~smcgee/homepage.html | scream and shout.
----------------------------------------------------------------------
My opinions do not necessarily reflect those of the College. Trust me!




-- 
When in danger,    |   If it has my name on it, it must be MY opinion!
or in doubt,       |____________________________________________________
run in circles,    | Email: ScottMcGee@cyber-wizard.com (Scott McGee)
scream and shout!  | Web: http://www.genealogy.org/~smcgee/homepage.html


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

Date: Wed, 26 Nov 1997 21:53:35 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Removing HTML tag
Message-Id: <347e99ed.14068873@news.wwa.com>

ryujiy@aol.com (Ryujiy) writes:

> I am new to Perl and have been working on a simple search engine as
> my practice.  However, I got a problem which is following After the
> target sentence is found, how can I remove HTML tag.  For instance,
> if I got following string, I only want to display "Some sentence".
> I can easily remove "</A>" using chop() function, but I cannot
> figure out the way to remove "<A NAME ="label"> part.  Is there any
> function to remove front part of character or Is there any good way
> to do this?
>  <A NAME="label">Some sentence.</A>

stephen farrell <sfarrell+usenet@farrell.org> replies:

>I imagine something like s/<.*>//gs would be a good first
>approximation at what you want...

Here is what the FAQ has to say:

:How do I remove HTML from a string? 
:
:The most correct way (albeit not the fastest) is to use HTML::Parse from CPAN (part of the libwww-perl distribution, which is a
:must-have module for all web hackers). 
:
:Many folks attempt a simple-minded regular expression approach, like s/<.*?>//g, but that fails in many cases because the tags
:may continue over line breaks, they may contain quoted angle-brackets, or HTML comment may be present. Plus folks forget to
:convert entities, like < for example. 
:
:Here's one ``simple-minded'' approach, that works for most files: 
:
:    #!/usr/bin/perl -p0777
:    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
:
:If you want a more complete solution, see the 3-stage striphtml program in
:http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz . 

You might also think about looking at the HTML::Parse module
distributed with libwww.  You can get it at a CPAN
(http://www.perl.com/CPAN) near you.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"For what had embittered him Fitz had no name.  Yet he knew that every
daybreak duped him into waking and every evening conned him into
sleep.  The feeling of having been cheated - of having been cheated -
that was it.  Nobody knew why nor by whom." -- Nelson Algren, _A Walk
on the Wild Side_ 


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

Date: Wed, 26 Nov 1997 15:32:21 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Strange 'print Location:' problem with Perl
Message-Id: <alecler-2611971532210001@dynppp-47.hip.cam.org>

In article <65fs8b$8hs$1@nntp2.ba.best.com>, "Tim Gilman"
<tdgilman@DELETETHISbest.com> wrote:

[...]
> This works fine:
> 
> print("Location: sib97181.pdf\n\n");
> 
> However, this doesn't work (it just shows a blank page in the target frame):
> 
> $article = $in{'ArticleList'};
> print "Location: $article\n\n";


Hm. Not an expert, but... I think it is a string concatenation syntax
error (look out for the dots -- and also the parentheses are missing):

print("Location: ".$article."\n\n");

Regards,
Andre


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

Date: 26 Nov 1997 18:46:37 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: strange problem with regular expression memory variables
Message-Id: <65hqqd$hpl$5@daily.bbnplanet.com>

John Rodkey (rodkey@citation.uptimecorp.com) wrote:
: I'm new to perl, so beat me softly, OK?
: Yes, I've looked at the man pages (perlre, perlop)
: and the FAQ.    But no reference to ...

: Regular expression matching from variables and 
: referencing RE memory variables indirectly.  to wit:

: I have need to store a regular expression in a variable,
: and then assign another variable the memory variable
: which must be determined based on yet another variable.
: Here's the code I'm attempting...

: #!/usr/local/bin/perl -w
: # match one or more digits surrounded by non-digits
: $RE = "m@\\D+(\\d+).*@" ;

this line should be $RE = "\\D+(\\d+).*" ;

: $_ = "Our 923 number in the middle of a String";
: $N = '$1';

: if ( $_=~$RE ) {

and this should be  if ( $_=~ /$RE/ ) {

Jason Gloudon


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

Date: 26 Nov 1997 15:51:59 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Text Matching
Message-Id: <lq1en43z8cw.fsf@bmers2e5.nortel.ca>

Brian <nyc-guy@ix.netcom.com> writes:
> I am trying to chop up a like of text that looks like :
> ABC "XXXXX" GHI
> 
> I want to do a search on the line of text and store the data
> between the two quotes into a variable.  Any help on
> how to do this would be extremely helpful.

There is actually a farely nice perl module called Text::ParseWords. (It comes
with perl now) Here's a sample usage:

       use Text::ParseWords;

       $a = q(ABC "XXXXX" GHI 'JKL');
       @words = quotewords('\s+', 0, $a);
       print join(" : ", @words), "\n";

And the output would be:

       ABC : XXXXX : GHI : JKL

hoping this helps,
mark



--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 26 Nov 1997 14:32:05 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: Text Matching
Message-Id: <65i105$37h@shoga.wwa.com>

rootbeer@teleport.com writes:
>On Wed, 26 Nov 1997, Brian wrote:
>
>> I am trying to chop up a like of text that looks like :
>> ABC "XXXXX" GHI
>> 
>> I want to do a search on the line of text and store the data
>> between the two quotes into a variable.  Any help on
>> how to do this would be extremely helpful.
>
>I recommend that you use Perl to do this. Its pattern matching abilities
>should make this easy. If you get stuck, let us know how far you've
>gotten. Good luck! 

There's another theory which says this has already happened.

He was recommended Perl for its pattern matching abilities, he tried
to use it, he was stuck and was letting us know how far he had gotten.
Furthermore, he has had good luck and is in possession of the solution.



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

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

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