[17275] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4697 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 23 14:05:43 2000

Date: Mon, 23 Oct 2000 11:05:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972324322-v9-i4697@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 23 Oct 2000     Volume: 9 Number: 4697

Today's topics:
    Re: Alphanumeric sorting of hashes (Bernard El-Hagin)
    Re: Alphanumeric sorting of hashes (Tad McClellan)
    Re: Alphanumeric sorting of hashes <ren.maddox@tivoli.com>
    Re: Boolean query to Perl regexp match conversion <sba@ocegr.fr>
    Re: Can perl code be sandboxed? <james@NOSPAM.demon.co.uk>
    Re: code error, pls help <tim@ipac.caltech.edu>
    Re: Comments <jdb@wcoil.com>
    Re: Comments <ren.maddox@tivoli.com>
    Re: Comments <bart.lateur@skynet.be>
    Re: coran??? <sariq@texas.net>
    Re: coran??? (Craig Berry)
    Re: Device::SerialPort no dial even parity <phil_xxx@my-deja.com>
        Don't use -w in CGI? <jgoldst@my-deja.com>
    Re: Don't use -w in CGI? <godzilla@stomp.stomp.tokyo>
    Re: Dynamic Regex building? <godzilla@stomp.stomp.tokyo>
    Re: Dynamic Regex building? <mrh@panix.com>
    Re: Dynamic Regex building? <bart.lateur@skynet.be>
    Re: Dynamic Regex building? <mrh@panix.com>
    Re: Dynamic Regex building? <godzilla@stomp.stomp.tokyo>
    Re: Dynamic Regex building? <mrh@panix.com>
    Re: Dynamic Regex building? <flavell@mail.cern.ch>
    Re: File locking (Mark-Jason Dominus)
        For Godzilla; all else ignore <mrh@panix.com>
    Re: Help with array concatenation <godzilla@stomp.stomp.tokyo>
    Re: Help with array concatenation <godzilla@stomp.stomp.tokyo>
        help with system () - a new twist (redirecting stdout) <paul_price@hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Oct 2000 13:05:04 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Alphanumeric sorting of hashes
Message-Id: <slrn8v8dul.28m.bernard.el-hagin@gdndev25.lido-tech>

On Mon, 23 Oct 2000 12:43:44 GMT, ra jones <ra_jones@my-deja.com> wrote:
>The scenario:
>
>A hash consisting of pairs of entries (standard stuff) as follows:
>
>%hash = (
>'CD3','0',
>'CD25','33',
>'CD8','21',
>'CD66','1'
>);
>
>I need to sort it by alphanumeric rather than ASCII order (ie CD3, CD8,
>CD25, CD66), so I use the command:
>
>  print "Key: $_; value: $hash{$_}\n" foreach (sort{ $a cmp $b }keys
>%hash); # also tried <=> instead of cmp
>
>But it does not work, only sorts in ASCII order (ie CD25, CD3, CD66,
>CD8).
>
>Have I made a fundamental mistake here? Using Perl 5.005.

Yes, you're not properly telling the sort function what it is you want
to sort. As I understand it, you'd like to sort in numerical order using
the numbers after the 'CD' part. So first you have to extract those
numbers and then pass them to the sort function. One way of doing this
is the Schwartzian Transform (read about it here -> perldoc perlfaq4):

-----------------------------------------------
#!/usr/bin/perl -w
use strict;

my %hash = ( 'CD3' => '0', 'CD25' => '33', 'CD8' => '21', 'CD66' => '1');

my @outkeys = map{$_->[0]}
              sort{$a->[1] <=> $b->[1]}
              map{[$_, /^CD(\d+)/]} keys %hash;

print "@outkeys";
-----------------------------------------------

Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'


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

Date: Mon, 23 Oct 2000 11:03:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Alphanumeric sorting of hashes
Message-Id: <slrn8v8kpd.3ur.tadmc@magna.metronet.com>

