[10363] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3956 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 12 19:07:19 1998

Date: Mon, 12 Oct 98 16:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 12 Oct 1998     Volume: 8 Number: 3956

Today's topics:
    Re: Are there any "perl.newbie" group or forum? (David Adler)
    Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
    Re: Communication with a program via system() (Tad McClellan)
    Re: Communication with a program via system() (Tad McClellan)
    Re: comp.lang.perl.win32?? (Craig Berry)
    Re: DBD Oracle binary for win32 (John D Groenveld)
    Re: Free Software Award (Tad McClellan)
    Re: Fun with Arrays of Hashes (Jon Drukman)
        Getting result of system() call <borthwic@johnson.cs.nyu.edu>
    Re: Help!  What's wrong with $string =~ s/$pattern/$rep (Charles DeRykus)
    Re: How to post a multipart mime format in Perl ? <gellyfish@btinternet.com>
    Re: howto : tee - replicate the standard output (Charles DeRykus)
    Re: I'm looking for someone who wants to write a comple (I R A Aggie)
        Install doesn't get off the ground. How come? <denniscook@erols.com>
    Re: Install on WINNT stops immediately <gellyfish@btinternet.com>
        JOB OFFER: ATLANTA <explorer@best.com>
    Re: Looking for a shopping cart <gellyfish@btinternet.com>
    Re: Name from IP (I R A Aggie)
    Re: Need IP Address Sort Subroutine <williams@clark.net>
        Need to Cut Mem use <sales@madm.com>
    Re: Newbie Using a variable for search/substitue option (Mike Stok)
        Odd number of elements <cshaw@cadence.com>
    Re: Pack and Unpack (Honza Pazdziora)
    Re: Peculiar behavior of system() (Charles DeRykus)
    Re: performing calculations on form entries <evonzee@tritechnet.com>
        PERL / CGI Programmer Needed (Robert)
    Re: Perl freezes when using special characters in HTML (Tad McClellan)
    Re: Perl Robots <gellyfish@btinternet.com>
        print output problem? <fsi001@gate.net>
    Re: Q: How to use a parameter on a perl script executed (Tad McClellan)
    Re: sorting hack <xah@best.com>
    Re: sorting hack <xah@best.com>
        Still can not get browser to read perl script <kespinal@fedex.com>
    Re: unidirectional pipe into interactive program (passw <mtk@egmont-kol.dk>
        which chars to escape in reg.exp? <alex@kawo2.rwth-aachen.de>
    Re: which chars to escape in reg.exp? (Mark-Jason Dominus)
    Re: which chars to escape in reg.exp? (Tad McClellan)
    Re: Why it doesn't work under UNIX?????? <gellyfish@btinternet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 12 Oct 1998 22:54:53 GMT
From: dha@panix.com (David Adler)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6vu1bt$vi@news1.panix.com>

On Sun, 11 Oct 1998 11:31:26 -0500, I R A Aggie
<fl_aggie@thepentagon.com> wrote:

>the Camel (Programming Perl), the Ram (Perl Cookbook) and the Owl 
>(Mastering Regular Expressions) books on my computer desk. Oh, and
>the Rommel Papers, for a little light reading. I guess you could call
>that the Tank Book... :)

For heaven's sake, don't give O'Reilly any ideas!  :-)

Dave, waiting for the Brannock Device book...

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"That's one of the tragedies of this life:  that the men most in need
of a beating up are always enormous." - John D. Hackensacker III


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

Date: Mon, 12 Oct 1998 15:57:29 -0800
From: madame philosophe <mp@mkt2mkt.com>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <36229750.B82EF84E@mkt2mkt.com>

See I knew the llama book was not for non-programmers.

What books would you recommend for intelligent independently studious non-programming
programmers??

Best,

madame p

Randal Schwartz wrote:

> >>>>> "Casper" == Casper Kvan Clausen <ckc@dmi.dk> writes:
>
> Casper> A Perl book for non-programmers, which takes its audience seriously.
>
> Casper> This would seem to fit the Llama book. [Disclaimer: I did not
> Casper> learn Perl via the Llama book, so this is based on hearsay].
>
> No.  The Llama is not designed for non-programmers.  I specifically
> presume at least an understanding of basic concepts (variable, array,
> subroutine, algorithms).  Otherwise, the book would have been about
> twice as long (I've written programming for non-programmers before...
> and it gets more wordy :).
>
> Having said that, I've heard of a number of people that have
> successfully used the llama to learn Perl as their first programming
> language.  I can only presume that they were naturally talented or
> perhaps a programmer in a previous lifetime or something.  :-)
>



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

Date: Mon, 12 Oct 1998 13:25:58 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Communication with a program via system()
Message-Id: <mjhtv6.n05.ln@flash.net>

Steve Howie (showie@uoguelph.ca) wrote:
: I have a question regarding a dialog with an external program called via
: system().  When called using system(), the program will prompt to stdout
: for a y/n response before continuing. Any ideas how to go about setting
: this up so that the perl program can communicate with this external 
: program? Named pipes possibly?


