[11766] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5366 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 22:17:27 1999

Date: Mon, 12 Apr 99 19:00:18 -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 Apr 1999     Volume: 8 Number: 5366

Today's topics:
        Can Perl implement a state machine? <Jeffrey_Davey-P93404@email.mot.com>
    Re: Help with submiting a form from a script (Ran)
    Re: HELP! - A very simple problem, I'm sure... <rick.delaney@home.com>
    Re: Help! I can't create an error response from this sc <rick.delaney@home.com>
    Re: How do I delete text in a file? <bwebb@fred.net>
    Re: How do I simply delete a file in CGI? (Sam Holden)
        How to write a format to an array instead of a filehand branboles@netscape.net
    Re: How to write a format to an array instead of a file <cassell@mail.cor.epa.gov>
    Re: How to write a format to an array instead of a file <uri@home.sysarch.com>
    Re: How to write a format to an array instead of a file <rick.delaney@home.com>
    Re: implement useradd in perl <rick.delaney@home.com>
        Installing Modules on 95 <jkhertog@worldnet.att.net>
    Re: Installing Modules on 95 <cassell@mail.cor.epa.gov>
    Re: Is it possible to have "..." appear while processin (Sam Holden)
    Re: Perl regexps compared to Python regexps (Sam Holden)
    Re: Perl regexps compared to Python regexps (Lindsey)
    Re: Q: Hash tables!!! <mpersico@bestweb.net>
    Re: Q: Hash tables!!! (Sam Holden)
    Re: Removing last space (Aaron B. Dossett)
    Re: stripping spaces out (Abigail)
    Re: stripping spaces out <dgris@moiraine.dimensional.com>
    Re: stripping spaces out (Andrew Johnson)
    Re: Suit case or backpack (Abigail)
    Re: Suit case or backpack <emschwar@rmi.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 12 Apr 1999 10:52:01 -0700
From: Jeffrey Davey <Jeffrey_Davey-P93404@email.mot.com>
Subject: Can Perl implement a state machine?
Message-Id: <371232C1.F32055D1@email.mot.com>

Greetings!

I was wondering if anyone knows how adept Perl is at implementing a
state machine.  The type we'd like to use is one that is table-driven,
in that functions called within a state are referenced from within an
array.  Haven't seen yet that Perl can do this.

Pointers to relevant information would be welcome.

Thanks in advance,

Jeff Davey


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

Date: Tue, 13 Apr 1999 01:15:33 GMT
From: ran@netgate.net    (Ran)
Subject: Re: Help with submiting a form from a script
Message-Id: <923966133.017.83@news.remarQ.com>

In <37124C6D.2A587FE7@umb.edu>, Alejandro Eluchans <alejandro.eluchans@umb.edu> writes:

>What I'm trying to do is create a crawler that submits to a cgi (this cgi
>handles a web form).
>So I may store the results from the cgi  into my crawler.
>(trying to download a database)

Look for a thread entitled "Retrieving  info after POSTing from a perl 
script" from about 2 weeks ago.  It included some good code examples,
and also info on how I got the same sort of thing to work with a 
different website that behaved a little differently from the one the 
original poster was asking about.

Ran




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

Date: Tue, 13 Apr 1999 00:59:52 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: HELP! - A very simple problem, I'm sure...
Message-Id: <37129909.52292A92@home.com>

Tad McClellan wrote:
> 
> Rick Delaney (rick.delaney@home.com) wrote:
> 
> : The first two lines are important and will catch a lot of mistakes 
> : you may make.
> 
>    Like the one on the third line.   heh, heh...

I meant to do that. --Pee-Wee Herman

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 13 Apr 1999 01:15:47 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Help! I can't create an error response from this script
Message-Id: <37129CC4.52230F49@home.com>

[posted & mailed]

Gareth Jones wrote:
> 
> Is there any way of getting this script to display HTML code on an error
> e.g. if the smtp server unavailable, rather than a blank page!

    use CGI;
    use CGI::Carp 'fatalsToBrowser';

or if you really hate modules so much you can dup stderr to stdout

perldoc -f open

or you can catch your die's with $SIG{__DIE__} and do whatever you want
with them.