On Mon, 23 Oct 2000 12:43:44 GMT, ra jones <ra_jones@my-deja.com> wrote:
>The scenario:
>
>A hash consisting of pairs of entries (standard stuff) as follows:
>
>%hash = (
>'CD3','0',
>'CD25','33',
>'CD8','21',
>'CD66','1'
>);


You seem to have an unhealthy affinity for punctuation characters...


>I need to sort it by alphanumeric rather than ASCII order (ie CD3, CD8,


No you don't.

You need to sort it numerically, ignoring the first 2 characters.


>Have I made a fundamental mistake here? Using Perl 5.005.


Yes.

You want to sort based on _part_ of the $a/$b values, but you
don't do anything to ignore the part that you want to ignore,
so it is not being ignored.

------------------------
#!/usr/bin/perl -w
use strict;

my %hash = (
   CD3  =>  0,
   CD25 => 33,
   CD8  => 21,
   CD66 =>  1
);

print "Key: $_; value: $hash{$_}\n"
   foreach (sort { substr($a, 2) <=> substr($b, 2) } keys %hash);
------------------------

   
An ST would be better if %hash gets beyond a "trivial" size...


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


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

Date: 23 Oct 2000 11:39:03 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Alphanumeric sorting of hashes
Message-Id: <m3u2a38qc8.fsf@dhcp11-177.support.tivoli.com>

ra jones <ra_jones@my-deja.com> writes:

> The scenario:
> 
> A hash consisting of pairs of entries (standard stuff) as follows:
> 
> %hash = (
> 'CD3','0',
> 'CD25','33',
> 'CD8','21',
> 'CD66','1'
> );
> 
> I need to sort it by alphanumeric rather than ASCII order (ie CD3, CD8,
> CD25, CD66), so I use the command:
> 
>   print "Key: $_; value: $hash{$_}\n" foreach (sort{ $a cmp $b }keys
> %hash); # also tried <=> instead of cmp
> 
> But it does not work, only sorts in ASCII order (ie CD25, CD3, CD66,
> CD8).
> 
> Have I made a fundamental mistake here? Using Perl 5.005.

You're going to have to break those keys up into the parts that you
really want to sort.  If they all start with "CD" or exactly two
non-digits, then you could use:

 .... sort { substr($a, 2) <=> substr($b, 2) } keys %hash;

If the format is not that clean, then use something like:

 .... sort { ($a =~ /\d+/g)[0] <=> ($b =~ /\d+/g)[0] } keys %hash;

In either case, if you have very much data to sort, you might want to
convert this to a ST or GRT, but I have a hunch that you aren't
dealing with that much data...

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 23 Oct 2000 18:00:50 +0200
From: Stephane Barizien <sba@ocegr.fr>
To: Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <39F460B2.D97CF2D3@ocegr.fr>

Gwyn Judd wrote:
> 
> I was shocked! How could Linc Madison <lincmad001@telecom-digest.zzn.com>
> say such a terrible thing:
> >In article <39f1a027@cs.colorado.edu>, Tom Christiansen
> ><tchrist@perl.com> wrote:
> >
> >> No one has to date suggested the simplest solution of all.  It's
> >> sort of an Occam's Razor approach, one often favored by Larry, so
> >> we'll call it Larry's Razor.  Just use Perl as the input.  In short,
> >> just require that
> >>
> >>     (foo OR bar) AND blah* AND kernel
> >>
> >> be typed in with slashes as quote delimiters, yielding
> >>
> >>     (/foo/ or /bar/) and /blah*/ and /kernel/
> >>
> >> which you are then free to compile as is.  Benefits of this approach
> >> are many and strong, so you should not automatically disregard it.
> >
> >Except that /blah*/ does not have the same meaning as blah* in the
> >original query. You would have to change it to /blah.*/ Also, as I read
> >he original query, it would actually change to something like
> 
> But /blah*/ matches the same strings as /blah.*/ which matches the same
> strings as /blah/. Therefore they have the same meaning. Depending on
> what the 'blah*' in the original query was intended to match.
> 
> >(/\bfoo\b/ or /\bbar\b/) and /\bblah/ and /\bkernel\b/
> >
> >(In English, the word "foo" or the word "bar," plus any word beginning
> >with "blah" and the word "kernel.")
> >
> >You're much less likely to get non-Perl-programmers to write that sort
> >of search query in Perl syntax.
> 
> True.


That's precisely why I was looking for something that would allow my
users to write

compiler error
(color OR colour) AND windows

instead of the current

compiler[\s\n]+error
(?=.*colou{0,1}r).*windows

(I deliberately ignore the (?i)/(?-i) and \b issues there...)

P.S. the users are inputting their patterns via a simple text file, one
pattern per line. So I'm reading the patterns one by one into Perl
strings.

I'll give Text::Query (advised earlier in this thread) a try and see
what my users think.

Regards,


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

Date: Mon, 23 Oct 2000 17:51:25 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Can perl code be sandboxed?
Message-Id: <ant231625bc8fNdQ@oakseed.demon.co.uk>

In article <8t184p$nbv$1@pegasus.csx.cam.ac.uk>, M.J.T. Guy
<URL:mailto:mjtg@cus.cam.ac.uk> wrote:
> James Taylor  <james@NOSPAM.demon.co.uk> wrote:
> >
> >Presumably you'll get plenty of people giving one line answers
> >to your question in the form "perldoc Safe" but as I don't have
> >perldoc on my system I won't do that. :-)
> 
> You mean you don't have Perl installed on your system ?
> 
> A correctly installed (sufficiently recent) Perl always includes perldoc.

Sadly the RISC OS port does not include perldoc. I intend to
download the Perl source archive and extract perldoc, then
modify it to work on my platform. However, this will have to
wait until I have spare time... :-)

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 23 Oct 2000 10:57:54 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: code error, pls help
Message-Id: <39F47C22.1F444486@ipac.caltech.edu>