Perl FAQ, part 8:

   "How can I open a pipe both to and from a command?"


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


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

Date: Mon, 12 Oct 1998 16:47:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Communication with a program via system()
Message-Id: <0dttv6.756.ln@flash.net>

Andrew Perrin (aperrin@mcmahon.qal.berkeley.edu) wrote:


: 2.) Use a filehandle:
: open(PROGRAM, '|externalprogram') || die "Couldn\'t open program: $!\n";
: print PROGRAM "y\n";


  Besides the superfluous backwack, the wording of the die message
  is misleading.

     "Couldn't fork   $!"

  would be more accurate.


  see Perl FAQ, part 8:

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


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


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

Date: 12 Oct 1998 21:45:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: comp.lang.perl.win32??
Message-Id: <6vtt9n$m4e$1@marina.cinenet.net>

Paul Murray (murray-paul@usa.net) wrote:
: On 6 Oct 1998 23:24:32 GMT, Craig Berry <cberry@cinenet.net> wrote:
: >thom_co@my-dejanews.com wrote:
: >: There are several perl issues that would be of interest only to those
: >: doing win32 perl programming and not to the rest of the perl community.
: >Examples?  
: 
: o Using Win32 GUI modules, Win32 Registry modules, umm most things
: called Win32:: :)

Sounds more like comp.lang.perl.modules.win32 to me.

: o Connecting to Access databases/Excell spreadsheets/etc...

Ditto.

: o Peculiarities of perl under win32 (or win32 under perl, depending on
: your perspective)

This would be topical, but seems a limited area of conversation.  The
number of non-module-related peculiarities is small.

: o Differences between available ports, utilities only available under
: Win32, such as perl2exe.

Again, topical but I can't see their being a lot of traffic on this (based
in part on how little occurs currently in clpm).

: >And why win32 as opposed to any other particular architecture or OS? 
: 
: o Most unices can be considered essentially homogeneous, Win32 is a
: very different environment. This would also apply to Macs, but...

But?  Please, extend the thought.  I'm interested in how this case
differs.

: o Userbase. There are a lot of Win32 perl users out there, more than
: any other non-unix port.

Yes, but I'm really not sure that they have needs differing that strongly
from the Unix-or-other-OS Perlers.

: o Cluelessness. It seems fair to say that the average Win32 perl
: programmer is less experienced than the average unix perl programmer,
: thus the level of questions asked is lower.

But this 'justification' fails for the same reason the frequently
suggested clp.newbies is a bad idea; the worst possible venue for a newbie
to ask a question is in a room full of newbies with no experts present.
Bad advice would be endlessly recycled.

: Currently this causes...
: 
: o Attitude problem of current newsgroup towards Win32, probably caused 
: by abovementioned cluelessness getting all Win32 programmers and 
: questions tarred with the same brush.  Questions tend to get blown off 
: with 'install a real OS' type 'help'

I really don't see that much OS prejudice in clpm (with a few loud-mouthed
exceptions).

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 12 Oct 1998 16:10:44 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBD Oracle binary for win32
Message-Id: <6vtno4$d58$1@tholian.cse.psu.edu>

Jeff Urlwin's page http://www.access.digex.net/~jurlwin/
now points users to http://www.ActiveState.com/. Personally,
I'd never admin a machine w/o a compiler.
John
groenveld@acm.org


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

Date: Mon, 12 Oct 1998 16:50:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Free Software Award
Message-Id: <hjttv6.756.ln@flash.net>

Michael J Gebis (gebis@fee.ecn.purdue.edu) wrote:


: Copyright (C) 1998 Free Software Foundation, Inc., 59 Temple Place -
: Suite 330, Boston, MA 02111, USA 

: Verbatim copying and distribution is permitted in any medium, provided
: this notice is prese.
                 ^^^^^^


Uh oh. 

Was the original notice preserved?    ;-)


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


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

Date: 12 Oct 1998 21:13:15 GMT
From: jsd@hudsucker.gamespot.com (Jon Drukman)
Subject: Re: Fun with Arrays of Hashes
Message-Id: <slrn724sce.4ff.jsd@hudsucker.gamespot.com>

