[9685] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3279 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 28 18:07:20 1998

Date: Tue, 28 Jul 98 15:00:25 -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           Tue, 28 Jul 1998     Volume: 8 Number: 3279

Today's topics:
    Re: @ISA a kludge? <zenin@bawdycaste.org>
    Re: AutoLogin <rootbeer@teleport.com>
    Re: best way of diffing two strings (Larry Rosler)
    Re: Can I use CRC to code a piece of text? <dean@mail.biol.sc.edu>
        DBM Files with Hashes of Arrays beaumack@my-dejanews.com
    Re: DBM Files with Hashes of Arrays (Michael J Gebis)
    Re: Dynamically creating graph images <a.g.macinnes@nospam.rl.ac.uk>
    Re: fork() problem <goodaci@mbs.gov.on.ca>
        glob wrecks foreach loop! <John.Adams@BentonvilleAR.ncr.com>
    Re: glob wrecks foreach loop! <rootbeer@teleport.com>
    Re: Hash reference? <rootbeer@teleport.com>
    Re: More on pattern matching (Patrick Timmins)
        Perl Embed Win32 C++ <ed@pdh.com>
    Re: Problems Running An executable from within PERL <rootbeer@teleport.com>
    Re: Reacting to 1 of 10 or so possible values.... Need  (Ilya Zakharevich)
    Re: reading a file listing? <rootbeer@teleport.com>
    Re: reading a file listing? <rootbeer@teleport.com>
    Re: s/// Regexp parsing oddity with negative lookahead  <lance@nospam.net-school.com>
    Re: s/// Regexp parsing oddity with negative lookahead  <rootbeer@teleport.com>
    Re: Simplish regular expression Question dwarren@dimensional.com
    Re: site_perl changes from 5.004_04 to 5.005_xx <zenin@bawdycaste.org>
    Re: site_perl changes from 5.004_04 to 5.005_xx <merlyn@stonehenge.com>
    Re: Sorting for Uniques (Gabor)
    Re: Transferring files from client to server <rootbeer@teleport.com>
    Re: Try perl on Ms Dos <thomas@daimi.aau.dk>
    Re: WANTED: Perl Autoreponder - Any Takers? <rootbeer@teleport.com>
    Re: Win32::OLE trouble (Jan Dubois)
        Zombies from Forking are Bad, says Sun <slivings@digitalriver.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 28 Jul 1998 21:16:11 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: @ISA a kludge?
Message-Id: <901661174.435619@thrush.omix.com>

[posted & mailed]

Luke <Luke.Y.Lu@usa.net> wrote:
	>snip<
: inheritance should really be resolved at compile time. using @ISA array
: looks like a huge half-baked hack to realize inheritance. Why don't we
: just use something like:
: package derived, qw(base1 base2);

	Already done, but probably needs more documentation in the common
	(perl*) docs (as the docs for base also point out).  Doc patches
	are always welcome. :-)

	Anyway, it looks like this:

		package C;
		use base qw(A B);

	See perldoc base for more info.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Tue, 28 Jul 1998 21:07:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: AutoLogin
Message-Id: <Pine.GSO.4.02.9807281406280.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998, robert wrote:

> Is there any way to automate login's to web sites ? 

Yes; the LWP module can do this. You may want to make a "logging proxy"
server. For information on the protocols and such, see the specification
docs and relevant newsgroups. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 14:36:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: best way of diffing two strings
Message-Id: <MPG.1027e45078e3d76998974a@nntp.hpl.hp.com>

In article <6pl6mg$q2b@gateway.grumman.com> on 28 Jul 1998 14:53:04 -
0400, John L. Allen <allen@gateway.grumman.com> says...
 ...
> >$i=0;$i++ until substr($one,$i,1) ne substr($two,$i,1);
> >
> >but that seems likely there is a more efficient way I just haven't thought
> >of????
> 
> Use xor, and the fact that two bytes xor'ed together will be null only
> when the two bytes are the same:
> 
> 	$a = "aaaaadaaacaaf";
> 	$b = "aaaaaraaataag";
> 	$_= $a ^ $b;
> 	print "strings differ in positions: ";
> 	print pos, ", " while /\0+/g;
> 
> which, when run, will print
> 
>     strings differ in positions: 5, 9, 12,
> 
> Unfortunately, it still does a pattern match.