Arthur wrote:
> 
> The error when compiled:
> 
> Name "main::d" used only once: possible typo at ./concat.pl line 23.

Others have told you what the error means. (BTW, you could have found out
yourself by reading the perldiag doc.) If $d is a throwaway variable, you can
either just not use it at all by using this construct ...

(undef, $n) = split /\t/, $line;

(This is a special use of undef; don't expect to be able to assign to undef in
other ontexts.)

or this one ...

$n = (split /\t/, $line)[1];

 ... or you can declare your variables thusly:

my ($d, $n) = split /\t/, $line;

perl won't warn you about lexical var.s used only once, only globals. And it's a
better idea to use lexicals anyway, usually.


--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: 23 Oct 2000 15:39:11 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: Re: Comments
Message-Id: <8t1m2v$8ot$0@206.230.71.59>

Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:8t0oji$u38$1@orpheus.gellyfish.com...
> On 21 Oct 2000 02:42:29 GMT Josiah wrote:
> > Corey French <blah.xyathn@yahoo.com> wrote in message
> > news:o05I5.16369$cO4.396072@nntp3.onemain.com...
> >> I know that you can comment out a line or end of line with the # key,
but
> > is
> >> there a way to comment out an entire section.  For those of you that
are
> > __CODE__
> >
> > print "Hahaha!";
> >
> > =begin comment
> >
> > print "you can't see me!";
> >
> > =cut
> >
> > print "boo!"
> >
> > __END__
> Why "don't try this in production code" ?  Nearly all the modules in CPAN
> have embedded pod in them, and surely a lot of them are being used in
> production code.  Using POD is the method decribed in the FAQ for
> commenting out blocks of code.

:-) I'm sorry, I didn't make that clear. Of COURSE you should use embeded
POD documentation in your modules - it's just plain silly not to. After all,
thats the whole purpose of POD, isn't it? (to make documentation a heckuva
lot easier :-)

The reason I added the "dont use in production code" comment was that my
experience has been that perldoc will include commented-out portions of code
in its perldoc output. For example, look at this example module that
illustrates that point:

package test;

=begin