In article <361eabb2.811494407@news.qgraph.com>, Darren Greer wrote:
>Howdy.....Ive got an aray of hashes...and am trying to print one of
>hte values in one of the hashes.....for example:
>
>	$array[0] = (%hash = ('var1',$var1,'var2,$var2) );

I find the perl debugger extremely helpful for experimenting with
these sorts of data structures.  For instance, if you fire it up (with
'perl -de 1') and type in that line, you would see something like the
following:

  DB<1> $array[0]=(%hash=('var1',3,'var2',4));

  DB<2> x @array
0  4

all you stuck in $array[0] was the result of assigning the hash, which 
was '4' (number of elements in the list).  if you fix the line, you
get something like this:

  DB<3> $array[0]={'var1' => 3, 'var2' => 4};

  DB<4> x @array
0  HASH(0x221af4)
   'var1' => 3
   'var2' => 4

ah, much better!  now you can play with the syntax for accessing the
desired hash value.

  DB<5> x $array[0]->{var2}
0  4
  DB<6> x $array[0]{var2}
0  4

-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Fear the government that fears your computer.


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

Date: Mon, 12 Oct 1998 16:19:11 -0400
From: Andrew Borthwick <borthwic@johnson.cs.nyu.edu>
Subject: Getting result of system() call
Message-Id: <Pine.SO4.4.03.9810121608090.2352-100000@johnson.cs.nyu.edu>

Hi,

   I am trying to write a subroutine which will execute an arbitrary system
command and die if the command fails (i.e. returns with a non-zero value).  If
I don't need to use the shell, I can do this by passing the command as a
list as follows:

sub execute {
    local($command) = @_;
    @executable = split (/\s+/,$command);
    system(@executable) && die "$command failed!!!";
}

   This works fine.  If $command fails, we die.

   However, if I need to go through the shell, (i.e. the command is something
like "cat f1 f2 > f3") then I have pass the command as a string rather than a
list by invoking this routine:

sub shell_exec {
    local($command) = @_;
    system($command) && die "$command failed!!!";
}

   This doesn't work so well.  If $command fails, the shell still returns 0 and
we don't die.

   Could anyone tell me how to rewrite shell_exec so that it will die when the
command fails?

Thanks,
Andrew Borthwick




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

Date: Mon, 12 Oct 1998 19:04:49 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help!  What's wrong with $string =~ s/$pattern/$replacement/?
Message-Id: <F0qAC1.sI@news.boeing.com>

In article <361c3ab6.204784741@news>, Ian Underwood <science@home.com> wrote:
>
>I hope this isn't too stupid a questions, but I'm new to Perl, and I'm
>having trouble understanding why the following program:
>
>	use strict;
>
>	my $text = "<u><b>Title here</b></u>";
>	my $pattern = '<u><b>(.*)</b></u>';
>	my $replacement = '<b><u>$1</u></b>';
>
>	my $text1 = $text;
>	$text1 =~ s|$pattern|$replacement|;
>	print "With variables: ", $text1, "\n";
>
>	my $text2 = $text;
>	$text2 =~ s|<u><b>(.*)</b></u>|<b><u>$1</u></b>|;
>	print "Without variables: ", $text2, "\n";
>
>prints the following output:
>
>	With variables: <b><u>$1</u></b>
>	Without variables: <b><u>Title here</u></b>
>
>How can I define $pattern and $replacement so that the first
>substitution has the same effect as the second?  
>

Here're a couple of ways:


eval "\$text1 =~ s|$pattern|$replacement|;";
die $@ if $@;


or, modifying your replacement somewhat:

        my $rep1 = '<b><u>';
        my $rep2 = '</u></b>';


$text1 =~ s|$pattern|$rep1. $1 . $rep2|e;



hth,
--
Charles DeRykus


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

Date: 12 Oct 1998 22:26:34 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: How to post a multipart mime format in Perl ?
Message-Id: <6vts6a$ds$1@gellyfish.btinternet.com>

On Sun, 11 Oct 1998 21:04:23 GMT sbernard@mail.esiea.fr wrote:
> I'd like to know how to post a mulitpart mime format using sendmail with
> Perl. I'd like to send emails containing plain text and HTML. If you know how
> to send HTML only, It will be useful too.
> 

You almost certainly want to get the MIME::* modules from CPAN.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Mon, 12 Oct 1998 19:16:01 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: howto : tee - replicate the standard output
Message-Id: <F0qAup.217@news.boeing.com>

In article <6vpm21$omp$1@nnrp1.dejanews.com>,  <naderr@my-dejanews.com> wrote:
>G'day,
>
>What's the equivalent way to do this in perl?
>
>	echo "foo" | tee -a foo.log
>

e.g,

open(TEE<, "| /bin/tee -a foo.log") or die "can't tee: $!";
print TEE "foo\n";

perldoc -f open and look for discussion of piping. 


hth,
--
Charles DeRykus


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

Date: Mon, 12 Oct 1998 15:58:43 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: I'm looking for someone who wants to write a complete perl-script (for free)
Message-Id: <fl_aggie-1210981558440001@aggie.coaps.fsu.edu>

In article <6vt4nr$753$1@nnrp1.dejanews.com>, dragnovich@my-dejanews.com wrote:

+ so men! get your perl tutoria, call for a pizza and 3 o 5 coca colas, and
+ start reading one of the many perl tutorials in the net, buy a book or read
+ the perl docs form www.perl.org....

Not only do you get a sugar buzz, a caffeine buzz, and plenty of pizza, you
also get the satisfaction of taking on a problem, and then kicking it around
like a BIG SLAWBERIN' DAWG!

James


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

Date: Mon, 12 Oct 1998 16:41:57 -0700
From: Dennis Cook <denniscook@erols.com>
Subject: Install doesn't get off the ground. How come?
Message-Id: <362293C5.3E1D@erols.com>

Actually, I tried posting this yesterday, but must be doing something
wrong - try, try again.

I am trying to become a perl user on my winnt, since I have come to
appreciate perl at work.  I can't get the install to work, though.

I downloaded
ftp.activeware.com/Perl-Win32/ntperl/perl5.001m/CurrenBuild/110-i86.  I
moved it to c:\program files\perl5.  Then I used SuperZip 1.0 to unzip
the file, and that seemed to work ok.  Reading the resulting readme and
install text docs, I used a command prompt window, cd to the perl5
directory and typed 'install'.

I got an immediate error:
'Can't locate NT.ph in @INC (did you run h2ph?) at install.bat line 35'

NT.ph does exist in the directory, and I don't know what h2ph is -
anybody got the answer?  Thanks in advance, I'm drooling to use perl at
home.

-- 
Thanks very much,
Dennis Cook


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

Date: 12 Oct 1998 21:58:51 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Install on WINNT stops immediately
Message-Id: <6vtqib$dm$1@gellyfish.btinternet.com>

On Sun, 11 Oct 1998 14:01:29 -0700 Dennis Cook <denniscook@erols.com> wrote:
> I'm a (non-power) perl user at work and, having been thoroughly won
> over, want to install at home to handle some file manipulation, but have
> run into a snag.
> 
> I have WINNT4.0 on pentiumII w/plenty memory & hd.  
> 1) I ownloaded:
> ftp.activeware.com/Perl-Win/ntperl/perl5.001/CurrentBuild/110-i86.zip.
> 

I dont know what that file is but the downloaded file should be something like
api502.exe which when run will just do the right thing.

Go back to the web site and check out the right file.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Mon, 12 Oct 1998 13:03:03 -0700
From: Michael Gersten <explorer@best.com>
Subject: JOB OFFER: ATLANTA
Message-Id: <36226077.BCBD3ACF@best.com>

We have an urgent need for a perl programmer in Atlanta, GA, to start IMMEDIATELY.

This is a contract position.

Please contact us at (510) 795-6086.


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

Date: 12 Oct 1998 18:33:58 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Looking for a shopping cart
Message-Id: <6vtei6$b6$1@gellyfish.btinternet.com>

On 12 Oct 1998 09:28:58 +0100 Jim Brewer <jimbo@soundimages.co.uk> wrote:
> Have you checked your local supermarket. Chances are you will find
> quite a few shopping carts.

Around here you only have to wait until saturday night and one always
seems to mysteriously appear in the back yard.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Mon, 12 Oct 1998 16:01:06 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Name from IP
Message-Id: <fl_aggie-1210981601060001@aggie.coaps.fsu.edu>

In article <MPG.108bb9c192ffc3f19898b1@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:

+ if you like a bit less typing.

I grabbed this of the net quite a while ago. Cut & Paste for even less
typing... :)