perldoc perlvar
perldoc perlipc

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Mon, 12 Apr 1999 20:04:57 -0400
From: "Robert E Webb" <bwebb@fred.net>
Subject: Re: How do I delete text in a file?
Message-Id: <9SvQ2.500$G4.662376@news.abs.net>

Here is a script from Tom Christiansen that I found some time ago. It was
modified to fix a regex bug in Perl versions below 5.003 I believe.

HTH
Bob/



#!/usr/bin/perl -p0777
#
#########################################################
# striphtml ("striff tummel")
# tchrist@perl.com
# version 1.0: Thu 01 Feb 1996 1:53:31pm MST
# version 1.1: Sat Feb  3 06:23:50 MST 1996
#   (fix up comments in annoying places)
#########################################################
#
# how to strip out html comments and tags and transform
# entities in just three -- count 'em three -- substitutions;
# sed and awk eat your heart out.  :-)
#
# as always, translations from this nacri rendition into
# more characteristically marine, herpetoid, titillative,
# or indonesian idioms are welcome for the furthering of
# comparitive cyberlinguistic studies.
#
#########################################################

require 5.002;      # for nifty embedded regexp comments

#########################################################
# first we'll shoot all the <!-- comments -->
#########################################################

s{ <!                   # comments begin with a `<!'
                        # followed by 0 or more comments;

    (.*?)  # this is actually to eat up comments in non
   # random places

     (                  # not suppose to have any white space here

                        # just a quick start;
      --                # each comment starts with a `--'
        .*?             # and includes all text up to and including
      --                # the *next* occurrence of `--'
        \s*             # and may have trailing while space
                        #   (albeit not leading white space XXX)
     )+                 # repetire ad libitum  XXX should be * not +
    (.*?)  # trailing non comment text
   >                    # up to a `>'
}{
    if ($1 || $3) { # this silliness for embedded comments in tags
 "<!$1 $3>";
    }
}gesx;                 # mutate into nada, nothing, and niente

#########################################################
# next we'll remove all the <tags>
#########################################################

s{ <                    # opening angle bracket

    (?:                 # Non-backreffing grouping paren
         [^>'"] *       # 0 or more things that are neither > nor ' nor "
            |           #    or else
         ".*?"          # a section between double quotes (stingy match)
            |           #    or else
         '.*?'          # a section between single quotes (stingy match)
    ) +                 # repetire ad libitum
                        #  hm.... are null tags <> legal? XXX
   >                    # closing angle bracket
}{}gsx;                 # mutate into nada, nothing, and niente

#########################################################
# finally we'll translate all &valid; HTML 2.0 entities
#########################################################

s{ (
        &              # an entity starts with a semicolon


     \x23\d+    # and is either a pound (#) and numbers
      |        #   or else
     \w+        # has alphanumunders up to a semi
 )
        ;?             # a semi terminates AS DOES ANYTHING ELSE (XXX)
    )
} {

    $entity{$2}        # if it's a known entity use that
        ||             #   but otherwise
        $1             # leave what we'd found; NO WARNINGS (XXX)

}gex;                  # execute replacement -- that's code not a string

#########################################################
# but wait! load up the %entity mappings enwrapped in
# a BEGIN that the last might be first, and only execute
# once, since we're in a -p "loop"; awk is kinda nice after all.
#########################################################