sub hello_world

    print "hello world!";
}

=cut

# more code

sub hello

    print "hello";
}

=begin

=head1 NAME

test

=head1 BYE

bye

=cut

1;

__END__

Now, when I run "perldoc test", I get:

        sub hello_world { print "hello world!" }

NAME
        test

BYE
        bye


Doesn't that seem  a bit wierd? I dont know about everybody, but i dont like
commented-out code appearing where I expect docs for the module.

Oh well, anyways, that is why I said, "dont try this in production code."

hth,

--
$from=<$josiah>;




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

Date: 23 Oct 2000 12:11:39 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Comments
Message-Id: <m3pukr8otw.fsf@dhcp11-177.support.tivoli.com>

"Josiah" <jdb@wcoil.com> writes:

> The reason I added the "dont use in production code" comment was that my
> experience has been that perldoc will include commented-out portions of code
> in its perldoc output. For example, look at this example module that
> illustrates that point:
> 
> package test;
> 
> =begin

You just need to include an invalid formatter after "begin" and a
corresponding "end", like:

=begin comment

> sub hello_world
> 
>     print "hello world!";
> }

=end comment

> =cut
> 
> # more code
> 
> sub hello
> 
>     print "hello";
> }
> 
> =begin
> 
> =head1 NAME
> 
> test
> 
> =head1 BYE
> 
> bye
> 
> =cut
> 
> 1;
> 
> __END__
> 
> Now, when I run "perldoc test", I get:
> 
>         sub hello_world { print "hello world!" }
> 
> NAME
>         test
> 
> BYE
>         bye
> 
> 
> Doesn't that seem  a bit wierd? I dont know about everybody, but i dont like
> commented-out code appearing where I expect docs for the module.

Changing it as I described now gives the correct output -- that is,
the subroutine is no longer displayed.

> Oh well, anyways, that is why I said, "dont try this in production code."

"unless you use it correctly" -- the example in the FAQ does it
correctly, but probably doesn't go into enough detail.  A quick glance
at the "=for =begin =end" section of perlpod is suitably revealing.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 23 Oct 2000 17:48:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Comments
Message-Id: <p8u8vs8jpsbt0f1nhj7fp8dkkpch3tdvrh@4ax.com>

Josiah wrote:

>=begin
>
>sub hello_world
>
>    print "hello world!";
>}
>
>=cut
>
># more code
>
>sub hello
>
>    print "hello";
>}
>
>=begin
>
>=head1 NAME
>
>test
>
>=head1 BYE
>
>bye
>
>=cut
>
>1;
>
>__END__
>
>Now, when I run "perldoc test", I get:
>
>        sub hello_world { print "hello world!" }
>
>NAME
>        test
>
>BYE
>        bye
>
>
>Doesn't that seem  a bit wierd?

Yes. But you've ignored the fact that you can use custom "targets" for
your "begin" tag, makingthe whole thing disappear for any other target
(= everywhere). Try:

	=begin comment

		This is invisible

	=end

You may use "=for" instead of "=begin".

-- 
	Bart.


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

Date: Mon, 23 Oct 2000 15:59:03 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: coran???
Message-Id: <39F46047.4633866@texas.net>

Clay Irving wrote:
> 
> On Fri, 20 Oct 2000 22:15:48 GMT, pape_98@my-deja.com <pape_98@my-deja.com>
> wrote:
> 
> >Has anyone heard of coran????
> >My boss just told me to read about it and said that it was designed to
> >make scripts run themselves.
> 
> s/o//;
> s/a/o/;

Of course we all know that tr/// is the *proper* operator here...

<smiley implied>

- Tom


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

Date: Mon, 23 Oct 2000 18:04:10 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: coran???
Message-Id: <sv8vcqndc5q459@corp.supernews.com>