This doesn't.  It combines the substr from original proposal with the xor 
you proposed:

  	$a = "aaaaadaaacaaf";
  	$b = "aaaaaraaataag";
  	$x = $a ^ $b;
 	print "strings differ in positions: ";
  	print join(', ', grep substr($x, $_, 1) ne "\0",
              0 .. length($x) - 1), "\n";

      strings differ in positions: 5, 9, 12

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 28 Jul 1998 16:36:43 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
To: Ggendrea@esrin.esa.it (Gaspard Gendreau)
Subject: Re: Can I use CRC to code a piece of text?
Message-Id: <m3g1flww4k.fsf@mail.biol.sc.edu>

Ggendrea@esrin.esa.it (Gaspard Gendreau) writes:
> I need to identify a piece of text in a code which should be made of
> characters valid for UNIX file names. I only need to encode the text, I'll
 ...
> I will use this code to quickly know if I already have a file with the
> same piece of text. Ideally, the code should be around 32 characters.
> 
> Can I use the CRC (Cyclic redundency check generation) for this? 
> What about String::CRC found on CPAN?
> Is there any better method?

I'd imagine that the MD5 module might be a better choice -- it's
designed to do just about what you're looking for.

Best of luck!

-Dean
-- 
N. Dean Pentcheff                                          <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)


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

Date: Tue, 28 Jul 1998 20:45:33 GMT
From: beaumack@my-dejanews.com
Subject: DBM Files with Hashes of Arrays
Message-Id: <6pld9e$td3$1@nnrp1.dejanews.com>

I am trying to store a hash of arrays in a DBM file, and I've been having
some trouble.  I want to store a series of values associated with keys in a
file, so I thought the easiest way would be to place all of the values in an
array, then store that array in a hash.  This idea works well within a single
run of the program, but when the program tries to access this information
from a DBM file, the array is no longer there.	When I try to print the
array, I get ARRAY(0x8169aa4) which looks more like the memory address of an
array rather than the actual array itself.

Can I store this data in a DBM file or does anyone have a better way to store
this information?

-Beau Mack

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 28 Jul 1998 21:34:47 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: DBM Files with Hashes of Arrays
Message-Id: <6plg5n$3vp@mozo.cc.purdue.edu>

beaumack@my-dejanews.com writes:

}I am trying to store a hash of arrays in a DBM file, and I've been having
}some trouble.  I want to store a series of values associated with keys in a
}file, so I thought the easiest way would be to place all of the values in an
}array, then store that array in a hash.  This idea works well within a single
}run of the program, but when the program tries to access this information
}from a DBM file, the array is no longer there.	When I try to print the
}array, I get ARRAY(0x8169aa4) which looks more like the memory address of an
}array rather than the actual array itself.

}Can I store this data in a DBM file or does anyone have a better way to store
}this information?

MLDBM

See CPAN.


-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Tue, 28 Jul 1998 12:00:57 +0100
From: Andrew MacInnes <a.g.macinnes@nospam.rl.ac.uk>
Subject: Re: Dynamically creating graph images
Message-Id: <35BDAF68.A1683A11@nospam.rl.ac.uk>

Joseph M Carlton wrote:

> I am using perl to fetch data from a database for a web project that I am
> working on. Now, I need to dynamically build a bar graph with this data.
> Someone told me that I could use javascript and somebody told me that I
> could do the whole thing in perl. I have not been able to find any
> information on this topic for either javascript or perl.  Could someone
> PLEASE direct me to a book or web page with information on this?  I am
> not limited to perl and javascript, so if anyone knows of a better way to
> do this.  I would be VERY appreciative.  Thanks in advance for your help.

I have just finished almost exactly the same project.  Initially I used
Lincon Stein's GD.pm which was a great starting point but I found GIFgraph
suited my needs a lot better.  It is very simple to use and there are some
easy examples to follow.  It does bar charts, histograms, line graphs etc..

Hope this helps.

Andrew MacInnes

----------------------------------------------------------
- RAL                       E-mail:A.G.MacInnes@rl.ac.uk -
- DCI                  Telephone (direct): (01235)446104 -
- Atlas Building                                         -
- R27 - F31                                  Disclaimer: -
- Chilton, Didcot     These opinions are my own and most -
- Oxon, OX11 0QX      probably not that of my employers. -
----------------------------------------------------------




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

