[7926] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1551 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 30 13:17:34 1997

Date: Tue, 30 Dec 97 10:00:23 -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           Tue, 30 Dec 1997     Volume: 8 Number: 1551

Today's topics:
     Re: [Q ] What is wrong with @INC ????  Help please! (Mike Stok)
     better foreach? (WOLtetch)
     Re: better foreach? (Jeremy D. Zawodny)
     Re: CGI: system "cat... <merlyn@stonehenge.com>
     Re: chomp ($&) to remove specific \n (Tad McClellan)
     Re: creating subclasses / HTML::Parser <merlyn@stonehenge.com>
     Re: creating subclasses / HTML::Parser <jdporter@min.net>
     Effective Perl Contest... word game.  (Martin D Schweitzer)
     Re: Faster way of calculating sum of absolute values? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     help compiling dynamic perl5_04 on hpux <mpchandler@mema.mail.fedex.com>
     Re: Help:  uniq utility (Chris Nandor)
     Is Serial I/O possible in PERL? (Arlen Fletcher)
     LWP SSL POST requests <chris@ixlabs.com>
     Re: need URL parsing help (brian d foy)
     Re: Passing shell objects as arguments to perl scripts (Harry Mills)
     Re: perl <STDOUT> to gnuplot <STDIN> (Tad McClellan)
     Re: PERL URL-Encoding <merlyn@stonehenge.com>
     SHELL/REGEX GUNSLINGERS NEEDED!!! Rholder@sispost1.bis.adp.com
     Re: Which language pays most 17457 -- C++ vs. Java? <jarvisbob@timken.com>
     Re: Which language pays most? Smalltalk, not C++ nor Ja (Billy Chambless)
     Re: Which language pays most? Smalltalk, not C++ nor Ja (Billy Chambless)
     Re: Which language pays most? Smalltalk, not C++ nor Ja <templon@studbolt.physast.uga.edu>
     Re: Which language pays most? Smalltalk, not C++ nor Ja <pats@acm.org>
     word wrap routine <jcotton@erols.com>
     Re: word wrap routine (Mike Stok)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 30 Dec 1997 08:16:57 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: [Q ] What is wrong with @INC ????  Help please!
Message-Id: <68as89$jc$1@stok.co.uk>

In article <34a81abe.263310@news>,
Augusto Cardoso <cardoso.a@mail.telepac.pt> wrote:
>when I try to run Perl programs I get a message stating that PM files
>can not be found.
>@INC is displayed and it refers to the right LIB...
>Here is the error message:
>
>Can't locate Pod/Text.pm in @INC <@INC contains:
>c:/perl/lib/os2/5.00455 c:/perl/lib c:/perl/lib/site_perl/os2
>c:/perl/lib/site_perl .> at c:\perl\bin/pod2text.cmd line 6.
>
>File Text.pm is located in c:\perl\lib
>Would appreciate any good suggestions

It's probably looking for

  c:/perl/lib/os2/5.00455/Pod/Text.pm
  c:/perl/lib/Pod/Text.pm
  c:/perl/lib/site_perl/os2/Pod/Text.pm

so the Text.pm in c:\perl\lib could either be an incorrectly installed
Pod::Text or an unrelated module Text - examining the beginning of the
module, in particular the package line will determine what the modulke
thinks it's called.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 30 Dec 1997 16:29:05 GMT
From: woltetch@aol.com (WOLtetch)
Subject: better foreach?
Message-Id: <19971230162901.LAA18263@ladder01.news.aol.com>

Take something like this:

foreach $drop (@water) {
        foreach $bat (@hell)  {
          #do something with $drop and $bat
       }
 }