Tom Briles (sariq@texas.net) wrote:
: Clay Irving wrote:
: > 
: > On Fri, 20 Oct 2000 22:15:48 GMT, pape_98@my-deja.com <pape_98@my-deja.com>
: > wrote:
: > 
: > >Has anyone heard of coran????
: > >My boss just told me to read about it and said that it was designed to
: > >make scripts run themselves.
: > 
: > s/o//;
: > s/a/o/;
: 
: Of course we all know that tr/// is the *proper* operator here...

You can even do it in one step that way:  tr/ao/o/d;

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Mon, 23 Oct 2000 13:13:55 GMT
From: Phil xxx <phil_xxx@my-deja.com>
Subject: Re: Device::SerialPort no dial even parity
Message-Id: <8t1dig$sn0$1@nnrp1.deja.com>


> I don't think your modem knows anything about parity.  The only time
you
> would use anything other than 8 bit, no parity would be after the
modem
> has connected to an old classic CompuServe account that you have not
> changed to 8 bit, and you need to use the old 7 bit, even parity to
login.
> Or maybe if you connect to a BBS or something else that uses parity,
but
> only after you receive the CONNECT string.
>
> --
> David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
> http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/
http://hammer.prohosting.com/~cgi-wiz/
>

David

Thanks.  Your kinda right.  I have to connect to a customers system.  I
have no idea why it requires the use of parity.  But it does, thats the
spec.  Anyway I still cant work out why my modem wont dial!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 23 Oct 2000 16:52:18 GMT
From: JL Goldstein <jgoldst@my-deja.com>
Subject: Don't use -w in CGI?
Message-Id: <8t1qbv$7im$1@nnrp1.deja.com>

I seem to remember reading somewhere that, once one's Perl CGI script is
debugged, the script should not be on the Web server with the -w switch.
The reasoning, as I recall, was that error messages printed to the
browser window could give the user system information that could
facilitate hacking.

Thoughts? Suggestions?

--

Any sufficiently advanced magic is indistinguishable from Perl.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 23 Oct 2000 10:45:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Don't use -w in CGI?
Message-Id: <39F47933.3AB2142@stomp.stomp.tokyo>

JL Goldstein wrote:
 
> I seem to remember reading somewhere that, once 
> one's Perl CGI script is debugged, the script 
> should not be on the Web server with the -w switch.
> The reasoning, as I recall, was that error messages
> printed to the browser window could give the user system 
> information that could facilitate hacking.
 
> Thoughts? Suggestions?


Who is 'one'? I read about this person as
frequently as I read about 'them'.

What better reason than to enhance security?
Only piss poor programmers leave pragma hints
and revealing information for a die statement,
within a final script version for public use.

There is another reason for removing warnings,
strict and other pragma hints; they consume
memory and slow your script, for naught.


Godzilla!


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

Date: Mon, 23 Oct 2000 07:08:26 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Dynamic Regex building?
Message-Id: <39F4465A.6693BFCC@stomp.stomp.tokyo>

Jonathan Stowe wrote:
 
> Michael Hoffman wrote:

>   <WRT Godzilla>
 
> > You know, while searching for an answer on this forum, I noticed that people
> > don't seem to like you.
 
> Ignore the Troll.


Screw off Stowe. I contribute more positive benefit to 
this group in one article than you have ever contributed.
Your articles, your comments and thoughts, are a vast
collection of tasteless RTFM garbage.


Godzilla!


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

Date: 23 Oct 2000 15:21:58 GMT
From: Michael Hoffman <mrh@panix.com>
Subject: Re: Dynamic Regex building?
Message-Id: <8t1l2m$lui$1@news.panix.com>

In <39F228D5.8F59CBF7@acm.org> article, John W. Krahn mentioned that:

: From what you have shown us it looks like you are doing too much work
: but it is hard to tell without looking at some samples from the data
: files. An example of doing too much is assigning a null string to the
: first element of an array and then later removing it.
:> my @newst="";
:> shift @newst;   # needed b/c blank character is first record
: You do this with three different arrays.

Ok, I understand the logic to this.  But, how do you initialize the array
if you don't know what the first element will be.  Or should I simply just
begin using the array without initializing it?