BEGIN {

    %entity = (

        lt     => '<',     #a less-than
        gt     => '>',     #a greater-than
        amp    => '&',     #a nampersand
        quot   => '"',     #a (verticle) double-quote

        nbsp   => chr 160, #no-break space
        iexcl  => chr 161, #inverted exclamation mark
        cent   => chr 162, #cent sign
        pound  => chr 163, #pound sterling sign CURRENCY NOT WEIGHT
        curren => chr 164, #general currency sign
        yen    => chr 165, #yen sign
        brvbar => chr 166, #broken (vertical) bar
        sect   => chr 167, #section sign
        uml    => chr 168, #umlaut (dieresis)
        copy   => chr 169, #copyright sign
        ordf   => chr 170, #ordinal indicator, feminine
        laquo  => chr 171, #angle quotation mark, left
        not    => chr 172, #not sign
        shy    => chr 173, #soft hyphen
        reg    => chr 174, #registered sign
        macr   => chr 175, #macron
        deg    => chr 176, #degree sign
        plusmn => chr 177, #plus-or-minus sign
        sup2   => chr 178, #superscript two
        sup3   => chr 179, #superscript three
        acute  => chr 180, #acute accent
        micro  => chr 181, #micro sign
        para   => chr 182, #pilcrow (paragraph sign)
        middot => chr 183, #middle dot
        cedil  => chr 184, #cedilla
        sup1   => chr 185, #superscript one
        ordm   => chr 186, #ordinal indicator, masculine
        raquo  => chr 187, #angle quotation mark, right
        frac14 => chr 188, #fraction one-quarter
        frac12 => chr 189, #fraction one-half
        frac34 => chr 190, #fraction three-quarters
        iquest => chr 191, #inverted question mark
        Agrave => chr 192, #capital A, grave accent
        Aacute => chr 193, #capital A, acute accent
        Acirc  => chr 194, #capital A, circumflex accent
        Atilde => chr 195, #capital A, tilde
        Auml   => chr 196, #capital A, dieresis or umlaut mark
        Aring  => chr 197, #capital A, ring
        AElig  => chr 198, #capital AE diphthong (ligature)
        Ccedil => chr 199, #capital C, cedilla
        Egrave => chr 200, #capital E, grave accent
        Eacute => chr 201, #capital E, acute accent
        Ecirc  => chr 202, #capital E, circumflex accent
        Euml   => chr 203, #capital E, dieresis or umlaut mark
        Igrave => chr 204, #capital I, grave accent
        Iacute => chr 205, #capital I, acute accent
        Icirc  => chr 206, #capital I, circumflex accent
        Iuml   => chr 207, #capital I, dieresis or umlaut mark
        ETH    => chr 208, #capital Eth, Icelandic
        Ntilde => chr 209, #capital N, tilde
        Ograve => chr 210, #capital O, grave accent
        Oacute => chr 211, #capital O, acute accent
        Ocirc  => chr 212, #capital O, circumflex accent
        Otilde => chr 213, #capital O, tilde
        Ouml   => chr 214, #capital O, dieresis or umlaut mark
        times  => chr 215, #multiply sign
        Oslash => chr 216, #capital O, slash
        Ugrave => chr 217, #capital U, grave accent
        Uacute => chr 218, #capital U, acute accent
        Ucirc  => chr 219, #capital U, circumflex accent
        Uuml   => chr 220, #capital U, dieresis or umlaut mark
        Yacute => chr 221, #capital Y, acute accent
        THORN  => chr 222, #capital THORN, Icelandic
        szlig  => chr 223, #small sharp s, German (sz ligature)
        agrave => chr 224, #small a, grave accent
        aacute => chr 225, #small a, acute accent
        acirc  => chr 226, #small a, circumflex accent
        atilde => chr 227, #small a, tilde
        auml   => chr 228, #small a, dieresis or umlaut mark
        aring  => chr 229, #small a, ring
        aelig  => chr 230, #small ae diphthong (ligature)
        ccedil => chr 231, #small c, cedilla
        egrave => chr 232, #small e, grave accent
        eacute => chr 233, #small e, acute accent
        ecirc  => chr 234, #small e, circumflex accent
        euml   => chr 235, #small e, dieresis or umlaut mark
        igrave => chr 236, #small i, grave accent
        iacute => chr 237, #small i, acute accent
        icirc  => chr 238, #small i, circumflex accent
        iuml   => chr 239, #small i, dieresis or umlaut mark
        eth    => chr 240, #small eth, Icelandic
        ntilde => chr 241, #small n, tilde
        ograve => chr 242, #small o, grave accent
        oacute => chr 243, #small o, acute accent
        ocirc  => chr 244, #small o, circumflex accent
        otilde => chr 245, #small o, tilde
        ouml   => chr 246, #small o, dieresis or umlaut mark
        divide => chr 247, #divide sign
        oslash => chr 248, #small o, slash
        ugrave => chr 249, #small u, grave accent
        uacute => chr 250, #small u, acute accent
        ucirc  => chr 251, #small u, circumflex accent
        uuml   => chr 252, #small u, dieresis or umlaut mark
        yacute => chr 253, #small y, acute accent
        thorn  => chr 254, #small thorn, Icelandic
        yuml   => chr 255, #small y, dieresis or umlaut mark
    );

    ####################################################
    # now fill in all the numbers to match themselves
    ####################################################
    for $chr ( 0 .. 255 )

        $entity{ '#' . $chr } = chr $chr;
    }
}

