[25048] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7298 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 24 21:06:00 2004

Date: Sun, 24 Oct 2004 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 24 Oct 2004     Volume: 10 Number: 7298

Today's topics:
    Re: arrays of arrays question (Jay Tilton)
    Re: arrays of arrays question <usenet@morrow.me.uk>
    Re: arrays of arrays question <nospam@nospam.com>
    Re: Copy modules to another identical installation? <usenet@morrow.me.uk>
    Re: copying files greymaus@yahoo.com
    Re: copying files <abigail@abigail.nl>
    Re: copying files <usenet@morrow.me.uk>
    Re: copying files <abigail@abigail.nl>
    Re: copying files <abigail@abigail.nl>
    Re: Fast random string generation <abigail@abigail.nl>
    Re: foreach vs. for <usenet@morrow.me.uk>
    Re: foreach vs. for <spamtrap@dot-app.org>
    Re: foreach vs. for <kalinaubears@iinet.net.au>
    Re: Hard regexp problem <abigail@abigail.nl>
        Please don't feed the troll (was Re: arrays of arrays q <tadmc@augustmail.com>
    Re: Practical Extraction Recording Language <abigail@abigail.nl>
    Re: Problem with useless use error message <tadmc@augustmail.com>
    Re: What's the seed? <abigail@abigail.nl>
    Re: where download web application source code examples <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 24 Oct 2004 22:20:11 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: arrays of arrays question
Message-Id: <417c2a78.1054115@news.erols.com>

"daniel kaplan" <nospam@nospam.com> wrote:

: ok, i have been thru perlfaq4 (i believe four)

Not much help to be found in there.  Try perlreftut instead.

: and my manuals aren't helping
: me either, and/or it's just 3am...but need some help syntax wise.
: 
: in brief, i am going through my database afetr a query.
: so what i am attempting to do, is to make an array of each array.
: now below is what i have currently, but i can't figure out how to get OUT
: each array.  i tried a POP, but that didn't seem to give me an array i could
: access (i.e. $row[0], etc).

For future reference, a good problem description should answer two
questions:

1. What does the program not do that it should?
2. What does the program do that it should not?

The second part of your problem description is missing.  What does
"pop @rows" return, and how is it different from what you expect it to
return?

: now i do realize that \@row, means the address.

Sort of.  The "address" of a datum is an alien concept in Perl programming.
You don't care _where_ it's stored, only that you can get to it through its
reference.

: so am curious if that means
: that the reference to each row is cleared.

Umm . . . I can't guess what you mean by that.

: but when i do the push without
: the \@, and just @,
: essentially @rows becomes a list....which is no longer a format that is easy
: to work with.
: 
: could really use some help here,
: 
: thanks ahead
: 
:       while (@row = $sth ->fetchrow_array)
:       {
:         my $trow = @row;

What is that line meant to accomplish?

:         push @rows, \@row;
:       }

Where's the "pop @rows" part?  Showing what you've tried to do, however
wrong, will often illuminate misapprehensions.



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

Date: Sun, 24 Oct 2004 23:50:29 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: arrays of arrays question
Message-Id: <l6ot42-to4.ln1@osiris.mauzo.dyndns.org>


Quoth "daniel kaplan" <nospam@nospam.com>:

[snip unattributed text: DON'T DO THAT]

[snip gratuitous rudeness, AGAIN: you will have your very own little
place in the killfile from now on]

> i will describe how far i have taken it, right now am going by faq.perl.org
> and in the chapters i have perused, could not find an example of my exact
> dillema.

PLEASE could you learn to type English? If English is not your first
language, I apologise, but I suspect it is; if it is, then you should be
ashamed of yourself. There are lots of people here who learnt English as
a second language, and 'most all of them type/spell/construct sentences
*substantially* better than you do. Giving this little regard to clear
and comprehensible expression is simply rude: you are saying 'I don't
give a damn if it is harder for my (rapidly diminishing group of)
readers, I'm going to take absolutely no effort to write clear English
'cos I can't be bothered'.

> i can successfully use pop and push with scalar, but it is using
> them with arrays that i cannot make them work.  but once i start popping
> arrays unto arrays, it goes out of wack.

This is perhaps because in perlfunc push is given as

push ARRAY,LIST

; i.e., you *can't* push an array onto an array. You can push the list
of values out of an array onto an array, but if you do that several
times you can't separate out which came from which afterwards. You can
push a ref to an array onto an array (which is probably what you want to
do here), but you have to ask to do that explicitly (see perlreftut,
perllol, perldsc, perlref).

> assuming that arrays are naturally references,

What gave you that idea? Arrays are naturally arrays.

> then perhaps a reference to an array is a reference to a reference?

No, surprisingly enough a ref to an array is a ref to an array. The
important fact here is that a ref to an array is a *scalar*, so you can
push it onto another array if you want to.

> i cannot get on to www.perldoc.com at this moment, not loading.  if you know
> of a mirror, i would take that.  if you know of a better site than
> faq.perl.org i will gladly listen.

Start with the docs on your own machine. You have been pointed at them
several times.

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: Sun, 24 Oct 2004 20:50:12 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: arrays of arrays question
Message-Id: <1098665460.710961@nntp.acecape.com>

[i'll snip and ignore most references to items not related to this thread]

>>you will have your very own little place in the killfile from now on
fine, really that's fine.  you have every right to ignore all my posts.
for the record that's what i do with all of Tad's posts now, i notice the
last one said troll in the subject, makes it real easy not to read
it...saves me the time, and save other readers of having to be dragged into
this..

>>PLEASE could you learn to type English? If English is not your first
>>language, I apologise, but I suspect it is; if it is, then you should be
>>ashamed of yourself.
yeah, i try, but give me the benefit of a doubt that i can neither type nor
spell as an actual defect...my other one, not sure if it's realted is i
won't remember your name for two months.  i'll remember everythign  you do,
where from, but names, like spelling just fly out of my head....for the life
me, i want to put an EXTRA l on actual...but i can't tell if that's right or
wrong.. oh and spell checker doesnt work on my OE, i'ld rant about MSoft
(despite my actual love of them), but that's a whole other newsgroup!
besides, spell checking a post to a programming newsgroup is a herculean
task.

anyway, regardless on to answer your questions/statement.

> > assuming that arrays are naturally references,
> What gave you that idea? Arrays are naturally arrays.
it's a C thing, look at an array and it is a pointer...when you send a
function an array, it's the same as sending it the pointer to the
array...unlike other variables....

> > then perhaps a reference to an array is a reference to a reference?
again, it's a C thing that's hard wired into my brain afetr all these years.
if this pictures it better...i can read spanish, but only by translating
each word in my head....that's the stage i am still at with Perl....brain
looks at it in C.....it'll be a while before it becomes an actual language
in my head.


> Start with the docs on your own machine. You have been pointed at them
> several times.

true, and as i said i do go to them....but wow, it's not an ease of use
thing...perldoc -q hasnt gotten me to the right place once. even AFTER Sinan
gave me the right link.  i tried to use perldoc with 20/20 hindsight, and
still nada....i think someone told me to try perldoc on perldoc, will have
to that next

for the record, with the debugger i was able to determine the proper way of
pushing my arrays onto one, now am reading up on that section so i fully
understand WHY.... rather than just do.....




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

Date: Sun, 24 Oct 2004 17:48:25 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Copy modules to another identical installation?
Message-Id: <pv2t42-gi5.ln1@osiris.mauzo.dyndns.org>


Quoth zaphod <none@none.com>:
> I have 3 identical installations of Fedora 2 which have the default Perl
> replaced with a source compilation. After building up an extensive module
> collection on one of the machines I'd like to have the same collection
> installed on the other 2. Can I simply copy the module collection over?

Maybe, if the machines truly are identical. As a safer alternative, see
CPAN.pm's autobundle command.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: 24 Oct 2004 22:27:58 GMT
From: greymaus@yahoo.com
Subject: Re: copying files
Message-Id: <slrncnnq0v.288.greymaus@darkstar.example.net>

On 24 Oct 2004 08:43:12 -0700, wana  wrote:
> yadurajj@yahoo.com (yaduraj) wrote in message news:<3668515b.0410240242.998b3ee@posting.google.com>...
>> I have a simple question,pardon me..
>> 
>> if I have to copy a file, I can use something like this:
>> 
>> copy ("$DIR/test.c" ,"$INP_DIR/");
>> 
>> this copies test.c from one location to another..but
>> if i have to copy all the files with .c extension like, what is the
>> method to this...
>> can i not use *.c in some way..
>> please help me on this..
>> 
>> thanks in advance
>
> maybe this would work:
>
> system("mv $DIR/*.c $INP_DIR/");
>
> I'm sure there is something in the File module that is better though. 
> By the way, 'Perl Cookbook' is awsome.  I just bought it and it is an
> incredible reference and would have saved me a lot of trouble if I had
> bought it earlier.
>
> wana

Agreed. Best Perl Book.

-- 
greymaus
97.025% of statistics are wrong


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

Date: 24 Oct 2004 23:41:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: copying files
Message-Id: <slrncnofd2.3ac.abigail@alexandra.abigail.nl>

Ben Morrow (usenet@morrow.me.uk) wrote on MMMMLXXII September MCMXCIII in
<URL:news:ks0t42-hm4.ln1@osiris.mauzo.dyndns.org>:
--  
--  Quoth "A. Sinan Unur" <usa1@llenroc.ude.invalid>:
-- > 
-- > system('cp', "$source/*.c", $target) == 0
-- >     	or die "System failed: $?;
--  
--  Err... this may work on Win32, but any system with C exec conventions
--  will require a shell to expand the wildcard.
--  
--  system("cp $source/*.c $target") and die "cp failed: $?";
--  
--  and pray $source doesn't need quoting...

Well, if you are afraid $source needs quoting, then put in the quotes:

    system "cp '$source'/*.c $target"

That would still fail if $source contained a quote. This ought to work
as well:

    system "cp \Q$source\E/*.c $target";


Abigail
-- 
BEGIN {$^H {join "" => ("a" .. "z") [8, 13, 19, 4, 6, 4, 17]} = sub
           {["", "Just ", "another ", "Perl ", "Hacker"] -> [shift]};
       $^H = hex join "" => reverse map {int ($_ / 2)} 0 .. 4}
print 1, 2, 3, 4, "\n";


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

Date: Sun, 24 Oct 2004 23:36:26 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: copying files
Message-Id: <acnt42-to4.ln1@osiris.mauzo.dyndns.org>


Quoth "A. Sinan Unur" <usa1@llenroc.ude.invalid>:
> Ben Morrow <usenet@morrow.me.uk> wrote in news:ks0t42-
> hm4.ln1@osiris.mauzo.dyndns.org:
> 
> > Quoth "A. Sinan Unur" <usa1@llenroc.ude.invalid>:
> >> 
> >> system('cp', "$source/*.c", $target) == 0
> >>          or die "System failed: $?;
> > 
> > Err... this may work on Win32, but any system with C exec conventions
> > will require a shell to expand the wildcard.
> 
> You are right. I only tried it on Windows 98 with copy instead of cp. Since 
> copy is a built-in with command.com, it did not have a problem expanding 
> the wildcard. However, I just noticed another problem with it: Since I had 
> forgotten to create the target directory, it appended all the files (in 
> text mode) to create one file with the directory name I had in $target.
> 
> I think this justifies my preference for not shelling out for wholesale 
> file operations, but using File::Copy.

s/for.*operations/ever/
s/(?=using)/ or writing/
s/File::Copy/an appropriate module/

:)

Ben

-- 
           All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk                                                  Kurt Vonnegut


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

Date: 24 Oct 2004 23:49:43 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: copying files
Message-Id: <slrncnofsn.3ac.abigail@alexandra.abigail.nl>

A. Sinan Unur (usa1@llenroc.ude.invalid) wrote on MMMMLXXII September
MCMXCIII in <URL:news:Xns958C826FE4F67asu1cornelledu@132.236.56.8>:
!!  Ben Morrow <usenet@morrow.me.uk> wrote in news:ks0t42-
!!  hm4.ln1@osiris.mauzo.dyndns.org:
!!  
!! > 
!! > Quoth "A. Sinan Unur" <usa1@llenroc.ude.invalid>:
!! >> 
!! >> system('cp', "$source/*.c", $target) == 0
!! >>          or die "System failed: $?;
!! > 
!! > Err... this may work on Win32, but any system with C exec conventions
!! > will require a shell to expand the wildcard.
!!  
!!  You are right. I only tried it on Windows 98 with copy instead of cp. Since 
!!  copy is a built-in with command.com, it did not have a problem expanding 
!!  the wildcard. However, I just noticed another problem with it: Since I had 
!!  forgotten to create the target directory, it appended all the files (in 
!!  text mode) to create one file with the directory name I had in $target.
!!  
!!  I think this justifies my preference for not shelling out for wholesale 
!!  file operations, but using File::Copy.


I, OTOH have issues with File::Copy, and never use it, and always "shell"
out. (Well, I always use "system cp", but that doesn't always involve a 
shell). Issues I have with File::Copy:

    - It doesn't respect the permissions bits of original file.
    - Only supports 2 file arguments. No file to directory, let alone
      multiple files to directories.
    - No recursion.
    - No -f, -p, -H, -d, or -p support.
    - Can't change it to a remote copy with minimal modification of
      the command name (rcp/scp) and command line options.

File::Copy offers me nothing over 'system cp' (No, I don't care for 
portability to non-POSIX systems - if you can't be POSIX, screw you).



Abigail
-- 
sub A::TIESCALAR{bless\my$x=>A};package B;@q[0..3]=qw/Hacker Perl
Another Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => qq 'A';print "$shoe $shoe $shoe $shoe\n";


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

Date: 25 Oct 2004 00:39:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: copying files
Message-Id: <slrncnoips.3ac.abigail@alexandra.abigail.nl>

Ben Morrow (usenet@morrow.me.uk) wrote on MMMMLXXII September MCMXCIII in
<URL:news:acnt42-to4.ln1@osiris.mauzo.dyndns.org>:
%%  
%%  Quoth "A. Sinan Unur" <usa1@llenroc.ude.invalid>:
%% > 
%% > I think this justifies my preference for not shelling out for wholesale 
%% > file operations, but using File::Copy.
%%  
%%  s/for.*operations/ever/
%%  s/(?=using)/ or writing/
%%  s/File::Copy/an appropriate module/


Giving us:

    I think this justifies my preference for ever, but  or writingusing
    an appropriate module


That doesn't make much sense to me.


Perhaps you want to say that you prefer using an appropriate module
instead of shelling out. I fully agree with that. That's why I 
shell out to copy a file - because File::Copy isn't appropriate. ;-)



Abigail
-- 
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};


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

Date: 25 Oct 2004 00:06:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Fast random string generation
Message-Id: <slrncnogrv.3ac.abigail@alexandra.abigail.nl>

Derek Fountain (nospam@example.com) wrote on MMMMLXXII September MCMXCIII
in <URL:news:417b232b$0$13761$5a62ac22@per-qv1-newsreader-01.iinet.net.au>:
<>  I need to generate a string of random characters, say about 20,000
<>  characters long. And I need to do it quickly! I tried the obvious:
<>  
<>      for( my $i=0; $i<20000; $i++ ) {
<>        $str .= chr(int(rand(256)));
<>      }
<>  
<>  which works, but I have a feeling there must be a faster way than doing
<>  20,000 string concatenations...?


Write it in C.


#!/usr/bin/perl

use strict;
use warnings;
no warnings qw /syntax/;

use Inline 'C';

sub r_string;

print r_string (20_000), "\n";

__END__
__C__
char * r_string (int l) {
    char * str;
    int    i;

    srand (time ((time_t) NULL));
    if ((str = (char *) malloc (l * sizeof (char))) == (char *) NULL) {
        perror (malloc);
        exit (-1);
    }
    for (i = 0; i < l; i ++) {
        str [i] = rand () % 255;
    }
    return (str);
}
-- 
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: Mon, 25 Oct 2004 00:40:36 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: foreach vs. for
Message-Id: <k4rt42-lj5.ln1@osiris.mauzo.dyndns.org>


Quoth Sherm Pendley <spamtrap@dot-app.org>:
> daniel kaplan wrote:
> 
> > am trying to find out if there is an essential difference between the way
> > the two run that you would chose one over the other.  the best answer i have
> > found so far (book) was "foreach is longer to type".
> 
> It's primarily a matter of style. If you're coming to Perl from C, you 
> might be more comfortable, at least for now, with for.

Eh?

There are two distinct meanings of the 'for' keyword in Perl. The first
is in the C-style for loop

for (init; cond; loop) {

, which is (almost) just a wrapper for a while loop, and you almost
never need. The second is a pure synonym for 'foreach'

for (LIST) {

and is in every way equivalent. AFAICT, most people use 'for' rather
than 'foreach', because it's shorter; however, this type of loop is
usually called a 'foreach loop' to distinguish it from the 'C-style for
loop' above.

All of this is explained perfectly well in the std docs, of course (and
if it isn't, we want to know so we can fix them).

I would have thought that someone coming to Perl from C might want to
use 'foreach' for Perl-style for loops, so that they don't confuse them
with the C-style for loops they are used to; but I don't know. I've
never used 'foreach' in my life, but then I came to Perl as much from sh
as from C :).

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk


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

Date: Sun, 24 Oct 2004 20:36:01 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: foreach vs. for
Message-Id: <dKidnUn2uM3v1-HcRVn-uA@adelphia.com>

Ben Morrow wrote:

> There are two distinct meanings of the 'for' keyword in Perl. The first
> is in the C-style for loop
> 
> for (init; cond; loop) {
> 
> , which is (almost) just a wrapper for a while loop, and you almost
> never need.

That's the one I was thinking of. I can think of a few cases where it 
might be necessary - iterating over every third element in an array, for 
example - but like you say here it's almost never needed.

On the other hand - and this is where it's a matter of style - any Perl 
style "foreach" loop can also be written as a C style "for". So if 
you're a C programmer who's comfortable with that style, there's no 
strong reason *not* to use it.

 > The second is a pure synonym for 'foreach'
> 
> for (LIST) {

My bad - I use "for" this way so rarely that I'd forgotten that you 
could. Sorry! I *do* use "foreach" fairly often, but I always spell it out.

> I would have thought that someone coming to Perl from C might want to
> use 'foreach' for Perl-style for loops, so that they don't confuse them
> with the C-style for loops they are used to; but I don't know.

That's probably why I do it the way I do. I came from C originally, 
although that was many moons ago. I began by using C-style for 
exclusively, and then gradually moving over to foreach as a grew more 
accustomed to coding in Perl.

I've now come full circle, and occasionally find myself writing foreach 
in C... :-( Ah well, at least I've gotten over my even older BASIC and 
Pascal habits.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 25 Oct 2004 10:31:42 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: foreach vs. for
Message-Id: <417c4ab4$0$13746$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

Ben Morrow wrote:
> Quoth Sherm Pendley <spamtrap@dot-app.org>:
> 
>>daniel kaplan wrote:
>>
>>
>>>am trying to find out if there is an essential difference between the way
>>>the two run that you would chose one over the other.  the best answer i have
>>>found so far (book) was "foreach is longer to type".
>>
>>It's primarily a matter of style. If you're coming to Perl from C, you 
>>might be more comfortable, at least for now, with for.
> 
> 
> Eh?
> 
> There are two distinct meanings of the 'for' keyword in Perl. The first
> is in the C-style for loop
> 
> for (init; cond; loop) {
> 
> , which is (almost) just a wrapper for a while loop, and you almost
> never need. The second is a pure synonym for 'foreach'
> 

So is the first ..... isn't it ?
I mean 'for' and 'foreach' are simply synonymous, irrespective of which 
of the "two distinct meanings" you're referring to.

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: 24 Oct 2004 22:21:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Hard regexp problem
Message-Id: <slrncnoanf.3ac.abigail@alexandra.abigail.nl>

Brian McCauley (nobull@mail.com) wrote on MMMMLXXI September MCMXCIII in
<URL:news:cld243$b09$1@slavica.ukpost.com>:
//  
//  Abigail wrote:
// > Aaron Sherman (AaronJSherman@gmail.com) wrote on MMMMLXX September
// > MCMXCIII in <URL:news:a2d0070.0410221555.37ea14c8@posting.google.com>:
// > ()  I was stumped for a while today, when I ran into a regular expression
// > ()  problem. Now, I'm a pretty good regexp hacker, but this problem was so
// > ()  constrained and seemed at first glance to be so wrong for a regexp
// > ()  that I didn't think it could be done. However, in specifying it to a
// > ()  friend, I realized that it could.
// > ()  
// > ()  I'm curious to see if there's a better solution.
// > ()  
// > ()  The problem is this: You have a function call in a library that takes
// > ()  a regexp, anchors it on both ends by adding "^" and "$" to the
// > ()  beginning end, and then applies that to an input string.
// > ()  
// > ()    sub foo {
// > ()      my $re = shift;
// > ()      my $in = <STDIN>;
// > ()      die "'$in' is bad" unless $in =~ /^$re$/;
// > ()    }
// > ()  
// > ()  It exits with an error if the string does not match the regexp. I
// > ()  wanted to accept strings that did NOT contain a particular substring.
// > ()  Normally, I would have written:
// > ()  
// > ()   !/xyz/
// > 
// >     /^[^x]*(?:x(?!yx)[^x]*)*$/
// > 
// > Or:
// > 
// >     /^(?:(?!xyz).)*$/
// > 
//  
//  Er no,

No? You mean, any of my regexen are wrong? Could you give an example of a
string were it gives the wrong result?

//  /^(?!.*xyz).*$/

A trailing .*, always very useful in a regexp.

The disadvantage of '/^(?!.*xyz).*$/$ is that it isn't easy to use it as
part of a larger expression - for instance if only part of your string
should not contain "xyz". My expression OTOH can easily be taken and
put in a larger expression.



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: Sun, 24 Oct 2004 17:53:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Please don't feed the troll (was Re: arrays of arrays question)
Message-Id: <slrncnocip.g1i.tadmc@magna.augustmail.com>

Matt Garrish <matthew.garrish@sympatico.ca> wrote:
> "daniel kaplan" <nospam@nospam.com> wrote in message 
> news:1098640155.622711@nntp.acecape.com...


>> you know "sherm", and i guess with a name like that i really should 
>> forgive
>> you for  being a condesending ass....perhaps your parents should have 
>> looked
>> through the "names guaranteed to lose your lunch money with" faq?


Only people lacking sufficient intellect to develop convincing
arguments in support of their point resort to ad-hominem as 
it is an admission that they couldn't really think of anything
substantial to say, yet they are going to insist on saying *something*
anyway.



It ought to be pretty clear to most Usenauts by now what we have
here, time to apply The Standard Protocol.


   Please don't feed the troll!


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


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

Date: 24 Oct 2004 23:04:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Practical Extraction Recording Language
Message-Id: <slrncnod7c.3ac.abigail@alexandra.abigail.nl>

Uri Guttman (uri@stemsystems.com) wrote on MMMMLXXII September MCMXCIII
in <URL:news:x7wtxgbq7q.fsf@mail.sysarch.com>:
||  
||  this page is mind boggling. if someone can find an email address, feel
||  free to forward my critique.


Three seconds with google gave me:
http://www.unc.edu/~husted/Contactme.htm, which has two of her email
addresses.


Abigail
-- 
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail


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

Date: Sun, 24 Oct 2004 18:15:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problem with useless use error message
Message-Id: <slrncnodsa.g1i.tadmc@magna.augustmail.com>

delfuego <djcameron60616@yahoo.com> wrote:

> I am trying to write a simple Perl program to do the following:
> Open /etc/passwd for read, create an output file in cwd for append,
> cut the fields 1,3-4,6 from /etc/passwd and redirect that output to
> the output file password, then close the two file handles for the
> input and output files.


Here is a complete Perl program that does that:

   perl -lne 'print join ":", (split /:/)[0,2,3,5]' /etc/passwd >>password


> [root@localhost james]# ./program.pl


Yikes!

You shouldn't do things as root unless the thing *requires* that
you be root.

You do not need to be root to do what you describe above, so don't
be root when you are doing the above.


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


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

Date: 25 Oct 2004 00:27:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: What's the seed?
Message-Id: <slrncnoi4a.3ac.abigail@alexandra.abigail.nl>

Derek Fountain (nospam@example.com) wrote on MMMMLXXII September MCMXCIII
in <URL:news:417b1c6f$0$13760$5a62ac22@per-qv1-newsreader-01.iinet.net.au>:
[]  In any recent version of Perl, the seed for the random number generator is
[]  set at the first time rand() is called. Can I find out what that seed is so
[]  I can subsequently reproduce the random sequence?

Not from standard Perl. Perhaps if you write a piece of XS.

[]  At present I'm setting my own seed using "time ^ ($$ + ($$ << 15))", but my
[]  program is being run repeatedly over and over, and only takes a fraction of
[]  a second to do its job. That means time is often the same for several runs,
[]  and $$ tends to go up in small, sometimes single, steps. I have my
[]  suspicions about the quality of my seed!

I do believe "time ^ ($$ + ($$ << 15))" is a good seed to defend against
exactly what you are describing. Many years ago, the manual page suggested
to use "time ^ $$", until I noticed a problem if you run the same program
repeatedly in a small time frame. Analysis shows that 

    time ^ $$ == (time + 1) ^ ($$ + 1)

one third of a time. They are identical if time and $$ end in the same
number of 1s.

That's why I suggested to use "time ^ ($$ + ($$ << 15))", which doesn't
suffer from that problem, and that because the standard suggestion until
Perl set a seed by itself (one based on various things, including the
output of ps, the current time and the process id).

Here's a link to the relevant post:

http://www.google.nl/groups?q=srand++third+group:comp.lang.perl.misc+author:abigail&hl=en&lr=&safe=off&selm=3148E9E1.21CA6C29%40www.iaf.nl&rnum=3



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Mon, 25 Oct 2004 00:33:25 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: where download web application source code examples ?
Message-Id: <5nqt42-lj5.ln1@osiris.mauzo.dyndns.org>


Quoth jasper_marzin@yahoo.com (Jasper):
> Hi building an ecommerce website here, is there anywhere on the web
> one can download the perl source for a basic one ?  Its probably a
> search problem but I cant find any..

Try

http://www.google.com/
http://search.cpan.org/
http://jobs.perl.org/

Request for pre-written scripts are not welcome here. If you wish to
write your own and get stuck, we will be happy to help you.

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
ben@morrow.me.uk                                          Frank Herbert, 'Dune'


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 7298
***************************************


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