Date: Tue, 28 Jul 1998 17:25:28 -0400
From: Ian Goodacre <goodaci@mbs.gov.on.ca>
Subject: Re: fork() problem
Message-Id: <35BE41C8.908335BB@mbs.gov.on.ca>

I had a similar problem. I thought it might have to do with buffering of
I/O, but looping forever suggests otherwise. If you try
"exec('/bin/true');" in place of the "exit;", you may get the behaviour you
expect. Of course this doesn't explain why it is doing the "wrong" thing. I
gave up and rewrote in C.

Good luck.




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

Date: Tue, 28 Jul 1998 15:44:24 -0500
From: John Adams <John.Adams@BentonvilleAR.ncr.com>
Subject: glob wrecks foreach loop!
Message-Id: <35BE3828.3DE4@BentonvilleAR.ncr.com>

I've tried to figure this out since last week, and I'm still stumped.

What's happening is that the (-e glob $filename) evaluates as true for
as many times in the foreach loop as it finds files that match the glob.
That makes no sense to me! Is there something going on under the hood of
glob that I don't know about or understand?

Here's the code that's giving me the problem, along with two lines added
on top for diagnostic purposes:

if (-e glob "isp0001.inventory.????????????") { print "0001okay!\n"; }
if (-e glob "isp0002.inventory.????????????") { print "0002okay!\n"; }

foreach $key (sort keys %numzone) {
 print "$key\t$numzone{$key}\n";
 $storefile = "isp" . "$key" . ".inventory.????????????";
   if (-e glob $storefile) {
        print glob $storefile ;
        print "\n";
        print "Yassir! $key\n";
   } else {
        print "Nossir! $key\n";
   }
}


There are files called isp0001.inventory.199807061643 and
isp0002.inventory.199807141011. I get a printout of:

0001okay!
0002okay!
0001    648M00
isp0001.inventory.199807061643
Yassir! 0001
0002    123D56
Nossir! 0002
0003    322K30
Nossir! 0003

That's not right. I should get another Yassir! for 0002.

Now the _really_ strange part. When I did this:

touch isp0001.inventory.199899999999

I got this output:

0001okay!
0002okay!
0001    648M00
isp0001.inventory.199807061643isp0001.inventory.199999999999
Yassir! 0001
0002    123D56
isp0002.inventory.199807141011
Yassir! 0002
0003    322K30
Nossir! 0003

Now, that's weird! And when I did this:

touch isp0001.inventory.199899999998

I got this!:

0001okay!
0002okay!
0001    648M00
isp0001.inventory.199807061643isp0001.inventory.199999999998isp0001.inventory.199899999999
Yassir! 0001
0002    123D56
isp0002.inventory.199807141011
Yassir! 0002
0003    322K30
                                        <----Blank line in the output!
Yassir! 0003

Now, why would the number of files found to exist in the conditional be
equal to the number of consecutive times through the outer loop that the
conditional would be found true? I've tried N(files matching isp0001*)=4
and gotten consistent (that is to say, equally weird) results.

I'm really bamfoozled on this! I've tried replacing:

if (-e glob $filename) {

        with

$filenames = glob $filename;
if (-e glob $filename) {

but the behavior is the same. I'm really out of ideas and ready to work
around it, but I just! don't! understand! this! WEIRD! BEHAVIOR!

Any help would be greatly appreciated.

	John A
	...speaking for himself, and not his fine employer


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

Date: Tue, 28 Jul 1998 21:48:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: glob wrecks foreach loop!
Message-Id: <Pine.GSO.4.02.9807281446500.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998, John Adams wrote:

> if (-e glob "isp0001.inventory.????????????") { print "0001okay!\n"; }

Do you know what a glob does in a scalar context? And why do you check
with -e? (It's not necessarily wrong, but it's unusual.)

>    if (-e glob $storefile) {
>         print glob $storefile ;

Hmmm... You're calling glob in a scalar context, then in a list context.
That's probably not what you want. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 20:54:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Hash reference?
Message-Id: <Pine.GSO.4.02.9807281353160.16612-100000@user2.teleport.com>

On Mon, 27 Jul 1998, Robert Eric Pearse wrote:

> Anybody know of a simple, easy-to-follow,
> just-what-you-need-to-get-started web reference on hashes. 

If you're dissatisfied with the docs which came with Perl, please tell us
in what way they let you down. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 21:12:03 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: More on pattern matching
Message-Id: <6pler3$v4b$1@nnrp1.dejanews.com>

In article <6pl3tf$bat$1@nnrp1.dejanews.com>,
  schnibitz@my-dejanews.com wrote:
> Hi all, Below is a little script I wrote that will read in a file and look
> for certain patterns.  What I want it to do is read in a page of html called
> "rogue.html." I specifically infected this page with harmful javascript.  I
> want the script to  recognize keywords within the context of a javascript,
> embedded in the html of "rogue.html."  Hope that made sense.  Anyhow, I want
> it to delete the entire javascript, if a certain pattern like "file:" is
> found.	It works great if there is only one script on the page, but if
there
> are several scripts, it sometimes deletes the wrong script.  Is there any way
> to make sure it deletes only the script(s) with the patterns/keywords and
> leaves the others untouched?  Any advice would be greatly appreciated.
>
> ~Prime
>
> ____________________________script_______________
> #!/usr/local/bin/perl -w
> use strict;
>
> my $file = 'rogue.html'; open(INFO, $file) or die "Couldn't open $file. $!";
> while (<INFO>) { if (/date/i) {  # This checks for header info that a server
> # would normally send. { local $/; $_ = <INFO>; }  # If the header starts
> with date, slurp up  # the file so that it is not read line-by-  # line. if
> (/[<]script.*file:.*script[>]/i) {# If the "file:" pattern appears in the JS,
> s!<script\s.*?</script>!!is;  # delete the entire script.  Problem is,
# how
> do I make sure that it only delets  # the harmful script, and not the others?
>  if (/embed SRC="file.{150,}/) {  s!embed!!is; } } print $_; } else { print
> $_; } } __END__
>

The deadline for the 3rd Annual Obfuscated Perl Contest is August 10, 1998.
More information can be found at http://www.tpj.com/tpj/obfusc-3

You'll need to put this via ftp to tpj.com in pub/orwant/obfuscated, or
re-post it here, with the lines wrapped properly.

Patrick Timmins
U. Nebraska Medical Center

who, in an Elijah idiom, understands your frustration, because he currently
uses Deja-News as well, which doesn't always wrap properly, because he is too
lazy and too busy and too cheap to find another newsfeed, because he used to
use "tin" from his shell account at U. Nebraska Medical Center, but he can't
anymore, because the powers that be here are "standardizing on NT" or
something, and will no longer support nntp, so I'm stuck, and constantly
humiliated everytime I post by having this tacked on to what I write:

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 28 Jul 1998 14:04:34 -0700
From: Ed <ed@pdh.com>
Subject: Perl Embed Win32 C++
Message-Id: <35BE3CE2.F2E95BA6@pdh.com>

To start out with, I am not a perl programmer and don't really know a
whole lot about perl, but was given the task to call a perl program from
within my C++ code.  I have looked at the perl embed for win32 stuff but
still don't have a good idea of how to do this.  Most of the programs
want to take the command line arguments which I do not want to use (from
void main(argc, argv)).  I will know the argument (single argument) and
the perl program name.  I have not seen any really good examples of how
to do this.  Does anyone have any ideas?

thanks in advance.

Ed



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

Date: Tue, 28 Jul 1998 21:42:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Problems Running An executable from within PERL
Message-Id: <Pine.GSO.4.02.9807281440580.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998 alan_k'necht@canadalife.com wrote:

> Hi, I'm trying to run an executable from within PERL. The program
> simply creates a file and writes the date to that file. 

That's a waste of another process. Perl is very capable of creating a file
and writing the date! :-)

> The executable runs fine if I run the script from the command prompt.
> However, when I run the script from within a browser, it seems that
> the executable does not run.

What diagnostic message are you getting from the program? (Not from the
browser, from the program.)

> $return_value = system("test.exe");
> 
> When run from the command prompt, the return value is 0.
> When run from within a browser, the return value is 256.

Maybe the program isn't being found along your PATH. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 28 Jul 1998 21:35:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Reacting to 1 of 10 or so possible values.... Need some streamlining help.
Message-Id: <6plg7t$jto$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to John Porter 
<jdporter@min.net>],
who wrote in article <35BDDB43.557B@min.net>:
> Ilya Zakharevich wrote:
> > 
> >       use 5.005;
> >       m{
> >          ^typeOne$ (?{ Do-type-one })
> >        |
> >          ^typeTwo$ (?{ Do-type-two })
> >        |
> >          (?{ Do-default })
> >        }x;
> 
> Extremely cool.

[Oups, the part about security below is wrong.  The things are much
less obtrusive, and not a tiny bit less secure.]

=item C<(?{ code })>

Experimental "evaluate any Perl code" zero-width assertion.  Always
succeeds.  C<code> is not interpolated.  Currently the rules to
determine where the C<code> ends are somewhat convoluted.

Owing to the risks to security, this is only available when the
C<use re 'eval'> pragma is used, and then only for patterns that don't
have any variables that must be interpolated at run time.

The C<code> is properly scoped in the following sense: if the assertion
is backtracked (compare L<"Backtracking">), all the changes introduced after
C<local>isation are undone, so

  $_ = 'a' x 8;
  m< 
     (?{ $cnt = 0 })			# Initialize $cnt.
     (
       a 
       (?{
           local $cnt = $cnt + 1;	# Update $cnt, backtracking-safe.
       })
     )*  
     aaaa
     (?{ $res = $cnt })			# On success copy to non-localized
					# location.
   >x;

will set C<$res = 4>.  Note that after the match $cnt returns to the globally
introduced value 0, since the scopes which restrict C<local> statements
are unwound.

This assertion may be used as L<C<(?(condition)yes-pattern|no-pattern)>>
switch.  If I<not> used in this way, the result of evaluation of C<code>
is put into variable $^R.  This happens immediately, so $^R can be used from
other C<(?{ code })> assertions inside the same regular expression.

The above assignment to $^R is properly localized, thus the old value of $^R
is restored if the assertion is backtracked (compare L<"Backtracking">).



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

Date: Tue, 28 Jul 1998 21:14:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: reading a file listing?
Message-Id: <Pine.GSO.4.02.9807281412400.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998, Jason Clark wrote:

> $filename = "123.txt";                            # Files already exist
> of 123.txt.001 / 123.txt.002 / 123.txt.003
> $FileParttern = "<".$filename."*>";
> print $FilePatterm;                                # Returns
> <123.txt*>
> 
> foreach $files ($FilePattern)                  # If I use <123.txt*> it
> works/ But not with the Var.

I think you may want something like this:

    foreach $files (glob "$filename*") { ... }

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 21:15:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: reading a file listing?
Message-Id: <Pine.GSO.4.02.9807281414270.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998 salvador@my-dejanews.com wrote:

> foreach $files (eval $Filepattern) {

eval of a string is in no way better than calling glob() directly. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 28 Jul 1998 21:20:30 GMT
From: "Lance Hollman" <lance@nospam.net-school.com>
Subject: Re: s/// Regexp parsing oddity with negative lookahead assertion
Message-Id: <01bdba6d$2b1d8b40$24f086cd@myname>

> 
> More generally, is there any better approach to what I am attempting?
> 

Perhaps try something like:

s/<f[^>]*?>(?!.*?<f.*?>.*?<xf>)(.*?)<xf>/$1/gsi;
    ^^^^

which looks for non-right-angle-bracket characters (0 or more) rather than
any characters.

The RE as written doesn't account for input which may be of the form:
     $_ = 'a<f>b<f>c<f>d<xf>e<xf>f<xf>g<f>h<xf>';
which may or may not be a concern for you.

Lance


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

Date: Tue, 28 Jul 1998 21:39:52 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: s/// Regexp parsing oddity with negative lookahead assertion
Message-Id: <Pine.GSO.4.02.9807281426210.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998, Brendan McMahon wrote:

> I'm trying to scan a HTML file and repeatedly remove paired open/close
> tags which may be recursively nested, using a '1 while s///' type
> repeat.

Now, of course you know that there are modules designed to help you parse
HTML. It's much hairier than it might seem at first.

> C:\>perl -e "$_='a<f>b<f>c<f>d<xf>e<xf>f<xf>g';
> s/<f.*?>(?!.*?<f.*?>.*?<xf>)(.*?)<xf>/$1/gsi;print"
> ade<xf>f<xf>g
> 
> which does not work. Various tests using .{0,X}? instead of the first .*?
> show that this term is matching greedily, despite the ? lazy match
> quantifier.

It looks as if it's working to me. That pattern matches the string
'<f>b<f>c<f>d<xf>' (yes, it does!), and replaces it with $1 (which is
'd'). If it's not what you wanted, maybe you meant to use a module to
parse the HTML anyway. :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 21:37:56 GMT
From: dwarren@dimensional.com
Subject: Re: Simplish regular expression Question
Message-Id: <6plgbk$1ic$1@nnrp1.dejanews.com>

In article <6pjg4l$465$2@marina.cinenet.net>,
  cberry@cinenet.net (Craig Berry) wrote:
> dwarren1@my-dejanews.com wrote:
> : I think I have a decent grasp of regular expressions but I'm not sure
> : what the best way to accomplish this would be.  I have a string in the
> : form of:
> : "/dir/file" or "/dir/file.c" or "dir/file" or "dir/file.c"
> : and in each case I would like to change the string to simply be "dir/file"
>   $str =~ s!^/?(.*?)(?:\.c)?$!$1!;
>
> : My current regexp looks like:
> : #!/usr/bin/perl
> No -w ?
Actually I just wrote that in for no reason, the actual test case uses -w and
strict

> : $str="\"/dir/file.c\"";
> Hmm, that string (which is easier to write as qq!"/dir/file.c"!) has
> literal double-quotes as characters in the string, not matching your spec
> above.  Which one is right?
Actually, my filespec says "/dir/file.c" and I ment "/dir/file.c" which is
what is written above. =)

> : $str=~s/^"[\/]?([\w\/]*)(\.c)?\"$/"$1"/;
> : print "'$str'\n";
> : and it works, however I don't like [\w\/]* i'd like to use lookahead and
> : say (.*) except '.c' together.  However I'm not quite sure how to best
> : do that.

> Not sure that's the best approach.  My version above will stop at each .c
> and see if it's followed by newline/end-of-string, completing the match if
> so, continuing if not.  Amounts to the same thing, really.
Maybe I was doing something wrong but when I ran that, it didn't match the
test case...  But I haven't had time to play with it more then a cut-n-paste

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 28 Jul 1998 21:26:01 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: site_perl changes from 5.004_04 to 5.005_xx
Message-Id: <901661764.679662@thrush.omix.com>

Christopher McCrory <chrismcc@netus.com> wrote:
: 	While compiling perl 5.005_xx I noticed these diferences:
	>snip<
: Is this how it is supposed to be?

	Yes.

: I haven't tested it but it seems that this will break any modules
: previously installed since the search paths are  different.
: yes/no?

	Yes, but there is a method to the madness.

	5.005 breaks binary compatibility with 5.004.  Any modules that
	are compiled with 5.004 will need to be compiled to work under
	5.005.  Thus, pointing them at the same directory would break
	a lot more. -Even scripts explicitly asking for perl5.00404
	would break, which would be very bad.

	Personally, I just installed it with the default directories,
	and relinked the *bin/perl's back to 5.00404, at least until
	I have the time to rebuild stuff for 5.005.  Until then, I
	get to 5.00505 with #!/usr/local/bin/perl5.00505.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Tue, 28 Jul 1998 21:36:44 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: site_perl changes from 5.004_04 to 5.005_xx
Message-Id: <8c1zr5wtcr.fsf@gadget.cscaper.com>

>>>>> "Christopher" == Christopher McCrory <chrismcc@netus.com> writes:

Christopher> Is this how it is supposed to be?  I haven't tested it
Christopher> but it seems that this will break any modules previously
Christopher> installed since the search paths are different.  yes/no?

Modules previously installed are probably incompatible anyway.  Especially
if there are any .so files.

-- 
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@teleport.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: 28 Jul 1998 21:10:23 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Sorting for Uniques
Message-Id: <slrn6rsfng.1mi.gabor@localhost.vmunix.com>

In comp.lang.perl.misc, George H <george@tapestry.net> wrote :
# Is there an easy way to sort an array for uniques? ... like the 'sort -u'
# command line in UNIX.  I am reading an array of clients from a huge file
# and I want to sort it for unique client names.  I was hoping to sort
# without runing a UNIX command.
# 
# Thanks in advance,
# 
# george@tapestry.net

perldoc perlfaq4


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

Date: Tue, 28 Jul 1998 21:05:02 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Transferring files from client to server
Message-Id: <Pine.GSO.4.02.9807281404250.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998 philc@hempseed.com wrote:

> 	open (OUTFILE, '>' . $path . "\\$localName");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 23:35:18 +0200
From: Thomas Jespersen <thomas@daimi.aau.dk>
Subject: Re: Try perl on Ms Dos
Message-Id: <35BE4416.A97684A0@daimi.aau.dk>

- wrote:
> >
> 
> Or pulling down the "Save as Type" drop down and selecting "All Files
> (*.*)" and then typing in whatever you please.


or even better: use another editor.


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

Date: Tue, 28 Jul 1998 21:22:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: WANTED: Perl Autoreponder - Any Takers?
Message-Id: <Pine.GSO.4.02.9807281422230.16612-100000@user2.teleport.com>

On Tue, 28 Jul 1998, David Deutsch wrote:

> I'm in need of a perl based autoreponder 

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 28 Jul 1998 23:13:33 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Win32::OLE trouble
Message-Id: <35bf3d32.23906796@news2.ibm.net>

[mailed & posted]

ctombras@mason2.gmu.edu (Constantine J Tombras) wrote:

>So with Word, I would expect:
>
>my $doc = $word_app->Documents->Open(FileName => "c:\\tmp\\doc.txt");
>
>to open doc.txt and assign $doc a Document object.  Yet, $doc seems to
>be undefined.
>
>Any ideas on what I am doing wrong? (full script below)

You are not using "named parameters" correctly. Named parameters are
specified through a reference to a hash as the last parameter:

my $doc = $word_app->Documents->Open({FileName => "c:\\tmp\\doc.txt"});

The way you have written it passes two parameters as positional
parameters; the first being "FileName" and the second being
"c:\\tmp\\doc.txt". The first positional parameter would be the filename
and because you probably don't have a file called "FileName" in Words
default directory, the Open method fails. I would recommend to run your
script with "perl -w" and "use strict;" too. You should have gotten an
error message to point you into the right direction.

So in this simple case you can write the Open method also like:

my $doc = $word_app->Documents->Open("c:\\tmp\\doc.txt");

You make the same mistake (not using a hash ref) in all the later method
calls too.

And one more note: I hope you have installed Office 97 Service Release
1. Without it you will have any number of problems using Word with OLE
automation. There are lots of problems with the original type library on
the MS CD.

-Jan



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

Date: Tue, 28 Jul 1998 16:36:29 -0500
From: Steve Livingston <slivings@digitalriver.com>
Subject: Zombies from Forking are Bad, says Sun
Message-Id: <35BE445D.5002A7E9@digitalriver.com>

I've got a perl daemon that runs continuously, forking children that do
stuf and then exit (simplified code below).

I run sparc/solaris/perl5.00404.

Each of the children leaves a Zombie process (seen by 'top') and I often
get many thousands of these Zombies, which _appear_ to go away when I
restart the daemon..

Sun kernel engineers tell me having this many zombies is bad, and may be
causing a unix/memory-being-stepped-on problem I'm having.

They said that this many zombied/defunct is very unusual and
zombied/defunct processes behave strangely. They said that a lot of
times they will not clear until the system reboots. They said just
because you kill the zombied/defunct processes does not mean the kernel
frees them and that they have gone away.

Can anyone shed any light on this?

Cheers,
Steve

Simplified forking code:

while () {
   ($trace_id,$ip_address) = &selectTrace;
   next if !defined $trace_id;

   FORK: {
      if ( $pid = fork ) {
         # parent here
         # child pid in $pid

      } elsif (defined $pid) { # $pid is 0 if defined
         # child here
         # parent pid is in getppid

         print "\n$0/child: PID=[$$]\n";

         &slave($trace_id,$ip_address);

         exit(0);

      } elsif ($! =~ /No more process/) {
                  sleep 5;
      } else {
                  die "can't fork: $!\n";
      }
   }
   sleep 15;
}



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

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

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