#########################################################
# premature finish lest someone clip my signature
#########################################################

__END__

<title>Tom Christiansen's Mox.Perl.COM Home Page</title>
<BODY BGCOLOR=#ffffff TEXT=#000000>
<!--

<BODY BGCOLOR="#000000" TEXT="#FFFFFF"
      LINK="#FFFF00" VLINK="#22AA22" ALINK="#0077FF">

!-->



<A NAME=TOP>

<CENTER>
<h3>
<A HREF="#PERL">perl</a> /
<A HREF="#MAGIC">magic</a> /
<A HREF="#USENIX">usenix</a> /
<A HREF="#BOULDER">boulder</a>
</h3>
<BR>
The word of the day is <i>nidificate</i>.
</CENTER>

Testing: &#69; &#202; &Auml;
</a>

<HR NOSHADE SIZE=3>

<A NAME=PERL>
<CENTER>
<h1>
<IMG SRC="/deckmaster/gifs/camel.gif" ALT="">
<font size=7>
Perl
</font>
<IMG SRC="/deckmaster/gifs/camel.gif" ALT="">
</h1>
</a>

DOCTYPE START1
<!DOCTYPE  HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
  -- This is an annoying comment > --
>
END1

DOCTYPE START2
<!DOCTYPE  HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
  -- This is an annoying comment  --
>
END2



<I>
<BLOCKQUOTE>
<DL><DT>A ship then new they built for him
<DD>of mithril and of elven glass...
</DL>
</I>
</BLOCKQUOTE>
</CENTER>

<HR size=3 noshade>

<UL>
<LI>
<A HREF="/perl/CPAN/README.html">CPAN
(Comprehensive Perl Archive Network)</a> sites are replicated around the
world; please choose
from <A HREF="/perl/CPAN/CPAN.html">one near you</a>.
The <A
HREF="ftp://mox.perl.com/pub/perl/CPAN/modules/01modules.index.html">CPAN
index</a>
to the <A
HREF="ftp://mox.perl.com/pub/perl/CPAN/modules/00modlist.long.html">full
modules file</a>
are also good places to look.

<LI><IMG SRC="/deckmaster/gifs/new.gif" WIDTH=26 HEIGHT=13 ALT="NEW">
Here's a table of perl and CGI-related books and publications, in either
<A HREF="/perl/info/books.html"><SMALL>HTML</SMALL> 3.0 table format</a>
or else in
<A HREF="/perl/info/books.txt">pre-formatted</a> for old browsers.



Gabriel Richards <grichard@uci.edu> wrote in message
news:7et5vr$95n@news.service.uci.edu...
> Is there a function which will allow me to delete text from a file? I want
> to delete all the tags in an HTML file just leaving the content.
>
> Gabe
>
>




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

Date: 13 Apr 1999 01:10:08 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How do I simply delete a file in CGI?
Message-Id: <slrn7h56bg.5k0.sholden@pgrad.cs.usyd.edu.au>

On Mon, 12 Apr 1999 13:55:01 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>In article <MPG.117c1dff68552385989682@news.idt.net> on Mon, 12 Apr 1999 
>16:13:36 -0500, Daniel Beckham <danbeck@qual.net> says...
>> Just as a FYI, CGI is the Common Gateway Interface and has nothing in the 
>> world to do with perl.  You can write CGI apps in python, VB <shudder>, 
>> C/C++ and pretty much any other language that can read from STDIN and 
>> write to STDOUT.  
>
><Perl commercial>
>
>Notably, I implemented my first CGI program using csh!  When I saw how 
>'fast' that ran, I bought my first Perl books and tried again.  Those 
>books have now been thrown out, but the program survives.

I've got this web server (not written by me luckily - though I've made
some local modifications) running on a machine on my desk that is implemented
in sh. 

It is I must admit a *very* limited web server that can't really do much,
although it does fulfil its requirements.

-- 
Sam