#!/usr/bin/perl

#usage:
#$ address2name 199.232.46.114

$bobo = pack("C4", (shift =~ /(\d+).(\d+).(\d+).(\d+)/));
($name, $aliases, $addrtype, $length, @addrs) = gethostbyaddr($bobo, 2);

print "Name: $name\n";
print "Aliases: $aliases\n";
print "Address type: $addrtype\n";
print "Length: $length\n";
print 'Addresses: '; 

foreach (@addrs) { print join('.', unpack('C4', $_)); }
print "\n";

#--snip snip

James


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

Date: Mon, 12 Oct 1998 15:05:56 -0500
From: "Joe Williams" <williams@clark.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <6vtng2$2kr$1@news.onramp.net>

Michael - This is very helpful. Many TXs.

I see better what the code is doing now. It is taking the four quads of an
IP address and converting
them to binary (I assume this is in 8-bit chunks since it is using the ASCII
format.) Then this is
stuffed into a string. Elementary, my dear Watson--but not until you gave me
a few hints!

This approach actually recreates the 32-bit IP address in binary form, then
when it is sorted
as characters, that works fine, because it is sorting on the four octets
giving the leftmost octets
the most importance. Actually, you could sort on the binary number as well,
but I assume Perl's
built in sort routine sorts on decimal numbers written in ASCII, and that
won't work well on this
kind of structure. Right?

Here is why I was confused:

Your example prints out fine:
print pack("C4",48,49,50,51),"\n";
print "\n";

However, the following is what I used as an example, and this doesn't print
out so fine--
    for reasons now obvious.
print pack("C4",199,77,210,67),"\n";

This is OK of course:
print unpack ("C4", get_ipa ("199.77.210.67") );

sub get_ipa{
     $_[0] =~ /([\d.]+)/;print "\n";
   return pack("C4",split(/\./,$1));
}