: Is the data in $sch_file and $tabfile not related to the data in
: $unl_file, and if it is there might be a better (for certain values of
: better) way to do it.

They are only related in the fact that $sch_file and $tabfile are Table 
Layouts, whereas $unl_file is the actually DATA from the table.  

: Remember, TMTOWTDI. :-)
: John



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

Date: Mon, 23 Oct 2000 15:24:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Dynamic Regex building?
Message-Id: <j1m8vsor5fvpmn6254aq5m40l108lc1aj0@4ax.com>

Godzilla! wrote:

>Screw off Stowe. I contribute more positive benefit to 
>this group in one article than you have ever contributed.

I don't think J. Stowe's HTML::Parser examples were useless.

-- 
	Bart.


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

Date: 23 Oct 2000 15:29:57 GMT
From: Michael Hoffman <mrh@panix.com>
Subject: Re: Dynamic Regex building?
Message-Id: <8t1lhl$lui$2@news.panix.com>


Thank you, Ben, for the help.  I tried using the "/ee" but it wouldn't eval
that way either.  I'll have to do some more reading about "eval" and "qq".

Being a begginer Perl programmer, I was hoping for responses like yours and
John's so I could learn to write cleaner code.  I appreciate the time you both
took to look over what I was doing and assist me.  

Michael Hoffman

In <MamI5.61419$td5.9352514@news1.rdc2.pa.home.com> article, Ben Kennedy mentioned that:
: "Michael Hoffman" <mrh@panix.com> wrote in message
: news:8sqglc$3o8$1@news.panix.com...
:>
:> Lets say I want to add 3 new fields between the 2nd and 3rd field.
:> $orig = ^([^\|]*)\|([^\|]*)\|([^\|]*)\|$
:> $repl = $1|$2||||$3|
:>
:> How do I get Perl to recognize the $repl string as a Regex?  Before you
:> suggest using "/e", I did that already with no change in results.

: The replacement pattern is not a regexp, its just an interpolated string (or
: chunk of code with /e).  Thus there are pitfalls since $1, $2 have to be
: filled at runtime.  Unless this happens, the string that contains $1 and $2
: etc will just contain those literal strings.  You can fix this by eval'ing
: the replacement expression:
: my $orig = '^([^\|]*)\|([^\|]*)\|([^\|]*)\|$';
: my $repl = '$1|$2||||$3|';
: my $text = "aaaaaaaaaa|bbbbbbbbbb|cccccccccccccc|";
: $text =~ s/$orig/eval qq{"$repl"}/e;
: # the qq is a generalized way of saying eval "\"$repl\""
: print "Out: $text\n";
: However, the cleanest way is to get your data into an array with split(),
: then use splice() to add elements, then output with join().  It is also
: better to try to boil down your questions a bit - a lot of people tune out
: posts that contain a lot of code.  Hope this helps --
: --Ben Kennedy





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

Date: Mon, 23 Oct 2000 08:42:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Dynamic Regex building?
Message-Id: <39F45C52.37FE15A7@stomp.stomp.tokyo>

Bart Lateur wrote:
 
> Godzilla! wrote:
 
> >Screw off Stowe. I contribute more positive benefit to
> >this group in one article than you have ever contributed.
 
> I don't think J. Stowe's HTML::Parser examples were useless.



Fearful to comment on Stowe consistently directing
insulting and hateful remarks at me? Are you fearful
to deal with reality? Well? Are you fearful to comment
on Stowe trolling this newsgroup? Tell me, why did you
ever so carefully snip his hateful comment?

Stowe is a RTFM garbage poster and what you think
doesn't amount to diddly-squat.

Godzilla!


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

Date: 23 Oct 2000 16:07:21 GMT
From: Michael Hoffman <mrh@panix.com>
Subject: Re: Dynamic Regex building?
Message-Id: <8t1nnp$nbo$1@news.panix.com>