Perl is the Cliff Notes of Unix.
	--Larry Wall


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

Date: Tue, 13 Apr 1999 00:02:41 GMT
From: branboles@netscape.net
Subject: How to write a format to an array instead of a filehandle?
Message-Id: <7eu1it$m9e$1@nnrp1.dejanews.com>

Hello all,

I am trying to use a format and write it to an array instead of it going to
standard output.  I would like to do something like this:

@newarray=write FORMAT;

I don't want to use a temporary file, if I can get around it.  Is there any
way to do this?  Any help would be greatly appreciated!  THANKS!

Brandon Boles
branboles@netscape.net

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 12 Apr 1999 17:31:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to write a format to an array instead of a filehandle?
Message-Id: <37129049.13C6CF90@mail.cor.epa.gov>

branboles@netscape.net wrote:
> 
> Hello all,
> 
> I am trying to use a format and write it to an array instead of it going to
> standard output.  I would like to do something like this:
> 
> @newarray=write FORMAT;
> 
> I don't want to use a temporary file, if I can get around it.  Is there any
> way to do this?  Any help would be greatly appreciated!  THANKS!

Umm, pardon my confusion, but why?  Really, I'd like to know.

write() sends output to a filehandle.  It isn't designed for outputting
to a named array, which is *not* a filehandle.

If you're trying to set up tables on a website, this isn't the way to
go.
Proportional fonts won't pay any attention to your alignment.

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 12 Apr 1999 20:40:28 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: How to write a format to an array instead of a filehandle?
Message-Id: <x7k8vhpd37.fsf@home.sysarch.com>

>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:

  DC> branboles@netscape.net wrote:
  >> 
  >> I am trying to use a format and write it to an array instead of it going to
  >> standard output.  I would like to do something like this:
  >> 
  >> @newarray=write FORMAT;
  >> 
  >> I don't want to use a temporary file, if I can get around it.  Is there any
  >> way to do this?  Any help would be greatly appreciated!  THANKS!

  DC> Umm, pardon my confusion, but why?  Really, I'd like to know.

i don't know his reasons but i could imagine some very easily. i tend to
build strings before i print them so i can send them to multiple places.

  DC> write() sends output to a filehandle.  It isn't designed for outputting
  DC> to a named array, which is *not* a filehandle.

but the format stuff has a func called formline which does exactly what
the poster wants. it formats to $^A. see perlform for more info.

  DC> If you're trying to set up tables on a website, this isn't the way
  DC> to go.  Proportional fonts won't pay any attention to your
  DC> alignment.

true but he didn't mention nor hint that this was a web related
request. but format could be used on the web with some fixed font html
like PRE, etc.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 13 Apr 1999 01:05:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to write a format to an array instead of a filehandle?
Message-Id: <37129A68.73D1932E@home.com>

[posted & mailed]

branboles@netscape.net wrote:
> 
> I am trying to use a format and write it to an array instead of it 
> going to standard output.

You should be able to modify the solution from perlfaq5, "How can I
write() into a string?"

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 13 Apr 1999 00:55:53 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: implement useradd in perl
Message-Id: <3712981B.E291AB23@home.com>

Sam Holden wrote:
> 
> I must admit I wouldn't use system() at all, unless I was being a 
> smart-ass and just calling an existing 'useradd'.

I see you understand me.  

You and Uri are obviously more experienced than I.  Don't all Unices
come with a useradd?

> When I said the same way, I was trying to politely say that it wasn't 
> a perl question...

Oops, forget I asked that.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Mon, 12 Apr 1999 20:08:20 -0400
From: "Justin K. Hertog" <jkhertog@worldnet.att.net>
Subject: Installing Modules on 95
Message-Id: <37128AF4.1CFD6A73@worldnet.att.net>

Hello All,

I just got the code for LWP and several other modules.  I'm using Perl
5.004, and it looks like I'll have to use a C compiler to build the
sources.  Can I use Borland C++ (5.0) for this purpose?  Am I on the
totally wrong track?  Someone want to set a total newbie straight?

Thank You,

Justin K. Hertog


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

Date: Mon, 12 Apr 1999 17:26:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Installing Modules on 95
Message-Id: <37128F39.8862C3E@mail.cor.epa.gov>