I can't print it
Michal Rutka wrote in message ...
>Good work Joe.
>
>"Joe Williams" <williams@clark.net> writes:
>> The info below in a partial summary of the ways suggested to sort an IP
>> number. It may be useful to some one new to the problem.
>[...]
>> # This one takes an approach that I don't understand. It uses a
subroutine
>
>Which part do you not understand?
>
>perl -e 'print pack("C4",48,49,50,51),"\n"'
>
>it will print a string "0123". The "C4" means, take 4 arguments and treat
>ASCII char code. One can rewrite this pack as follow:
>
>sub my_c_pack{
>   my $tmp = "";
>   foreach(@_){
>      $tmp .= chr($_);
>   }
>   $tmp;
>}





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

Date: Mon, 12 Oct 1998 14:49:38 -0700
From: "Doyle Johnson" <sales@madm.com>
Subject: Need to Cut Mem use
Message-Id: <6vtuf0$d06$1@nnrp03.primenet.com>

Hello all,

    Well it looks like I need to urn to the experts once again....*sigh*...
Here is the situation..

  I have a script that needs to parse and sort a large file. Th file will
probably be over 2megs at its peak.  At present the sript I created is
running out of mem at about 1.7 megs.

  I have tried to keep the use of @ARRAY's to a minimum to conserve mem. I
need a more efficiant method of reading the file into some sort of an array
so I can sort it.  The current code is similar to this:

  open(FILE, "<$data_file")
  @LIST = <FILE>;
  close(FILE);

And then I sort the array.... in turn the sort creates several other
arrays....I have even went to the much slower method of partialy sorting an
open file, saved some mem but still not enough as I cannot find a way around
the 4 other arrays the sort needs to create.  I have seen brief mention of a
way to turn the array into a vector or something that is much more mem
efficiant. Can anyone give me a hand here? I need to cut the mem use down on
this. Is there a better way to read in large files and sort them?

Thanks in advance

Doyle Johnson






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

Date: 12 Oct 1998 20:48:23 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: Newbie Using a variable for search/substitue options
Message-Id: <6vtpun$r76@news-central.tiac.net>

In article <6vtivt$sba$1@nnrp1.dejanews.com>,  <asequeir@yahoo.com> wrote:
>Hi
>I am trying to use a variable for search /substitue options.
>Perl does not seem to allow it.
>For example
>
> s/$pattern/$subst/g;
>
>works, but,
>
> s/$pattern/$subst/$opt;
>
>gives error. How do I make options dynamic ?

The perlre man page includes this:

  (?imsx-imsx)
            One or more embedded pattern-match modifiers.  This is
            particularly useful for patterns that are specified in a table
            somewhere, some of which want to be case sensitive, and some of
            which don't.  The case insensitive ones need to include merely
            (?i) at the front of the pattern.  For example:

                $pattern = "foobar";
                if ( /$pattern/i ) { }

                # more flexible:

                $pattern = "(?i)foobar";
                if ( /$pattern/ ) { }

            Letters after - switch modifiers off.

you should have got the perlre docs with perl.

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: Mon, 12 Oct 1998 15:48:25 -0700
From: Chris Shaw <cshaw@cadence.com>
Subject: Odd number of elements
Message-Id: <36228739.1AFB@cadence.com>

"Odd number of elements in hash list at ...."

I get this warning on another system, but get 
no warnings when I run the program on my system.

I did not install either copy of perl. I'm running
version 5.001, patchlevel 1m. The other system is
running 5.004_01.

Any suggestions?

-- 
			-chris shaw
			DSM Tech Pubs
			cshaw@cadence.COM


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

Date: Mon, 12 Oct 1998 19:54:10 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Pack and Unpack
Message-Id: <slrn724nj3.o3a.adelton@aisa.fi.muni.cz>

On Mon, 12 Oct 1998 19:13:11 GMT, Garrett Casey <nospamno_adms1@cts.com> wrote:
> Do you know of any good tutorial or lesson that goes over the pack and
> unpack functions.  I looked at perlfunc but I am still a bit unclear.

Tell us what you find difficult, we might be able to explain. IMHO the
pack section of perlfunc is rather detailed, so if you _know_ you need
pack, you should be able to make sense of it. So let us see your
problem ...

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 12 Oct 1998 21:04:01 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Peculiar behavior of system()
Message-Id: <F0qFup.A40@news.boeing.com>

In article <36214827.7FEE0507@home.com>,
Dwight Klaus  <dklaus1@home.com> wrote:
>Hi,
>
>I have been fighting with a peculiar behaviour in using system() to
>invoke an executable command.  Maybe you are one step ahead of me on
>this one, and can offer me some advice (or simpathy, or whatever...).
>
>When invoking: 
>
>	system("<some_long_command_string>") 
>
>the results I see indicate that the command interpreter that this string
>is passed to is somehow seeing newlines inserted before the entire
>string is scanned.  I know this because the last argument in the command
>string is missing from the perspective of the program invoked, and when
>this program completes, the command interpreter tries to execute the
>last argument as if it were the next command.  To make matters worse,
>the behavior seems to be intermittant, and related to the length of the
>command string being executed.  I wonder if there is a buffer limit that
>I am reaching in the command interpreter, and that its default action is
>to truncate the command string after the last full word prior to the
>buffer overflowing.???
>
>No idea on this one - and I also question how perl chooses the command
>interpreter that system() uses.  Is it based on passwd file entry, or
>environment variable SHELL or something else?
>