The problem with splice() is that you need to know the Offsets.  In real life,
my new table will have numerous fields being inserted at random spots in the
old table.  I would need to keep a list of offsets and create a splice() loop
until the list is fully processed.  I figured the replace Regex was more 
efficient in code, time, and memory usage.

Michael Hoffman

In <MamI5.61419$td5.9352514@news1.rdc2.pa.home.com> article, Ben Kennedy mentioned that:
: However, the cleanest way is to get your data into an array with split(),
: then use splice() to add elements, then output with join().  It is also
: better to try to boil down your questions a bit - a lot of people tune out
: posts that contain a lot of code.  Hope this helps --
: --Ben Kennedy





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

Date: Mon, 23 Oct 2000 17:56:13 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Dynamic Regex building?
Message-Id: <Pine.GHP.4.21.0010231755020.3095-100000@hpplus03.cern.ch>

On Mon, 23 Oct 2000, Bart Lateur wrote:

> I don't think J. Stowe's HTML::Parser examples were useless.

Of course not.  Please do not feed the troll.




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

Date: Mon, 23 Oct 2000 15:49:46 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: File locking
Message-Id: <39f45e19.6ba8$1a6@news.op.net>

In article <_4QI5.2683$ud.614505@news.uswest.net>,
Michael Cook <mikecook@cigarpool.com> wrote:
>I find that section incomplete - it does not state what to do for FH
>flushing in the case of opening more than 1 file in the same script.

That is not true.  It shows for example:

    $file->autoflush(1);
    flock(FH, LOCK_UN);

Also, elsewhere in the same chapter is an extensive discussion of
flushing issues.


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

Date: 23 Oct 2000 16:13:32 GMT
From: Michael Hoffman <mrh@panix.com>
Subject: For Godzilla; all else ignore
Message-Id: <8t1o3c$ngc$1@news.panix.com>

I tried to reply to you through email, but, as I suspected, stomp.stomp.tokyo
is not a valid email address.  Please reply to me through email as this 
newsgroup is not the place for a flame war.

-----------------------------------------------------------
Godzilla,

What the hell is your problem?  I've been using Perl for about 2 weeks now
and was pretty proud of what I had learned.  In my 12 years of using the 
Usenet *technical* groups, I've never seen anyone flame a beginner as quickly
or as harshly as this!  What did I do to you?  Why did you think that code was
a "troll"???  And if you thought it was, why for god sake, would you even
bother to respond to it?  Everyone who's been around long enough knows to 
ignore the trolling responses.

In fact, as someone suggested, I should ignore you.  But I've read many of your
responses and I don't view them as trolling.  You usually do have something
worthwhile to say, although your approach might be tempered down a bit.  So,
when you accuse *me* of trolling, I must ask why?  

As to my 3 million plus lines of code.... I was just hoping some of the Perl 
"gurus" would show me simpler ways of carrying out my code.  I'd appreciate
any help you could give as well.

I look forward to your response, but email is the place for this and not the
newsgroup.  Don't bother posting this or your response.  Let's talk this
way.

Michael Hoffman

P.s. --- Who the heck is Frank?

In article <39F1CA7D.401D261E@stomp.stomp.tokyo> you wrote:
: Michael Hoffman wrote:
: (snipped verbal diarrhea)
:> Godzilla! wrote:
:> > (snipped 3,591,274 lines of unrelated comments and code)

:> >    $in=~ s/$orig/$repl/;      # SOMETHING WRONG HERE!!  BUT WHAT???

:> > Why don't you print each of those variables before
:> > your substitution and find out what is wrong?

:> > print " IN: $in\n ORIG: $orig\n REPL: $repl\n\n";
:  
:> > Of course this code snippet is extremely complex
:> > and difficult to understand. Nonetheless, I am
:> > certain you will figure out how to use this code.


:> As to your "answer", did you even bother to read the end of the post?
:> Obviously not, or else you would have seen the following:

:> > Lets say I want to add 3 new fields between the 2nd and 3rd field.
:> > $orig = ^([^\|]*)\|([^\|]*)\|([^\|]*)\|$
:> > $repl = $1|$2||||$3|