Justin K. Hertog wrote:
> 
> Hello All,
> 
> I just got the code for LWP and several other modules.  I'm using Perl
> 5.004, and it looks like I'll have to use a C compiler to build the
> sources.  Can I use Borland C++ (5.0) for this purpose?  Am I on the
> totally wrong track?  Someone want to set a total newbie straight?
> 
> Thank You,
> 
> Justin K. Hertog

Upgrade to 5.005 .  Get ActiveState's Perl and download it.  It
installs nicely, and comes with a number of modules already set up.
Any modules you still need can be snarfed down using the ppm program,
as per the on-line instructions that come with the installation.

I'm assuming from your thoughts on a C compiler that you didn't compile
the version now on your system, so this is probably the way to go.

HTH,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 13 Apr 1999 01:05:53 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Is it possible to have "..." appear while processing?
Message-Id: <slrn7h563h.5k0.sholden@pgrad.cs.usyd.edu.au>

On 12 Apr 1999 17:21:41 GMT, Abigail <abigail@fnx.com> wrote:
>Poohba (poohba@io.com) wrote on MMXLVIII September MCMXCIII in
><URL:news:Pine.BSF.4.05.9904101039090.19025-100000@schultz.io.com>:
>:: If so how?...I have a program that takes a little while to complete but i
>:: don't want the user to abort so i would like something to be happening so
>:: i thought maybe i could have ... appear as long as it is processing.  When
>:: I say ... i mean the dots keep coming til program is complete.
>
>
>unless ($pid = fork) {
>    die "Could not fork\n" unless defined $pid;
>    print "." while 1;
>    exit;
>}
>
>
># Your program here.
>
>
>kill 9, $pid;
>exit;


That's an aweful lot of dots...

The bahaviour will probably be not what is wanted if that fork() fails too...
Though if fork() fails you probably have bigger things to worry about then
the current program...


-- 
Sam

I don't want Perl to be beautiful--I want you to write beautiful
programs in Perl.
	--Larry Wall


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

Date: 13 Apr 1999 00:41:08 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl regexps compared to Python regexps
Message-Id: <slrn7h54l4.5k0.sholden@pgrad.cs.usyd.edu.au>

On Mon, 12 Apr 1999 13:49:09 GMT, matthew.freake@smlawpub.co.uk wrote:
>Without wishing to start a Perl vs Python discussion, I was wondering does
>anyone out there know if there are any major differences between the the two
>languages implementations of regular expressions. Lots of net resources seem
>to imply that Python's implementation is less powerful but with my limited
>use of Python and having looked at the documentation, I cannot really find
>any evidence for this. Have I picked up the wrong end of the stick or am I
>missing something ?

I'm not a python expert by any stretch of the imagination so I'm probably
wrong, but I'll blab anyway...

I believe python regular expression are as powerful as older perl 
regular expressions. I think python uses perl style regular expressions now,
but not the cutting edge version. This means python misses out on the
newer features that no one knows about anyway? Look-behind is an example
I believe (I could be wrong on this).

To confuse matters python has two regular expression libraries. The older one
is not like perl at all. The newer one is perl style. If the documentation
you are looking at is old or regarding the older style regexes they won't
be perl like at all.

I think th 're' library is the perl like one, and 'regexp' the other one. I
might have it backwards of course.

A python user will know much better than clpm readers...


-- 
Sam

So I did some research. On the Web, of course. Big mistake...
	--Larry Wall


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

Date: Tue, 13 Apr 1999 01:38:57 GMT
From: ldubb@u.washington.edu (Lindsey)
Subject: Re: Perl regexps compared to Python regexps
Message-Id: <ldubb-1204991839080001@c36852-a.sttln1.wa.home.com>

In article <slrn7h54l4.5k0.sholden@pgrad.cs.usyd.edu.au>,
sholden@cs.usyd.edu.au wrote:

> I believe python regular expression are as powerful as older perl 
> regular expressions. I think python uses perl style regular expressions now,
> but not the cutting edge version. This means python misses out on the
> newer features that no one knows about anyway? Look-behind is an example
> I believe (I could be wrong on this).