'/bin/sh' is used - whatever it is. See perldoc -f system.

You can quickly get /bin/sh out of the picture though
with an exec, e.g.

 system qq{exec /bin/ksh -c "/path/cmd"};


hth,
--
Charles DeRykus


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

Date: Mon, 12 Oct 1998 16:18:24 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
To: seanr@zapinc.com
Subject: Re: performing calculations on form entries
Message-Id: <36227220.EF45A3B9@tritechnet.com>

[courtesy copy mailed]

Where is use strict?
Use the -c and -w option to check syntax and enable warnings...  You're missing
at least one left curly...  and have a couple single-use vars.

Where are the variables coming from?  You refer to many variables:

>$total_A = eval($quant_A * $price_A);
>$total_B = eval($quant_B * $price_B);
>$total_C = eval($quant_C * $price_C);

that have never been declared.  (and why use eval?)  Didn't you mean

my($total_A) = $cgivars{'quant_A'} * $cgivars{'price_A'};

and so on?

All of the above are just my initial impressions of your code.  There may be
more problems (and I may be wrong about some of the above) but at least my first
two recommendations hold true.

HTH, Cheers!

-Eric

--
Best Regards,     | Psychotics are consistently
Tritech Marketing | inconsistent. The essence of
                  | sanity is to be inconsistently
Eric Von Zee      | inconsistent.
Webmaster         | -- Larry Wall




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

Date: Mon, 12 Oct 1998 20:46:07 GMT
From: Robert@Syworks.Com (Robert)
Subject: PERL / CGI Programmer Needed
Message-Id: <6vtpvn$aqr@newsops.execpc.com>

Hello!

Perl / CGI programmer needed in efforts to develop an Internet site /
Job Board. Free BSD / Unix platform. 

This internet site will contain several forms, one will be especially
infomation intensive - allowing individuals to rate thier technical
proficiencies in I.T., Graphic Design, Engineering and so forth. The
majority of the other pages involving CGI / Perl will be glorified
Bulletin Boards, not too difficult. However, there are other needs /
desires that we have for this board that we're not too sure are
possible (or easy). We've charted a decent viseo chart on the process
of the flow of information and we'll assemble the majority of the
board in HTML. 

You simply need to be the CGI / Perl god in efforts to help us
understand what's possible (and within our budget) and develop it. 

Sound interesting? E-Mail ROBERT@SYWORKS.COM for info. This project
will not "get going" for about 3 to 4 weeks, however we'd like to
shoot some information back & forth first in order to plan things
accordingly. 






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

Date: Mon, 12 Oct 1998 16:43:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl freezes when using special characters in HTML
Message-Id: <76ttv6.756.ln@flash.net>

scott@softbase.com wrote:
: Ruud Limbeck (ruud.limbeck@tip.nl) wrote:
: > system ('pro98.exe 111.bbx');
: > ...
: > open(wrk, "111.wrk");

: Are you sure:

: 	1. Pro908.exe has *finished* when the open call has been
: 	made? It is possible to start asynchronous commands. I think
: 	that's what system does. 


   I don't think that's what system does.   ;-)


perldoc -f system

------------------------------------
=item system LIST

Does exactly the same thing as "exec LIST" except that a fork is done
first, and the parent process waits for the child process to complete.
 ...
------------------------------------


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


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

Date: 12 Oct 1998 18:32:36 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl Robots
Message-Id: <6vtefk$b3$1@gellyfish.btinternet.com>

In comp.lang.perl.misc Timothy P O'Neill <timothy@nmia.com> wrote:
> jrrl@lycos.com wrote:
> : I am working up a Perl branch of the {C,C++}Robots family.
> 
> Programming languages are very much a matter of taste, though. I love Java
> and hate Perl.

"I Love it when a cross-post goes bad"

Could this be a contender for "reese of the week" ;-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Mon, 12 Oct 1998 18:18:55 -0400
From: "Dennis P." <fsi001@gate.net>
Subject: print output problem?
Message-Id: <6vtv2o$1hc8$1@news.gate.net>

i wrote a program in perl to calculate an invoice with extended totals but
everytime i extend the toal dollars i'm not getting the right 0 to print in
my field. how can i insert a zero at the end of the field so it prints
correctly.


Thank you in advance for any help in this matter.




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

Date: Mon, 12 Oct 1998 16:56:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Q: How to use a parameter on a perl script executed from HTML on Apache
Message-Id: <itttv6.756.ln@flash.net>

Raoul (raoul@xs4all.nl) wrote:

: <html>
: ....
: <!--#exec cgi="/cgi-bin/do_something.pl?say_hello"-->
: ...
: </html>