Is there a way to do this without nesting the foreach loops?
(I take it something like 
foreach ($drop, $bat) (@water, @hell) {
     #do something with $drop and $bat
}

won't work at all).

Thank you.


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

Date: Tue, 30 Dec 1997 17:14:27 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: better foreach?
Message-Id: <34a92b42.514364987@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On 30 Dec 1997 16:29:05 GMT, woltetch@aol.com (WOLtetch) wrote:

>Take something like this:
>
>foreach $drop (@water) {
>        foreach $bat (@hell)  {
>          #do something with $drop and $bat
>       }
> }
>
>Is there a way to do this without nesting the foreach loops?
>(I take it something like 
>foreach ($drop, $bat) (@water, @hell) {
>     #do something with $drop and $bat
>}
>
>won't work at all).

Hm.

Let's assume that @water and @hell both hold 50 elements. How many
times would you expect the loop to execute? It depends on how you'd
expect Perl to iterate over those two lists.

Possible answers:

 - 50
 - 50*50
 - (50*50) - 50

And there are certainly others.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 30 Dec 1997 05:52:14 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "B. Bell" <maximill@u.washington.edu>
Subject: Re: CGI: system "cat...
Message-Id: <8cra6v6lj5.fsf@gadget.cscaper.com>

>>>>> "B" == B Bell <maximill@u.washington.edu> writes:

B> require "cgi-lib.pl";

Bad.  Evil.  Please use CGI.pm, which is included with all modern
versions of Perl.

B> system "cat includeme.html";

For a portable way to do this, use:

	use File::Copy;
	copy "includeme.html", \*STDOUT;

That'll work on Mac and Win32 as well.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 245 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: Tue, 30 Dec 1997 08:53:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: chomp ($&) to remove specific \n
Message-Id: <ks1b86.sn.ln@localhost>

Joe Marler (joema@nospam.microsoft.com) wrote:
: I'm using Perl 5.001 on Win32. I need to strip out selected \n
: characters from a text file using inplace editing, where the \n is
: preceded by a specific match pattern.

: I tried this:

: s/matchpattern.*\n/chomp($&)/egi

[snip]

: This works OK, but I spent a lot of time looking for a syntactically
: simpler method. I've checked the FAQ, various books, dejanews, etc.,
: and was curious if I missed something obvious?


   s/(matchpattern.*)\n/$1/gi;


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


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

Date: 30 Dec 1997 06:03:03 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: tadmc@metronet.com (Tad McClellan)
Subject: Re: creating subclasses / HTML::Parser
Message-Id: <8cius76l14.fsf@gadget.cscaper.com>

>>>>> "Tad" == Tad McClellan <tadmc@metronet.com> writes:

Tad> You make a new package for your derived class (myParser), and
Tad> put the name of the superclass in the package's @ISA:

[example using two files deleted]

You can also do the subclassing all within one program, as I've
illustrated in a few of my WebTechniques columns, archived online at:

	http://www.stonehenge.com/merlyn/WebTechniques/

In particular, use the search engine on that page to look for all
programs matching a regular expression of /\@\S+ISA/.  Works nicely!

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 245 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: Tue, 30 Dec 1997 12:00:28 -0500
From: John Porter <jdporter@min.net>
Subject: Re: creating subclasses / HTML::Parser
Message-Id: <34A928AC.5E44@min.net>

jsd@bud.com wrote:
> 
> so i wrote this script:
> 
> #!/usr/local/bin/perl -w
> 
> require HTML::Parser;
> 
> . . .
> 
> sub comment {
>   print "hi there i'm alive\n";
>   print @_;
> }
> 
> $p = HTML::Parser->new;
> $p->{'comment'} = \&comment;
> $p->parse($html);
> exit;
> 
> but it doesn't do anything.  it never prints "hi there i'm alive" so i'm
> guessing that i'm not properly creating the subclass.  


Dude! Not creating a subclass at all is about as improper as you can
get.
Have you come across @ISA in your man page readings?

To create a subclass of HTML::Parser you can do this:

require HTML::Parser;

package MyParser;              # this will be the derived "class".
  @ISA = qw( HTML::Parser );   # indicate the parent class(es).

  sub comment {  # this definition overrides the one in HTML::Parser.
     . . .
  }

package main;
my $p = new MyParser . . .;



John Porter
jporter@logicon.com


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

Date: Tue, 30 Dec 1997 09:24:24 GMT
From: martin@matilda.vut.edu.au (Martin D Schweitzer)
Subject: Effective Perl Contest... word game. 
Message-Id: <ELzwso.7Fo@matilda.vut.edu.au>

In article <34A76E93.7D05230@5sigma.com> joseph@5sigma.com writes:
>
>This is kind of a fun problem.  I'm thinking of making it the first
>Effective Perl Programming contest problem ....
>

Here is a problem:

I have written a word game.  The user must find all words using
the letters given in a square, e.g:

H A N
D I W
O R K

The computer then generates a list of solutions.  The technique I
am currently using is as follows:

(pseudocode)
$magic = sort "HANDIWORK" ;
foreach word (/usr/dict/words)
{  $current = sort word ;
   $current -> c.*u.*r.*r.*e.*n.*t.* ; # if you get my meaning
   print $word if $magic =~ /$current/ ;
}

Some ideas I have had are to do a grep -v on all letters
that do not appear in the original word.  I am sure that there
are far more efficient ways, though, of finding if a word can
be made from the given letters.  I look forward to seeing
any submissions.

(If you want to try playing the game, my web page is:
 http://dingo.vut.edu.au/~martins )


A
>	-joseph
>	 http://www.effectiveperl.com
>
>use Benchmark;
>$string1="5174";
>$string2="7823";
>
>#your[0] code
>
>timethis(10000,<<'EO1');
>@string1=split //, $string1;
>@string2=split //, $string2;
>$sum=0;
>for ($i=0;$i<$#string1;$i++) {
>        $sum+=abs($string1[$i]-$string2[$i]);
>}
>EO1
>
>#your[1] code
>
>timethis(10000,<<'EO2');
>$sum=0;
>for ($i=0;$i<$#string1;$i++) {
>        $sum+=abs(substr($string1,$i,1)-substr($string2,$i,1));
>}
>EO2
>
>#my code
>timethis(10000, <<'EO3');
>$sum=0;
>my $s = $string1;
>my $i = length $s;
>vec($s, $i, 8) -= vec($string2, $i, 8) while $i--;
>$s =~ tr/\367-\377/\11\10\7\6\5\4\3\2\1/;
>$sum = unpack "%32C*", $s;
>EO3
>
>
>timethis 10000:  6 secs ( 6.54 usr  0.00 sys =  6.54 cpu)
>timethis 10000:  4 secs ( 3.05 usr  0.00 sys =  3.05 cpu)
>timethis 10000:  1 secs ( 1.72 usr  0.00 sys =  1.72 cpu)
>{joseph}:108%


-- 
---------------------------------------------------------------------
Martin Schweitzer
Snipe & Grouse
Footscray, Australia


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

Date: Tue, 30 Dec 97 09:42:57 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Faster way of calculating sum of absolute values?
Message-Id: <34a90964$1$ofn$mr2ice@speaker>

In <ebohlmanELx6yz.AHH@netcom.com>, on 12/28/97 at 10:11 PM,
   Eric Bohlman <ebohlman@netcom.com> said:
+-----
| : Any suggestions of a faster implementation ?
|
| use Benchmark;
| $string1="5174";
| $string2="7823";
|
| #your code
|
| timethis(10000,<<'EO1');
| @string1=split //, $string1;
| @string2=split //, $string2;
| $sum=0;
| for ($i=0;$i<$#string1;$i++) {
| 	$sum+=abs($string1[$i]-$string2[$i]);
| }
| EO1
|
| #my code
|
| timethis(10000,<<'EO2');
| $sum=0;
| for ($i=0;$i<$#string1;$i++) {
| 	$sum+=abs(substr($string1,$i,1)-substr($string2,$i,1));
| }
| EO2
+--->8

# bsa's code

timethis(10000,<<'EO3');
$s1=$string1;
$s2=$string2;
$sum=0;
while ($s1 ne '') {
        $sum+=abs(chop($s1)-chop($s2));
}
EO3

[C:\tmp]perl btst.pl
timethis 10000:  3 secs ( 3.30 usr  0.00 sys =  3.30 cpu)
14
timethis 10000:  2 secs ( 1.51 usr  0.00 sys =  1.51 cpu)
14
timethis 10000:  1 secs ( 1.46 usr  0.00 sys =  1.46 cpu)
15

Notice that I added code to print the sum after running the benchmark... and
that it reveals a fencepost error in *both* previous attempts.  (Hint:  $#xxx
reports the index of the last element of @x, not the number of elements.)

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)



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

Date: Tue, 30 Dec 1997 10:59:37 -0600
From: Michael P Chandler <mpchandler@mema.mail.fedex.com>
Subject: help compiling dynamic perl5_04 on hpux
Message-Id: <34A92878.7A12625C@mema.mail.fedex.com>

I get this error message when trying to 'sh Configure'.....even
if I try to bypass with a -DCC=gcc   (version 2.7.3)

I need to know if there is a patch for cc that I need or an
option that I'm not stating.....for the reasons below....
>[from 'sh Configure']
>
>The bundled C compiler can not produce shared libraries, so you will
>not be able to use dynamic loading.
>

I'm trying to install a dynamic version of perl5.04 so I can
install DBI modules for Informix and Sybase.....(i believe
Informix needs dynamic installation..

Any help gets an 'at-a-boy/girl' and my eternal gratitude!!!

{Background: before I compiled 5.01m using gcc2.7.3.....and
             understood it's nuances....now I'd like to usher my
             wkgrp (for brnypts) into the OOP era using 5.04 and
             the various db_hooks that are now stable[r]}

Mike Chandler
Programmer, FedEx
mpchandler@fedex.com




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

Date: Tue, 30 Dec 1997 11:49:56 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Help:  uniq utility
Message-Id: <pudge-3012971149560001@ppp-44.ts-1.kin.idt.net>

In article <67ugjp$jht@tekka.wwa.com>, scribble@tekka.wwa.com (Tushar
Samant) wrote:

# bholzman@earthlink.net writes:
# >use strict;
# >
# >my %values;
# >
# >map {$values{$_}++} <>;
# >
# >while (my($val, $cnt) = each %values) {
# >  print "$val\n";
# >  # You also get the count of each value in $cnt...
# >}
# 
# But this is very different from what Unix uniq does.
# uniq is much simpler, something like this:
# 
#     #input in @data, output in @uniq --
# 
#     $curr = shift @data;
#     @uniq = ($current);
# 
#     for $line (@data) {
#         if ($line ne $curr) {
#             push @uniq, $line;
#             $curr = $line;
#         }
#     }

uniq assumes a file is in order already.  Speaking of which, I am working
on a File::Sort module which will sort any given file and optionally
remove duplicates in the same manner as above.

I have a bit more work to do on it, and I would not recommend it for
people using Unix anyways, as sort(1) is much faster than this will be. 
:)

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


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

Date: 30 Dec 1997 16:08:32 GMT
From: fletcher@paccar.com (Arlen Fletcher)
Subject: Is Serial I/O possible in PERL?
Message-Id: <68b6a0$8hh@ender.techcenter.paccar.com>


I need to communicate with a weather station via RS232.  I wasn't able to
find any modules on CPAN that fit the bill...  Is serial I/O do-able in 
PERL?

TIA

-- 
Arlen Fletcher 
--Spam Chaff
admin@loopback,$LOGIN@localhost,$LOGNAME@localhost,$USER@localhost,$USER@$HOST,
-h1024@localhost,root@mailloop.com
rhundt@fcc.gov,jquello@fcc.gov,sness@fcc.gov,rchong@fcc.gov,customer@email.usps
 .gov



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

Date: Tue, 30 Dec 1997 07:47:14 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: LWP SSL POST requests
Message-Id: <34A91782.1F14@ixlabs.com>

I recently got all the LWP/SSLeay/SSLeay-Perl stuff working, so I can
now create a secure SSL socket.

Now I need to hand-code a couple of POST requests with a few simple
key-value pairs.

I have not, however, been able to find good documentation about what a
HTTPS POST request looks like (or HTTP POST requests for that matter).

More than reference, I need examples.

If someone could email me a sample HTTPS POST request, or knows a way I
could watch my outgoing requests from a browser (well, they would be
encrypted, that wouldn't work), I would be immensely grateful.

Thanks
Chris


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

Date: Tue, 30 Dec 1997 06:34:37 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: need URL parsing help
Message-Id: <68alrj$3fp@mtinsc05.worldnet.att.net>
Keywords: just another new york perl hacker

In article <34A7DCCD.FC615282@criticalpath.net>, Brian Moseley <brian@criticalpath.net> wrote:

> given:
>     &lt;http://www.maz.org/&gt;
> i want: 
>     &lt;<a href="http://www.maz.org/">http://www.maz.org/</a>&gt;
> but the regexp (correctly) gives me: 
>     &lt;<a href="http://www.maz.org/&gt">http://www.maz.org/&gt</a>;

to solve that problem (for this case), you might want to extract the
data found between &lt; and &gt; and then run them through the 
_urlify routine.

   s/   &lt;        #beginning ampersand escape
        (?:URL:)?   #possible RFC compliance, not captured
        (.*?)       #anything, including whitespace
        (?=&gt;)    #up to the ending ampersand escape

    / '&lt;' . &_urlify($1) /egxs;

and then add a line in the _urlify routine to strip out any
whitespace (as is allowed by the RFC).

good luck :)

-- 
brian d foy                                 <http://computerdog.com>
perhaps the routine should be _referencify since the input is
already a URL.


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

Date: Tue, 30 Dec 1997 09:34:55 -0600
From: smills@lewiston.com (Harry Mills)
Subject: Re: Passing shell objects as arguments to perl scripts
Message-Id: <883482457.1137836036@dejanews.com>

Thanks, Joseph.  I got it.  Some stuff you read and it just doesn't make
sense until your head's in the right place.  I read about it in perl
variables section of some man page somewhere or other, today, and there
it was, @ARGV.	*sigh* One of these days I'll remember the program I
wanted it for 'way back when.

I've bookmarked the url you offered.  Every little bit helps, especially
for someone like me.  And thanks to all the others who've chimed in on
this.  I even understood some of it!

Thanks,

Harry

http://mickey.lcsc.edu/~steve

And don't ask me why I'm using Dija News!  I was tricked!

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


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

Date: Tue, 30 Dec 1997 08:31:18 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: perl <STDOUT> to gnuplot <STDIN>
Message-Id: <mj0b86.em.ln@localhost>

Andrew M. Langmead (aml@world.std.com) wrote:
: ron@farmworks.com (Ronald L. Parker) writes:

: >That's not a file.  Isn't it documented somewhere that the return from
                                           ^^^^^^^^^
: >opening a pipe isn't very useful?  Does the Tom Phoenix 'bot need an
: >adjustment?

: Its not that the return value (whether the fork() succeeded) isn't
: useful, its just on *as* useful as many people want it to
: be. (expecting it to tell whether the following exec() succeeded as
: well.)


And the "somewhere" is this Perl FAQ from part 8:

   "Why doesn't open() return an error when a pipe open fails?"


Which refers you to the 'perlipc' man page (under the heading
"Using open() for IPC":

---------------------------
Be careful to check both the open() and the close() return values.  If
you're I<writing> to a pipe, you should also trap SIGPIPE.  Otherwise,
think of what happens when you start up a pipe to a command that doesn't
exist: the open() will in all likelihood succeed (it only reflects the
fork()'s success), but then your output will fail--spectacularly.
 ...
---------------------------


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


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

Date: 30 Dec 1997 05:56:49 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dustin@hub.ofthe.net
Subject: Re: PERL URL-Encoding
Message-Id: <8cn2hj6lbi.fsf@gadget.cscaper.com>

>>>>> "Dustin" == Dustin Arnold <dustin@hub.ofthe.net> writes:

Dustin> Could anyone email me the line(s) of PERL that would re-URLencode a
Dustin> string
Dustin> of text (do the opposite of this):

Dustin> $value =~ tr/+/ /;
Dustin> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

First, you shouldn't be doing that in the first place.  Let CGI.pm do
that for you.  Don't reinvent the wheel.  Don't copy code from some
silly book in some cargo-cult-programming mode.  That's how a lot of
bad code gets executed, and how a lot of security holes get
propogated.

For going to and from URI-encoded strings in general, look at the
URI::URL module of the LWP library, available at any fine CPAN site
near you.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 245 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: Tue, 30 Dec 1997 11:01:42 -0600
From: Rholder@sispost1.bis.adp.com
To: Rholder@sispost1.bis.adp.com
Subject: SHELL/REGEX GUNSLINGERS NEEDED!!!
Message-Id: <883500436.1689190410@dejanews.com>

I want to store regular expressions in one file, and then use a
shell script to read them into a shell variable within a "for" loop,
and then feed the expression into egrep via the shell variable.

I'm doing this under Solaris 2.5.1.

Here is my script:

  #!/usr/bin/ksh -x
  #
  # pidfinder -- find the PID of a process given a regex that will
  #              pluck that process from the output of ps -eo args,pid
  #
  for REGEX in `(cat /usr/local/scripts/pregex)`
  do
        ps -eo pid,args | egrep -v egrep | egrep $REGEX | awk '{print $1}'
  done
  # END OF SCRIPT

 ....and here is what is in the file /usr/local/scripts/pregex:

'(dataserver).*(miler)+'
'(dataserver).*(citys)+'
'(dataserver).*(demo)+'

Here is what the lines I'm searching for look like:

$ ps -eo pid,args | egrep dataserver
  970 /opt/sybase/bin/dataserver -d/db/mstr/miler_mstr.0 -smiler
18042 egrep dataserver
  959 /opt/sybase/bin/dataserver -d/db/mstr/demo_mstr.0 -sdemo
  948 /opt/sybase/bin/dataserver -d/db/mstr/citys_mstr.0 -scitys

 ....I use the "ps -eo pid,args" rather than "ps -ef" or something more
usual so that I can see more of the sybase arguments.  We have three
dataservers running on this machine, and I need to be able to grab the
line from "ps" for each one, as differentiated by the "miler", "citys"
and "demo" part of the expression.

These regular expressions work when I type them in at the shell
prompt, like this:

  ps -eo pid,args | egrep '(dataserver).*(miler)+' | awk '{print $1}'

 ....this gives me the correct PID.  But they don't work when plugged in
via the $REGEX variable in the shell script...

It seems to me that the meaning of the quotes is changing when they are
in the content of the $REGEX shell variable, but I don't understand how
and I'm starting to run out of ideas...

I don't want to write a long, ugly script with lots of individual egrep
statements.  Is there a way to do this, or should I try an entirely
different approach?  I'm just starting to learn Perl, and I have a
feeling this is easier to do in Perl, but I need to get this script done,
like, yesterday...

THANKS FOR ANY HELP!  HAPPY NEW YEAR!

Robert Holder
Denver, Colorado

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


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

Date: 30 Dec 1997 12:45:04 GMT
From: "Bob Jarvis" <jarvisbob@timken.com>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <01bd145e$6eebcb30$2f74b993@jarvisb>

If you've spent your career writing COBOL it shouldn't be surprising
that a C header file appears confusing.

I just looked through winsock.h and it didn't look incomprehensible
to me.  Of course, I've got about 15 years of C behind me.

I haven't looked at COBOL in over 10 years.  No doubt it'd take me a
while to come up to speed on it again.

So how do you feel about Smalltalk?  :-)
-- 
Bob Jarvis
Mail address hacked to foil spammers!
Remove "ob" from address to reply

Charles F Hankel <charles@hankel.mersinet.co.uk> wrote in article <34a61f24.10392498@news.mersinet.co.uk>...
> 
> Just to add to this debate, I had to look into the winsock.h file on
> my PC the other day and the first glance showed why COBOL is so much
> more easy to maintain.  Anyone with a grain of sense would prefer the
> sheer readability of COBOL to the mess that I saw.
> 
> 
> Charles F Hankel
> ------------------------------------------------------------------
> COBOLs: IBM D, E, F, ANS v4, VS, COBOL 2, LE/370, AIX, S/38, OS/2,
>         PC/MS-DOS, Honeywell GCOS, Burroughs 7000, Tandem, HP3000
>         all to varying degrees over the past 25 years or so.
> 


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

Date: 30 Dec 1997 15:15:50 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <68b376$7ht$1@nntp.msstate.edu>

In article <34A812F9.C169A703@its.cl>, Guillermo Schwarz <gschwarz@its.cl> writes:

|> Kurt Watzka wrote:

|> > Guillermo Schwarz <gschwarz@netup.cl> writes:
>
|> > Well, looks as if there still is something to learn about C for you.
|> > The exact wording is "are reserved as identifiers with external
|> > linkage", but "reserved external name" looks close enough to me.

|> It's nice to know C advances so fast I can't keep up to date with its
|> definition.

Yeah, it's pretty tough, trying to look at the new version of the
standard every decade or so.


|> "Reserved as identifiers" is something meaningful to you? Can you
|> reserve a name as a non indentifier? "with external linkage"? 

The exact quote ( from ISO 9899-1990) is:

  -- All identifiers with external linkage in any of the following
  subclauses (including the future library directions) are always
  reserved for use as idenitiers with external linkage.

You have to read the sentence all the way through in order to
understand. "Reserved as identifiers" might be a bit silly, but
"reserved as identifiers with external linkage" makes some sense, no?

|> The point is, at least when I studied the good and old K&R, it didn't
|> mention "reserved as identifiers with external linkage",

Why don't you take a bold step forward into the 1980's and take a look
at ANSI/ISO C? ;)

|> or trick"... The C guys modify their language each 3 months just when they
|> realize
|> something is missing. If you think it is funny, I think it is pretty messy.

They do? Which C guys is that? The bit about external identifiers is a
quote from C89. We have great hopes that C9X will be ratified before we
call have to call it C01 or something.

There have been a couple addenda to the C standard, but no big changes
in 7 years.

|> In Smalltalk, there is USUALLY no need to change the language, but just the
|> need to add new classes and methods to achieve what's needed.

[ assorted language advocacy snipped. You've heard it all before... ]

|> I'm sorry to hurt your feelings about C++. But it turns out that C++ is a
|> very poorlanguage. 

Yeah, it sucks. That's why so many people get paid so much money tp
program in it when they'd really rather be using Smalltalk. Or Lisp.

|> You can't know how many bits does an int have. Or if long
|> is actually bigger than int.

You can't? Wow...I though you could.

|> You can't tell an structure to write itself into a file. 

You can't? I thought I had....

|> You can't code an algorithm that works with any
|> kind of numbers: int, double, big int, etc.

You can't? Has anybody told Alexander Stepanov about this?

|> Try to make a single general program.

Huh? A single general program? Help me out here...what does that mean?

|> Try to create a Set of objects in C++.
|> Try to create a Bag of objects in C++.
|> Try to create a SortedCollection of objects in C++.

Hmmmm.... I get it. Your knowledge of C++ is as current as your
knowledge of C.

|> I'm sorry if I hurt your feelings, but for the last 3 months I've been
|> Smalltalking more than keeping up with the C crap. 

Obviously.

|> (C++ being the cream of the crap and Java being coffe you
|> drink with cream).

I do like that, though: "C++ : The cream of the Crap!".
 
|> I mean no offense to other languages. Fortran had its time. C had it. C++ had
|> it. Java is having it.

And Smalltalk...?

|> And claiming you know C++ and Smalltalk more
|> than me is something to prove, sir!

 ...and the band played on.

[ spewage apparantly generated by Web browser being overloaded as
newsreader deleted ]


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

Date: 30 Dec 1997 15:52:02 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <68b5b2$8b4$1@nntp.msstate.edu>

In article <dewar.883445953@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) writes:
|> <<Keep on dreaming.  No language, ever, can be defined by a piece of paper.
|> Unless it is a dead language that is no longer used and therefore no longer
|> changes.  This concept is simply impossible.
|> >>


|> This is complete nonsense. It does not correspond to the real situation
|> with many standardized languages. Many programmers know the C standard
|> well, carefully adhere to it, and succeed in writing portable code, and
|> the same thing can be said of Fortran, COBOL and Ada programmers (
|> particularly in the latter case, Ada programmers tend to know the standard
|> well).

And the converse is true, as well. Many "programmers" who consider the
compiler to define the laguage generate code that runs fine, but creates
major migraines when it has to be ported, or even compiled with a
different compiler. On Unix, for instance, the standard Sun C compiler
will accept crap that the SGI compiler will choke on.


|> The idea that a language wanders around ill-defined, and programmers follow
|> it may seem familiar to undisciplined hackers, but it does not required
|> dreamers to correct this totally unacceptable behavior!

Yep. It's not really all that hard to base one's programing style on the
formal definition of the language,  making use of extensions as needed.
It's more an attitude than anything.

|> Sounds like you have very little direct experience with language
|> standardization efforts, your account above bares no relation to reality.

Indeed.


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

Date: 30 Dec 1997 11:54:56 -0500
From: Jeffrey Templon <templon@studbolt.physast.uga.edu>
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <m37m8m6aan.fsf@studbolt.physast.uga.edu>

"Alicia Carla Longstreet" <carla@ici.net> writes:

> No the language is *not* defined by any single compiler, neither is it
> defined by any piece of paper.  A language is defined by usage.  A
> combination of compilers and the standard.

I'd guess this opinion is generated by doing the majority of one's
work on the same platform, possibly even using the same development
tools, whenever you use C.

We have had *no end* of headaches on our big code, because the original
lead programmer agreed with your definition of the language (in this
case, Fortran).  He declared that one extension he made extensive
use of (no pun intended, but I like it) was *standard* because every
compiler he ever used supported it.  The year after the first major
release, CEBAF made a big investment in IBM RS/6000 machines, and lo
and behold this wonderful extension was *not* supported in IBM's
compiler suite!  Also lots of people started getting Linux boxes
at about the same time, and it has only been in the last year that
Linux compilers are available which support this extension (although
there were a number of Fortran compilers available which did not
support the extension.)  So our project does not have access to a
significant fraction of the on-site horsepower, and we're looking at
a six-month project to convert this extension usage to conform to the
F90 standard.

Good luck with any porting projects you may have in the future.

					JAT


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

Date: Tue, 30 Dec 1997 09:26:31 -0800
From: Patricia Shanahan <pats@acm.org>
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <34A92EC7.8AA616F9@acm.org>

Jeffrey Templon wrote:
> 
> "Alicia Carla Longstreet" <carla@ici.net> writes:
> 
> > No the language is *not* defined by any single compiler, neither is it
> > defined by any piece of paper.  A language is defined by usage.  A
> > combination of compilers and the standard.
> 
> I'd guess this opinion is generated by doing the majority of one's
> work on the same platform, possibly even using the same development
> tools, whenever you use C.
 ...

I sometimes think that every programmer should be required to port a
large program to its second platform before doing any new code.
Preferably, the first platform should differ in word size, endianness,
and general software heritage (e.g. UNIX vs. MSWindows vs. VMS) from
the new target. There is nothing quite like this experience for an
enhanced appreciation the value of standards.

Patricia


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

Date: Tue, 30 Dec 1997 08:34:22 -0500
From: Joseph Cotton <jcotton@erols.com>
Subject: word wrap routine
Message-Id: <34A8F85E.6144@erols.com>

Does any one have a routine to word wrap a $string ?
I need to insert \n every 50 bytes or less, but not in the middle of a
word.


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

Date: 30 Dec 1997 08:31:24 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: word wrap routine
Message-Id: <68at3c$kl$1@stok.co.uk>

In article <34A8F85E.6144@erols.com>, Joseph Cotton  <jcotton@erols.com> wrote:
>Does any one have a routine to word wrap a $string ?
>I need to insert \n every 50 bytes or less, but not in the middle of a
>word.

If you have a recent perl distribution then the Text::Wrap module should
be available to you.  The perldoc command can be used to view its
documentation:

NAME
       Text::Wrap - line wrapping to form simple paragraphs

SYNOPSIS
               use Text::Wrap

               print wrap($initial_tab, $subsequent_tab, @text);

               use Text::Wrap qw(wrap $columns);

               $columns = 132;


DESCRIPTION
       Text::Wrap::wrap() is a very simple paragraph formatter.
       It formats a single paragraph at a time by breaking lines
       at word boundries. [...]

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

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

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