Python's "re" is based on Philip Hazel's PCRE, and is extremely similar
to Perl 5.005's regular expressions.  It's got lookbehind, once-only
subpatterns, and conditional subpatterns, as well as the earlier stuff.
I don't know how they compare in terms of performance, though I'd be
interested in hearing anyone's experience.

-- 
9:)     Lindsey Dubb     ldubb@u.washinton.edu


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

Date: Tue, 13 Apr 1999 00:07:45 GMT
From: "Matthew O. Persico" <mpersico@bestweb.net>
Subject: Re: Q: Hash tables!!!
Message-Id: <37128B1E.F89D92E8@bestweb.net>

"Jim Kangosjdrvi" wrote:
> 
> Hi
> 
> When i create a hash table and then add 1000's of variables to it then it
> grows few MB (ex. 5 MB).
> And when i Delete all the Variables, the size of the hash table is still
> several 5 MB.
> 
> Why doesnt it decrease?
> 
> Please, show a small Source example how i should write if i want to decrease
> the database when i delete data from the hash table.
> 
> Please mail to Jim.Kangosjarvi@Abc.se
> 
> Thanks, Jim

The idea is that memory is cheap, but allocating it is an expensive operation in terms of time. You do not want to be dealloc and realloc 'ing memory over and over so once you have it, you've got it makgin reallocation cheaper.
-- 
Matthew O. Persico


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

Date: 13 Apr 1999 01:32:43 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Q: Hash tables!!!
Message-Id: <slrn7h57lr.9gm.sholden@pgrad.cs.usyd.edu.au>

Jim Kangosjdrvi <Jim.Kangosjarvi@Abc.se> wrote:
>Hi
>
>When i create a hash table and then add 1000's of variables to it then it
>grows few MB (ex. 5 MB).
>And when i Delete all the Variables, the size of the hash table is still
>several 5 MB.
>
>Why doesnt it decrease?
>
>Please, show a small Source example how i should write if i want to decrease
>the database when i delete data from the hash table.

Memory is cheap. Allocating memory takes time. Thus I suspect perl keeps
the memory around to reuse later on. Since in most cases the hash will 
grow again.

Even if perl did free the memory, there is a chance that it wouldn't be
returned to the OS anyway. Depending on your OS of course (and your libc
I guess).

-- 
Sam

I took the initiative in creating the Internet. 
	--Al Gore


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

Date: 13 Apr 1999 00:15:39 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: Removing last space
Message-Id: <7eu2bb$4po$1@news.uky.edu>

Larry Rosler (lr@hpl.hp.com) wrote:
: 
: I would answer the literal question that was actually asked this way:
: 
:     s/ (?=[^ ]*$)//
: 
: This indeed removes the last space from a variable -- only one space, 
: the last one in the string (but not necessarily a 'trailing' space).
:  

I'm glad I wasn't the only person who interpreted the question that way.
What immeadiately popped into my mind was:

      s/^(.*) (.*)$/$1$2/;

But I'm sure yours is much faster.

-Aaron




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

Date: 13 Apr 1999 00:08:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: stripping spaces out
Message-Id: <7eu1uc$8nr$1@client2.news.psi.net>

Steve Linberg (linberg@literacy.upenn.edu) wrote on MML September
MCMXCIII in <URL:news:linberg-1204991214170001@ltl1.literacy.upenn.edu>:
[] 
[] An interesting hack that could be useful would be a Perl interpreter that
[] would decelerate your machine as punishment when it runs into small,
[] inefficient constructs or operations like <s/ //g>, so you'd feel the pain
[] more.  :)  With 450 mhz machines now cheaper than original Apple IIs, who
[] notices anymore?


You don't understand Perl. Perl is supposed to be your friend, and you
should not be a slave to your computer.

An interesting bugfix would be to have s/ //g not be significantly slower
than tr/ //d.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: 12 Apr 1999 18:10:59 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: stripping spaces out
Message-Id: <m3iub11iss.fsf@moiraine.dimensional.com>

[mailed and posted]

lr@hpl.hp.com (Larry Rosler) writes:

> In article <7etl4r$44a$1@gellyfish.btinternet.com> on 12 Apr 1999 
> 20:30:19 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
> ...
> > Anyhow just for fun and as antedote for all this regexry and translation
> > here is possibly the most *inefficient* way I can think of doing this:

<snip something horrible :-)>

> You could do worse by using an indexed loop:
> 
> my @chars = split //, $string;
> for (my $i = 0; $i < @chars; $i++) {
>   $newstring .= $chars[$i] if $chars[$i] ne ' ';
> }
> 
> There.  That looks much more like C and is surely slower.

I mean this with all due respect- but when we want slow code around
here we want slow _perl_ code.  Any geek off the street can write
inefficient C, but it takes a special kind of geek to really mess
perl up. :-)

Try this for bad-

my @chars = split /(?=)/, $string;
for (my $i = 0; $i < @chars; ) {
    if ( $chars[$i] =~ / / ) {
        splice @chars, $i, 1;
        next;
    }
    $i++;
}
my $newstring = join '', @chars;


> But I would write those ugly loops as a one-liner:
>
> my $newstring = join "", grep $_ ne ' ', split //, $string;

Here's my one liner for the slowest way to remove all
of the spaces from a string.

$new = join " \b", grep {!/ /} split 
       /(?<!help me! I can't stop myself)/, $string;

Yuck.

:-)

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Tue, 13 Apr 1999 01:26:08 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: stripping spaces out
Message-Id: <Q2xQ2.344$Rn2.77884@news1.rdc1.on.wave.home.com>

In article <7etl4r$44a$1@gellyfish.btinternet.com>,
 Jonathan Stowe <gellyfish@gellyfish.com> wrote:

[snip]
 
! Eeeek.
! 
! Of course one will have to see the section entitled:
! 
!        Regexp Quote-Like Operators
! 
! in the perlop manpage for that bit.
! 
! Anyhow just for fun and as antedote for all this regexry and translation
! here is possibly the most *inefficient* way I can think of doing this:
! 
! 
! #!/usr/bin/perl -w
! 
! use strict;
! 
! my $string = '  this is a  string with space in it';
! 
! my $newstring;
! 
! foreach (split //,$string)
! {
!   $newstring .= $_ if $_ ne ' ';
! }
! 
! print $newstring;  
! 

but your antidote still contains a drop of the regex toxin in
the split() call ...

my $string = '  this is a  string with space in it';
substr($string, $pos, 1)  = '' while ($pos = index $string,' ' ) >= 0;
print $string;

regards
andrew


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

Date: 13 Apr 1999 00:10:19 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Suit case or backpack
Message-Id: <7eu21b$8nr$2@client2.news.psi.net>

Stanley Horwitz (stan@tempest.temple.edu) wrote on MML September MCMXCIII
in <URL:news:7et0ns$2du$2@cronkite.ocis.temple.edu>:
;; 
;; I think I might be going crazy, because I cannot seem to find the backpack
;; I used on my previous trip to Europe. I have searched my parents' house
;; and my own, but to no avail. I guess maybe I lent the backpack to a friend
;; and than forgot about it. This backpack was kind of on the heavy side
;; anyway so it wasn't the most convenient backpack. Anyway, I have a very
;; good hard shell American Tourister suitecase with a key lock and
;; combination locks that I am thinking of taking with me. The suit case is a
;; little on the large side though, but its more than big enough for a two
;; week trip. I am a pretty strong guy and the suit case has wheels and a
;; pull cord, but I am wondering if this will be too cumbersome to bring on
;; the trains in Italy. I could go out and get another backpack, but I 
;; would rather not spend the money, especially since I know that as soon 
;; as I buy a new one, I will find my old backpack.


You didn't make backups?




Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: 12 Apr 1999 18:26:25 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Suit case or backpack
Message-Id: <xkf6771l61a.fsf@valdemar.col.hp.com>

"Wayne Keenan" <tripix@tdi-net.freeserve.co.uk> writes:
> have you tried "Memory::Storable" function?:
> 
> sub find_backpack
> {
>     my $mem=shift;
>     $_=$memory->{"BackpackAttribs"};
>     /where_I_left_it_last:(.*)/  ?  return $1 :  return undef;
> }

No, no, you're going about it all wrong.

sub find_backpack
{
  my $mem = shift;
  $result = $mem->location{Backpack};
  return $result || undef;
}

At least, my memory indexes *much* faster on location than item.  YMMV.

-=Eric


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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