: Unfortunately this is not understood by the Apache webserver. Does someone 
: have a clue how this can be done? Thanks in advance for all your help.


   Asking questions related to servers in a newsgroup about
   servers is more likely to get you the answer you seek.

   Try:

         comp.infosystems.www.servers.unix

   or even:

            comp.infosystems.www.authoring.cgi

   as I expect they talk about SSI there too.



   perl does not know what went on before it was called.

   You are having a problem before perl is called  ;-)


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


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

Date: Mon, 12 Oct 1998 15:27:23 +0000
From: "Xah" <xah@best.com>
Subject: Re: sorting hack
Message-Id: <6vtv7r$2r7$1@nntp2.ba.best.com>

Xah wrote:
> I have an array of arrays of the form [[a1,a2,...],[b1,b2,...],...].
> I want to sort them first by their digits starting from the left,
> then by their length.
> How would one best implement this in Perl?

John Porter <jdporter@min.net> wrote:
>       sort { pack("N*",@$a) cmp pack("N*",@$b) }

This solution is supreme. I just read the brief documentation on pack. It's
a bit dense. Can you do a bit explanation? Is there an webpage that I can
read more about pack?

Thanks.

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 Mountain View, CA, USA


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

Date: Mon, 12 Oct 1998 15:57:52 +0000
From: "Xah" <xah@best.com>
Subject: Re: sorting hack
Message-Id: <6vu112$3kj$1@nntp2.ba.best.com>

In article <362238D4.396A2E89@min.net> , John Porter <jdporter@min.net> 
wrote:
>Is there some reason this
>
> sort { pack("N*",@$a) cmp pack("N*",@$b) }
>
>is not satisfactory?


I just noted that this solution fails when the numbers are greater than
'long'. For example,

--

#!perl -w
use strict;
use lib qw(
APS318User:T2:perl_files_dir:perlModules_dir:
);
use Data::Dumper qw(Dumper); $Data::Dumper::Indent=0;

sub IndexSetSort2 ($$$$) {
my @indexList = @{$_[0]};
my $sortByIndexFirstQ = $_[1];
my ($indexAscendingQ, $lengthAscendingQ) = ($_[2],$_[3]);

@indexList = sort { pack("N*",@$a) cmp pack("N*",@$b) } @indexList;

return \@indexList;
};

my $ref = [[5000000000000000000000],[1000000000000000000000,2]];

print Dumper(IndexSetSort2($ref,1,1,1));
--

will print "$VAR1 = [['5e+21'],['1e+21',2]];"

Mmm... Would this solution still be fastest if we check each number size
first?

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 Mountain View, CA, USA



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

Date: Mon, 12 Oct 1998 17:11:44 -0700
From: Katia Espinal <kespinal@fedex.com>
Subject: Still can not get browser to read perl script
Message-Id: <36229AC0.8554C785@fedex.com>

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

I have created a simple perl script.

print "Content-type:text/html\n\n";
print "<html><head><title>Test Page</title></head>";
print "<body>";
print "<h2>Hello, world!</h2>";
print "</body></html>";

I still can not get the browser to interpret the HTML tags.

Help please.

Thx,
katia
kespinal@fedex.com


--------------BB1BD85F21336FB14659AC90
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Katia  Espinal
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Katia  Espinal
n:              Espinal;Katia 
org:            Edi Services Federal Express
email;internet: kespinal@fedex.com
title:          TA
tel;work:       (901) 224-9168
tel;fax:        (901) 224-9130
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------BB1BD85F21336FB14659AC90--



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

Date: Mon, 12 Oct 1998 22:55:43 +0200
From: "Mikkel K." <mtk@egmont-kol.dk>
Subject: Re: unidirectional pipe into interactive program (passwd)
Message-Id: <36226CCF.9325EE33@egmont-kol.dk>

Tony Curtis wrote:
> 
> Re: unidirectional pipe into interactive program (passwd),
> Mikkel <mtk@egmont-kol.dk> said:
> 
> Mikkel> open(MY_PIPE, "| /usr/local/samba/smbpasswd&") or die
                         ^
                       ooups
>
 
> You're sure that smbpasswd reads from stdin?  I suspect it
> doesn't, and that it wants to play with the tty to turn off
> echo etc. (guess).

Nope. You are probably right, there is (as in passwd, where I would like
to use same trick) no echoing on the screen. If thats the case, will I
then have to use Expect? I am so to speak not a very hardcore terminal
guru, and I didn't even know that there was a difference between tty and
stdin.

> Expect would probably do what you want.  Have you checked on
> CPAN for Samba related modules?  Maybe there's canned
> solution.  Or even a cpanned solution :-)

Found nothing on CPAN (no guarantee), but some links on Yahoo! on +perl
+smbpasswd.

Though, the programs offered here looks that complex that it will be
easier for me to finish my own, with or without expect.pm

But still: Can I somehow pipe to passwd and smbpasswd (stdin or tty)
without expect.pm? 



Thanks, Mikkel


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