:> > Given Data like:  Hi|Hello|Howdy|
:> > I am returned:    $1|$2||||$3|
:  
:> I believe that is what your "print" statement would provide, no?


: his initial article:

:  "How do I get Perl to recognize the $repl string as a Regex?
:   Before you suggest using "/e", I did that already with no 
:   change in results."

:  

: Yes, I read this along with 3,591,274 lines of unrelated
: comments and code posted by you with an intent of annoying
: people to a point of reaction. You now have a reaction.
: However, you chose a wrong person to troll and from whom
: to elicit a reaction.

: My decision is and was, you were to confirm, by duplicity,
: you are aware, precisely aware, of what is your code problem,
: although there is no such problem; a reasonable person would
: and could infer this based upon your malice intent displayed
: via your initial fake article with a faked problem evidenced
: by a variety of simple code testing, which I performed, 
: of course. Your regex yields the same results, regardless
: if it tested as a direct regex or otherwise.

: I elected to mentally manipulate you into confirming, twice, 
: you could have posted your problem and example with a small 
: handful of lines, no more than a dozen lines, rather than 
: posting 3,591,274 lines of unrelated comments and code,
: with malice intent evidenced by a completely fake problem.

: Nasty little creatures those Mind Maggots, yes Frank?

: Godzilla!




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

Date: Mon, 23 Oct 2000 06:57:12 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with array concatenation
Message-Id: <39F443B8.CD954AF@stomp.stomp.tokyo>

Piers Cawley wrote:
 
> "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> > Tad McClellan wrote:
> > > Martien Verbruggen wrote:
> > > > Jody Fedor wrote:
> > > > > Uri Guttman wrote:

(snipped)

> Have you actually read the perl 5 documentation set?

How lame. No, I have never read documentation for
Perl, any version. It is my habit as a Professor
of English to pass judgement on written material
without review. 

> It's not just lists of functions, there's damn fine 
> tutorials in there too.

After reading several versions of Perl documentation
over years, my professional opinion is this documentation
is a collection of 


-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Mon, 23 Oct 2000 07:03:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with array concatenation
Message-Id: <39F44523.7EE289A5@stomp.stomp.tokyo>

"Godzilla!" wrote:
 
> Piers Cawley wrote:
 
> > "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> > > Tad McClellan wrote:
> > > > Martien Verbruggen wrote:
> > > > > Jody Fedor wrote:
> > > > > > Uri Guttman wrote:
 
> (snipped)
 
> > Have you actually read the perl 5 documentation set?
 
> How lame. No, I have never read documentation for
> Perl, any version. It is my habit as a Professor
> of English to pass judgement on written material
> without review.
 
> > It's not just lists of functions, there's damn fine
> > tutorials in there too.
 
> After reading several versions of Perl documentation
> over years, my professional opinion is this documentation
> is a collection of


darn it...

 ...is a collection of Techno-Geekster gibberish so
poorly written it is best suited for a trash can.

Do you actually believe you know how to read?

Godzilla!


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

Date: Mon, 23 Oct 2000 11:21:41 -0600
From: Paul Price <paul_price@hp.com>
Subject: help with system () - a new twist (redirecting stdout)
Message-Id: <39F473A5.1F7A9F1C@cnd.hp.com>

I'd like to add a new twist to the problems related to calling "system".

What I'd like to do is run a program, with a path that has embedded spaces,
passing in some filename (with spaces) AND pipe stdout to a file. To add to
the example our test example:

Here is the command line I want to run:
"d:\\my folder\\myprogram.exe" "d:\\some folder\\input file" > "d:\\my
folder\\myprogram.out"

@args=("d:\\my folder\\myprogram.exe","d:\\some folder\\input file",">
d:\\my folder\\myprogram.out");
system(@args);

Before the advent of embedded spaces (don't get me started on this one), I
could just do:

system("d:/folder/program.exe input.file > d:/folder/program.out");

Any ideas?



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4697
**************************************


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