Date: Mon, 12 Oct 1998 22:01:46 +0000
From: Alex Farber <alex@kawo2.rwth-aachen.de>
Subject: which chars to escape in reg.exp?
Message-Id: <36227C4A.97219CD9@kawo2.rwth-aachen.de>

Hi,

how do you know, which characters are to escape
in a regular expression? perldoc what?

I am confused, because all three reg. expressions 
seem to work for me, but I am worried if they really
do what I want them to do (- and @):

if (param ('mail') !~ /^[\w\.\-]+\@[\w\.\-]+\.\w+$/)

if (param ('mail') !~ /^[\w\.\-]+@[\w\.\-]+\.\w+$/)

if (param ('mail') !~ /^[\w\.-]+@[\w\.-]+\.\w+$/)

Thanks for your help!
Alex

--
http://www.simplex.ru/pref.html


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

Date: 12 Oct 1998 18:49:01 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: which chars to escape in reg.exp?
Message-Id: <6vu10t$it7$1@monet.op.net>

In article <36227C4A.97219CD9@kawo2.rwth-aachen.de>,
Alex Farber  <alex@kawo2.rwth-aachen.de> wrote:
>Hi,
>
>how do you know, which characters are to escape
>in a regular expression? perldoc what?

I don't think there's a short summary anywhere, but it would be in
`perlre'.   The problem is that characters that are special in one
context may not be special in another context.  For example, `.' is
usually special, but inside [...] it is just a dot.

>I am confused, because all three reg. expressions 
>seem to work for me, but I am worried if they really
>do what I want them to do (- and @):
>
>1. if (param ('mail') !~ /^[\w\.\-]+\@[\w\.\-]+\.\w+$/)
>
>2. if (param ('mail') !~ /^[\w\.\-]+@[\w\.\-]+\.\w+$/)
>
>3. if (param ('mail') !~ /^[\w\.-]+@[\w\.-]+\.\w+$/)

2 and 3 are the same.  You should also replace \. with just .
like this:

4.	/^[\w.-]+@[\w.-]+\.\w+$/

I would be concerned about the @.  I was afraid that perl would see it
as introducing an array to be interpolated.  So I would have written:

5.	/^[\w.-]+\@[\w.-]+\.\w+$/

5 is definitely what you want; it might also be the same as 4.  Maybe
someone who knows for sure can say; it's possible that this is one of
the places where Perl is smarter than I expect.



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

Date: Mon, 12 Oct 1998 17:36:32 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: which chars to escape in reg.exp?
Message-Id: <g90uv6.7f6.ln@flash.net>

Alex Farber (alex@kawo2.rwth-aachen.de) wrote:

: how do you know, which characters are to escape
: in a regular expression? perldoc what?


   perldoc perlre

   I don't know if there is a succinct list of regex metachars around...


: I am confused, because all three reg. expressions 
: seem to work for me, but I am worried if they really
: do what I want them to do (- and @):

: if (param ('mail') !~ /^[\w\.\-]+\@[\w\.\-]+\.\w+$/)

: if (param ('mail') !~ /^[\w\.\-]+@[\w\.\-]+\.\w+$/)

: if (param ('mail') !~ /^[\w\.-]+@[\w\.-]+\.\w+$/)


   "character classes" are a little language within the larger
   regex language.

   Within char classes there are very few metachars.

   Only four, I think. Someone jump in if I missed any:


   1) ^ (caret) is meta only if it is first in the char class

   2) - (hyphen) is meta unless it is last in the char class

   3) ] (closing square bracket) is meta unless it is first in
        the char class

   4) \ (backslash) is always meta


   So feel confident that you don't need to escape the dots and
   hyphens in your char classes above.



   In regular expressions proper, it is not so simple. But your
   code above only has two that are escaped.

   . (dot) is definitely meta. I assume you want a literal dot
     above, so escaping it is the Right Thing.

   @ (at sign) is not meta for regexes. 

   But it _is_ used to get variable interpolation
   of an array. This should only need to be escaped when the
   character following the @ is alphabetic (because it looks like
   a reference to an array variable in that case).

   (actually if it is: @_ or @{array} or similar it would also
    need to be escaped to avoid interpolation...
   )

   Since your @ doesn't "look like" a reference to an array variable, 
   you don't need to escape that either.





   Note 1:  If you want them all to be literal and you are unsure
            about their "metaness", it won't hurt to escape all
            of them. This is the approach taken by the
            quotemeta() function.


   Note 2:  You realize that it is hopeless to rigorously test
            email addresses with regular expressions?

            Your code above will fail to match some legal addresses...


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


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

Date: 12 Oct 1998 18:38:46 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Why it doesn't work under UNIX??????
Message-Id: <6vter6$b9$1@gellyfish.btinternet.com>

On Sun, 11 Oct 1998 10:36:11 -0700 Andrew Perrin 
<aperrin@mcmahon.qal.berkeley.edu> wrote:
> I deeply apologize for my incorrect and snide answer to the original poster.
> 

Contrition ? Hah he must be taking the piss ;-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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