[24892] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7144 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 15 18:06:55 2004

Date: Wed, 15 Sep 2004 15:05:18 -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           Wed, 15 Sep 2004     Volume: 10 Number: 7144

Today's topics:
    Re: $| (undocumented) magic? (J. Romano)
    Re: $| (undocumented) magic? <notvalid@email.com>
    Re: a splice question <someone@example.com>
    Re: Best place to learn perl? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Best place to learn perl? (Jim Keenan)
    Re: Best place to learn perl? <zebee@zip.com.au>
    Re: Best place to learn perl? <notvalid@email.com>
        Closures with $_? <bik.mido@tiscalinet.it>
    Re: Closures with $_? ctcgag@hotmail.com
        external program <simplitia@gmail.com>
    Re: external program <mritty@gmail.com>
    Re: external program <jgibson@mail.arc.nasa.gov>
    Re: Help with globbing (Mr. Land)
    Re: Help with globbing (Mr. Land)
    Re: How do I set up DBI? <news4@sidestreet.tzo.com>
    Re: hv_iterinit has side effects - who cares about PL t (Ozgun Erdogan)
    Re: hv_iterinit has side effects - who cares about PL t <joe+usenet@sunstarsys.com>
    Re: hv_iterinit has side effects - who cares about PL t ctcgag@hotmail.com
    Re: newbie question <nds@none.com>
    Re: Passing a regex reference through a hashed value to <someone@example.com>
    Re: Regular expression to match month number 1,...,12 ( <bigal187@invalid.rx.eastcoasttfc.com>
    Re: Regular expression to match month number 1,...,12 ( <bigal187@invalid.rx.eastcoasttfc.com>
        replace ever 80th character in a string with a quote jason@cyberpine.com
    Re: replace ever 80th character in a string with a quot <noreply@gunnar.cc>
    Re: replace ever 80th character in a string with a quot <gifford@umich.edu>
        require("filex.pl")  , where the file? (Mimi)
    Re: require("filex.pl")  , where the file? <dwall@fastmail.fm>
    Re: Running as a Service <alder.bw@forces.gc.ca>
    Re: Using RE's to match a word split across lines? les0624@_cox.net
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 15 Sep 2004 08:08:47 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: $| (undocumented) magic?
Message-Id: <b893f5d4.0409150708.573c24f4@posting.google.com>

> On 14 Sep 2004 07:40:16 -0700, jl_post@hotmail.com (J. Romano) wrote:
> 
> >   Forgive me for bringing this up one more time,
> >Michele.  I've been thinking about this, and it
> >seems to me that $| may have been implemented to
> >return 1 (if true) in order to behave like a boolean
> >variable.  This would be an advantage when comparing
> >to boolean variables, like in this example:

Michele Dondi <bik.mido@tiscalinet.it> replied in message
news:<jckek09ghen8j4r7e76aeevs0rpcohtq9r@4ax.com>...
> 
>   Forgive me for this answer that most likely won't
> satisfy you, Jean-Luc.  I've been thinking about this,
> and it seems to me that $| may have been implemented
> that way to help me finding the final form for my most
> recent JAPH


   I'm not sure if your reply was meant to be taken as sarcasm, but
either way... good for you!  It's always good to learn something new
when creating new JAPHs!

   -- Jean-Luc


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

Date: Wed, 15 Sep 2004 16:25:05 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: $| (undocumented) magic?
Message-Id: <B1_1d.21323$7W3.102@newssvr29.news.prodigy.com>

Sherm Pendley wrote:

> Michele Dondi wrote:
> 
>> You may think what you want, but IMHO spending some time on JAPHs,
>> golf et similia is an aid to improve one's programming skills also in
>> "productive" code.
> 
> 
> Yeah, but what you practice is what you do by habit later. Do you 
> *really* want JAPH-style code to appear in production scripts?

No, but that doesn't mean that JAPHs and golf promote "bad" habits 
(whatever the definition of "bad" might be). I have never spent too much 
time on JAPHs, but have done so on perlgolf (over at perlgolf.org during 
its earlier days). And, I must admit, I learnt lots of useful techniques 
and discovered a lot of interesting properties of Perl's built-in vars 
in the process of squeezing just one more character out of my code. As a 
matter of fact, I learnt about $|--'s magic when one person used it in 
his golf code to alternate between two elements, while everyone else 
used some variation of ++$i%2. It was exciting and very insightful to 
figure those things out.

I take all of this as a form of edutainment and don't allow it into 
production code. Afterall, watching a violent movie doesn't make a 
(normal ;) person want to go out on a rampage.

> Also, JAPHs as sigs tend to give a bad impression of the language to 
> those who've never seen any other Perl. They promote the idea of an 
> insular community that delights in writing obscure code that's difficult 
> for newbies and outsiders to grok.

They're just jealous because they can't write any valid Python program 
in just four lines (/me ducks and runs for cover).

--Ala


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

Date: Wed, 15 Sep 2004 17:58:10 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: a splice question
Message-Id: <So%1d.35901$XP3.19782@edtnps84>

Michele Dondi wrote:
> On Wed, 15 Sep 2004 05:21:10 GMT, Uri Guttman <uri@stemsystems.com>
> wrote:
> 
>> >> but you could also use File::ReadBackwards:
>>
>> JWK> Or use a list slice (instead of copying the list to an array.)
>>
>> JWK> print +( <FILE> )[ -10 .. -1 ];
>>
>>that still reads in the entire file into a list of lines and then slices
>>it. file::readbackwards never reads more than it needs (it actually does
>>block i/o so it reads many lines at one time).
> 
> He did never claim it doesn't. His suggestion was reasonable in that
> it achieves the same effect of the cited one eliminating the somewhat
> unnecessary step of creating a reference to an anonymous array and
> then dereferencing it.

As well as the overhead of calling the splice function.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 15 Sep 2004 08:42:00 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Best place to learn perl?
Message-Id: <8f4m12x7rq.ln2@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2004-09-15, Page <dummymb@hotmail.com> wrote:

> But when I try to assign @{$struct->{treemap}->[0]->{pscript}} to a
> variable, perl vomits, for example:
> $PATH = @{$struct->{treemap}->[0]->{pscript}};

One other item you can take from the discussion is to be as
technical as possible.  When you describe perl ''vomiting'',
we don't know what you see (though in some cases people can
make a good guess).  If I read the code above, I'd guess
that $PATH got a numeric value, but I wouldn't call that
vomiting.  But if you post the exact error perl gives, there
is less likely to be a misunderstanding.

> Why can't I assign this value to a variable so that I can use the
> variable over and over.  I know this must have a simple answer. 

Check David's post for a good explanation.  What do you plan
on doing with $PATH (or @PATH)?  You may want to assign it
differently, or parse it after assigning it.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBSGLGhVcNCxZ5ID8RAhpnAJ9UBOx8LI0/CfWGVNyjV/XmI4TEpACfRHFX
HlzT9hr5biUl1Oa64vU07kg=
=o12J
-----END PGP SIGNATURE-----


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

Date: 15 Sep 2004 10:40:06 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Best place to learn perl?
Message-Id: <196cb7af.0409150940.4b022a8d@posting.google.com>

dummymb@hotmail.com (Page) wrote in message news:<6742094.0409141011.720703e6@posting.google.com>...
> Ok.  I give.  I'm throwing in the towell.  No matter how long I use
> perl, some of the syntax just doesn't make any sense to me.
> 
> Any suggestions on the best place to learn Perl?  I own a 1/2 dozen
> books or so and they are only helpful to a point.
> 
> Is there an online school or should I try to take a night course at
> one of the local colleges?
> 

For some definition of 'local', yes.  I used to teach a 6-week,
14-hour introduction to Perl ... but I have to admit that a full
semester course would have been vastly better.

Problem is:  Most continuing ed schools offer courses base on expected
demand.  While they may schedule a course, they usually need a minimum
enrollment to actually have the course run; otherwise, they cancel it
and tell the instructor (me) to chill.  And the simple fact is that
such schools have greater demand for HTML, Flash, etc., than they do
for more-hard core computer language/science fare.

But I can make two suggestions:  (1) There are mailing lists
specifically oriented to beginners in Perl.  These tend to be much
more receptive to beginners than this list.  Check out perl-beginners
at Yahoo! Groups and the beginners-level lists at learn.perl.org.  (2)
For some definition of 'local', there is a Perlmongers group in your
vicinity, which may or may not hold technical meetings on a regular
basis.  Check those out at pm.org

Jim Keenan


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

Date: Wed, 15 Sep 2004 19:23:07 GMT
From: Zebee Johnstone <zebee@zip.com.au>
Subject: Re: Best place to learn perl?
Message-Id: <slrnckh59g.l55.zebee@zeus.zipworld.com.au>

In comp.lang.perl.misc on 15 Sep 2004 06:30:33 -0700
Page <dummymb@hotmail.com> wrote:
> 
> All of you guys have been AWESOME on this post.  With the help of your
> posts and a lot of tinkering on my part, I do finally understand the
> code that I originally posted.  I'd be lying if I said I no longer
> need to take a class on this stuff though, so I'll look around and see
> what I find.

googling for "perl training online" came up with
http://www.hwg.org/services/classes/perltraining.html

of course you won't be diving straight into complex data structures with
that. 

Zebee


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

Date: Wed, 15 Sep 2004 20:29:07 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: Best place to learn perl?
Message-Id: <nC12d.20052$AK3.7738@newssvr27.news.prodigy.com>

Page wrote:

> Is there an online school or should I try to take a night course at
> one of the local colleges?

The best online school I can think of is comp.lang.perl.misc. I learnt 
*A LOT* just from lurking on the ng. 99.99% of all questions you will 
ever come up with have already been answered here dozens of times, and 
will be answered again and again on a daily basis.

So, my advice to you is read as many posts as you can on clpmisc. And 
just when you feel you lurked long enough, lurk around some more.

--Ala


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

Date: Wed, 15 Sep 2004 21:31:01 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Closures with $_?
Message-Id: <ecjgk0hrhab73tvrgfd8ucv06liuo7enc0@4ax.com>

The documentation is clear (and I'm not contending this!) about the
fact that closures are about *lexical* variables.

Thus I *do* understand why the following doesn't work as (I, for one,
could have) expected:

  # perl -le 'print map $_->(), map { sub { $_ } } qw/f o o/'
  CODE(0x8137f84)CODE(0x8137f84)CODE(0x8137f84)

BTW: OTOH I do *not* understand *how* exactly it fails to work, i.e.
what I actually get. Data::Dumper on

  map { sub { $_ } } ...

gives me

  $VAR1 = sub { "DUMMY" };
  $VAR2 = $VAR1;
  $VAR3 = $VAR1;

As a side note indeed this is *not* WIM...

However, to return to the main theme, using

  map { my $t=$_; sub { $t } } qw/f o o/

instead does exactly what I want, again as of the documentation. But
IMHO the latter conveys the psychological feeling of being equivalent
to the former, just in a more clumsy form.

So I wonder wether, apart possible technical difficulties, there are
other issues against the possibility of having closures using $_.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 15 Sep 2004 20:31:18 GMT
From: ctcgag@hotmail.com
Subject: Re: Closures with $_?
Message-Id: <20040915163118.523$aP@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> The documentation is clear (and I'm not contending this!) about the
> fact that closures are about *lexical* variables.
>
> Thus I *do* understand why the following doesn't work as (I, for one,
> could have) expected:
>
>   # perl -le 'print map $_->(), map { sub { $_ } } qw/f o o/'
>   CODE(0x8137f84)CODE(0x8137f84)CODE(0x8137f84)
>
> BTW: OTOH I do *not* understand *how* exactly it fails to work, i.e.
> what I actually get.

at the time of the outer map, $_ contains a code ref to a subroutine
which returns $_.  So $_->() just returns the value of $_,
which of course is a code ref and stringifies to look like that.
I am kind of surprised it is the *same* coderef each time, but I guess
I shouldn't be surprised.  Since code cannot be changed, but only replaced,
coderefs are essentially immutable and there is no reason not to put all
copies at the same address.


> Data::Dumper on
>
>   map { sub { $_ } } ...
>
> gives me
>
>   $VAR1 = sub { "DUMMY" };
>   $VAR2 = $VAR1;
>   $VAR3 = $VAR1;
>
> As a side note indeed this is *not* WIM...

What about it is not what you meant?  The "DUMMY" thing is just
there as an artifact of Data::Dumper (perldoc Data::Dumper, search
for DUMMY).  The fact that Data::Dumper shows $VAR2=$VAR1 means
that the reference objects don't just happen to be identical, but
rather that they are identical because they share the same underlying
storage.

> However, to return to the main theme, using
>
>   map { my $t=$_; sub { $t } } qw/f o o/
>
> instead does exactly what I want, again as of the documentation.

Did you run Data::Dumper on that as well?

> But
> IMHO the latter conveys the psychological feeling of being equivalent
> to the former, just in a more clumsy form.
>
> So I wonder wether, apart possible technical difficulties, there are
> other issues against the possibility of having closures using $_.

I don't understand what you include in "possible technical difficulties",
and therefore don't know what issues there are other than the ones you
already include.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 15 Sep 2004 09:16:40 -0700
From: "Alex  Lee" <simplitia@gmail.com>
Subject: external program
Message-Id: <ci9pt8$sfo@odak26.prod.google.com>

Dear all: I am having a problem that is driving me nuts and I hope some
one can help me.

Basically I need to access another program/script from my perl script.
This is easy. It is not when the program ask for an input (ie yes or
no).

here is an example:
------------------------------------
-- external script
$|=1;
print "enter something \n";
my $i = <>;
print "your input: $i";
-------------------------------------

-- my script:
open(TE, "perl externalScript.pl|") or die "no";
while(<TE>){
print "$_";
### need to print "hello world \n\r" when $_ =~ /enter/;
}

---------------------------------------
basically I need the external program to accept my input:
example: print "hello world \n\r" when $_ =~ /enter/;

I tried many different ways, but none works so far. I figure that is
probablt has something to do with redirecting my STDOUT from my script
to the external program. How I do not know. If anyone can help, it
would be greatly apprecaited. 

thanks.



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

Date: Wed, 15 Sep 2004 16:53:37 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: external program
Message-Id: <ls_1d.6939$IO5.513@trndny04>


"Alex Lee" <simplitia@gmail.com> wrote in message
news:ci9pt8$sfo@odak26.prod.google.com...
> Basically I need to access another program/script from my perl script.
> This is easy. It is not when the program ask for an input (ie yes or
> no).
>
> here is an example:
> ------------------------------------
> -- external script
> $|=1;
> print "enter something \n";
> my $i = <>;
> print "your input: $i";
> -------------------------------------
>
> -- my script:
> open(TE, "perl externalScript.pl|") or die "no";
> while(<TE>){
> print "$_";
> ### need to print "hello world \n\r" when $_ =~ /enter/;
> }
>
> ---------------------------------------
> basically I need the external program to accept my input:
> example: print "hello world \n\r" when $_ =~ /enter/;

Have a look at the Perl FAQ on this topic:

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

Paul Lalli




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

Date: Wed, 15 Sep 2004 13:46:46 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: external program
Message-Id: <150920041346463884%jgibson@mail.arc.nasa.gov>

In article <ci9pt8$sfo@odak26.prod.google.com>, Alex  Lee
<simplitia@gmail.com> wrote:

> Dear all: I am having a problem that is driving me nuts and I hope some
> one can help me.
> 
> Basically I need to access another program/script from my perl script.
> This is easy. It is not when the program ask for an input (ie yes or
> no).
> 
> here is an example:
> ------------------------------------
> -- external script
> $|=1;
> print "enter something \n";
> my $i = <>;
> print "your input: $i";
> -------------------------------------
> 
> -- my script:
> open(TE, "perl externalScript.pl|") or die "no";
> while(<TE>){
> print "$_";
> ### need to print "hello world \n\r" when $_ =~ /enter/;
> }
> 
> ---------------------------------------
> basically I need the external program to accept my input:
> example: print "hello world \n\r" when $_ =~ /enter/;
> 
> I tried many different ways, but none works so far. I figure that is
> probablt has something to do with redirecting my STDOUT from my script
> to the external program. How I do not know. If anyone can help, it
> would be greatly apprecaited. 

Look at 'perldoc perlipc' and search for 'Bidirectional Communication
with Another Process'.


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

Date: 15 Sep 2004 12:40:48 -0700
From: graftonfot@yahoo.com (Mr. Land)
Subject: Re: Help with globbing
Message-Id: <3a81cd7b.0409151140.3bb0e4c1@posting.google.com>

"John W. Krahn" <someone@example.com> wrote in message news:<0yL1d.20346$KU5.9553@edtnps89>...
> Yes you should.
> 
> my @fileList = grep /\Q$baseString\E.*[gG].*4$/, readdir DIR;
> 
> 
> John

I've not yet been exposed to that "\Q", "\E" syntax ... I'll have a
look, thanks very much for your help.


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

Date: 15 Sep 2004 12:42:54 -0700
From: graftonfot@yahoo.com (Mr. Land)
Subject: Re: Help with globbing
Message-Id: <3a81cd7b.0409151142.1611efaa@posting.google.com>

chris-usenet@roaima.co.uk wrote in message news:<3asl12-82m.ln1@moldev.cmagroup.co.uk>...
> Michael Slass <miknrene@drizzle.com> wrote:
> >   # match File One.[gG]<anything>4
> >   if ( $fileName =~ m/File One\.[gG].*4/ ) {
> 
> This also will match file names like "Not File One.gb4" and
> "File One.gotlotsmore4u.txt".
> 
> Chris

I should have mentioned that the "File One" part is going to be in a
variable, and it's already going to contain everything up to but not
including the last period in the full filename.  Thanks very much for
your reply.


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

Date: Wed, 15 Sep 2004 15:25:56 GMT
From: Trey Waters <news4@sidestreet.tzo.com>
Subject: Re: How do I set up DBI?
Message-Id: <Pine.LNX.4.58.0409151036540.28217@tj.fvqrfgerrg.gmb.pbz>

On Wed, 15 Sep 2004, Rob Richardson wrote:

> Greetings!
> 
> I have been maintaining a Perl/CGI application that tries to do
> database stuff without using a database, instead working with
> cumbersome comma-delimited text files.  I would dearly love to convert
> it to use a real live database.  The application is hosted on a Unix
> box, but I am developing it under WinXP Pro.  MySQL is available in
> both places.  Can somebody point me to a step-by-step guide for using
> DBI and MySQL under WinXP for somebody who has never done it before?
> 
> Thank you very much!
> 
> Rob Richardson
> 

Here's a snippet of code I used for a Sybase database.  The way I used it
(possibly not the most efficient, but it's what I could find at the time)
required that you knew at least how to form your own queries.  If you
can't manage that, best do some more reading.

This should be enough to get you started.  Remember, 'perldoc' is your 
friend!  :)

And to preface, printError() was a function I wrote to let the script
die nicely (since this was used in a CGI fashion).  Anyway, here goes:

-----------------------------------------------------
$dbname = "some.server.somewhere.com";
$dbuser = "AUser";
$dbpass = "user";
$dbdriv = "Sybase";
$dbtable= "messy_table";

use DBI;

<snip>

sub getDB_FID {
  my @gFID, @rowData;
  my $dbh, $query, $data, $i;
                                                                                                                                                                  
  $dbh = DBI->connect("dbi:Sybase:server=$dbname;database=MES", $dbuser, $dbpass) or printError("Can't access DB");
                                                                                                                                                                  
  $query = "select distinct Fermentor_ID from $dbtable;";
  $data = $dbh->prepare($query) or printError("Can't execute prepare statement!");
  $data->execute or printError("Can't execute statement!<BR>\n     ".$data->errstr);
                                                                                                                                                                  
  $i=0;
  while (@rowData = $data->fetchrow_array) {
    push(@gFID, $rowData[0];
  }
                                                                                                                                                                  
  return @gFID;
}
 .......

Basically, here's what's going on:

  DBI->connect(params)    Creates a connection to the database at the server
  $query                  Text string for DB query
  $dbh->prepare($query)   Module loads query
  $dbh->execute           Module sends query to DB
  $data->fetchrow_array   One array of data per result returned
                             (IOW, call this until you've gotten all results)
                              For this particular function, I only cared
                              about the first column of data

+-----------------------------------------------------------------------+
 Trey Waters                                    news4@sidestreet.tzo.com
                  Experience is the worst teacher.
     It always gives the test first and the instruction afterward.
+-----------------------------------------------------------------------+


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

Date: 15 Sep 2004 11:17:24 -0700
From: ozgune@gmail.com (Ozgun Erdogan)
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <48b43181.0409151017.526aa2a@posting.google.com>

> that, most thread implementations (POSIX threads for instance) don't
> know of a 'write lock'. 

POSIX threads just give you the basics. You can easily get read/write
locks by using these primitives. Type "POSIX threads read write locks"
in Google. And this POSIX argument is completely out of the point. C
doesn't have any primitive types that result in a write when you do a
read.

> Secure access to shared data happens through
> mutexes which are independent of the kind of access (read/write) that
> might happen. So the distinction into read and write lock is moot. 

Well, yes the distinction between read and write lock is moot. Unless
of course you are writing concurrent programs. Like databases, like
operating systems, etc..

I just gave "two threads" as a concrete example to show that reading
the hash structures was absolutely doing writes. There is a
distinction between a read and a write, and from my perspective (and
from my perspective), a read should do a read. This independent of
your claim for "the distinction into read and write lock is moot."
(besides, there is a very fine distinction there, like 30 years of
computer science history).


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

Date: 15 Sep 2004 15:42:59 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <87mzzr5nek.fsf@gemini.sunstarsys.com>

ozgune@gmail.com (Ozgun Erdogan) writes:

[...]

> I just gave "two threads" as a concrete example to show
> that reading the hash structures was absolutely doing writes.

  each %foo 

is an iterator.  Pretending it isn't won't resolve your
complaint.  Somewhere somebody decided that it was good 
to include an iterator API for perl hashes, PL theory
notwithstanding.

-- 
Joe Schaefer


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

Date: 15 Sep 2004 21:06:20 GMT
From: ctcgag@hotmail.com
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <20040915170620.380$lc@newsreader.com>

ozgune@gmail.com (Ozgun Erdogan) wrote:
> > Clearly, this will end in an infinite recursion. But is this a bug in
> > perl? One has to keep track of the references to make sure that
> > circular ones are detected correctly.
> >
>
> I think another example will make it clear why I think Perl's
> hv_iterinit()/hv_iternext() functions are not implemented as expected.
> Technically, these functions are doing reads. Say, you have two
> threads:
>
> T1
> ----
> grab_read_lock(hash1);
> hv_iterinit(hash1);
> while (not_endof_hash(hash1));
> {
>   hv_iternext(hash1);
>   print(value(hash1));
> }
> release_read_lock(hash1);
>
> T2
> ----
> grab_read_lock(hash1);
> hv_iterinit(hash1);
> while (not_endof_hash(hash1));
> {
>   hv_iternext(hash1);
>   print(value(hash1));
> }
> release_read_lock(hash1);
>
> Technically, independent of scheduling, you should see each of hash1's
> elements printed twice. This is because hv_iterinit()/hv_iternext()
> are supposed to do reads.

In my book, things that "are supposed to do reads" generally don't end
in "init".

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Wed, 15 Sep 2004 18:05:05 GMT
From: "NDS Ltd" <nds@none.com>
Subject: Re: newbie question
Message-Id: <lv%1d.528$Vt4.255@newsfe6-win.ntli.net>



THANKS KRAKLE IT WORKED!!



"Tintin" <tintin@invalid.invalid> wrote in message
news:2qnvbrF11ec9aU1@uni-berlin.de...
>
> "krakle" <krakle@visto.com> wrote in message
> news:237aaff8.0409132008.2f48a3bb@posting.google.com...
> > To run as CGI you must include a content header
>




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

Date: Wed, 15 Sep 2004 18:05:36 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Passing a regex reference through a hashed value to the right side of s///g
Message-Id: <Qv%1d.35949$XP3.18660@edtnps84>

Brian McCauley wrote:
> Yes! Yes! Yes! This is wonderfull.  I'm so happy to see this.

Are you being ironic?


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 15 Sep 2004 12:10:40 -0700
From: "187" <bigal187@invalid.rx.eastcoasttfc.com>
Subject: Re: Regular expression to match month number 1,...,12 (including e.g. 04,05)
Message-Id: <2qrielF133962U1@uni-berlin.de>

Paul Lutus wrote:
> Matt Benson wrote:
>
> First, DO NOT CROSS-POST as you are doing. Choose at most two
> newsgroups.

Oh come off it, he posted to groups that can be considered relevant to
this topic. RegEx, in the general sense, can be difficult to fully fit
into just one category. It's a part of sed, egrep, Perl, among many
other languages and tools. I'm sorry, but this is such a case when the
crossposting seems merited.

And come to think of it, that's the whole point of cross posting, to be
able to reach as many people for a given relevant topic without posting
multiple copies for each group (multi-posting), is it not?

>> How does a regular expression look like which should match exactly
>> one of the twelve possible month numbers
>> 1,...,12
>> Prepending a zero to one-digit month numbers should be allowed e.g.
>> 07
>
> Simple, but you need to say which language/utility/command you plan to
> process the expression. The below won't find the single-digit
> versions, but it will work for the double-digit forms:
>
> (01|02|03|04|05|06|07|08|09|10|11|12)

Why not   (1[0-2]|0?[1-9])   ? Takes care of leading 0's too :-) Should
work with most tools, like Perl, sed, egrep, and the likes.




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

Date: Wed, 15 Sep 2004 12:18:28 -0700
From: "187" <bigal187@invalid.rx.eastcoasttfc.com>
Subject: Re: Regular expression to match month number 1,...,12 (including e.g. 04,05)
Message-Id: <2qritaF12n3c2U1@uni-berlin.de>

Andres Monroy-Hernandez wrote:
> mbens@hotmail.com (Matt Benson) wrote in message
> news:<ci7i5r$c56$00$1@news.t-online.com>...
>> How does a regular expression look like which should match exactly
>> one of the twelve possible month numbers
>> 1,...,12
>> Prepending a zero to one-digit month numbers should be allowed e.g.
>> 07
>>
>> Matt
>
> Maybe what you want is:
> /^(0?[1-9]|1[0-2])$/

Bah, shame your post didn't come down the feed before I posted. Yours is
basically the same, but I admit a bit better, but only if if the number
is the only thing on the line.

Perhaps something like:

   /[^0-9]*(0?[1-9]|1[0-2])[^0-9]*/

Of if your RegEx engine supports \D (non-numeric) you can write it as:

   /\D*(0?[1-9]|1[0-2])\D*/

That way it can be caught not just when it's in a line by itself :-)




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

Date: 15 Sep 2004 13:43:02 -0700
From: jason@cyberpine.com
Subject: replace ever 80th character in a string with a quote
Message-Id: <ef0a04d7.0409151243.140b9678@posting.google.com>

running under HPUX.

Perl Newbie here.

I have a file with one record that can be very wide, possibly 5000+
bytes wide.

I need to replace every 80th byte in that record with a double quote.
I have the below script, with a failed attempt to replace x number of
spaces with the quote, but that solution will not work upon further
inspection of the data.

#!/usr/bin/perl
strict;
use warnings;
open RIN,"<x1" or die "ERROR!";
open ROUT,">x2" or die "ERROR!";
while (<RIN>) {
 $_=~s/                                     / "/g;
 print ROUT ($_);
}
print ROUT ("\"");
close (RIN);
close (ROUT);

Many thanks for any help or information.


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

Date: Wed, 15 Sep 2004 22:54:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: replace ever 80th character in a string with a quote
Message-Id: <2qroiaF12u73kU1@uni-berlin.de>

jason@cyberpine.com wrote:
> I have a file with one record that can be very wide, possibly 5000+
> bytes wide.
> 
> I need to replace every 80th byte in that record with a double
> quote.

     s/(.{79})./$1"/g;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 15 Sep 2004 17:10:26 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: replace ever 80th character in a string with a quote
Message-Id: <qszhdpznsql.fsf@asteroids.gpcc.itd.umich.edu>

jason@cyberpine.com writes:

> running under HPUX.
>
> Perl Newbie here.
>
> I have a file with one record that can be very wide, possibly 5000+
> bytes wide.
>
> I need to replace every 80th byte in that record with a double quote.

Something like this is one way to do the substitution without a regexp:

    use constant WIDTH => 80;
    my $s = "0123456789" x 100;

    foreach my $i (1..length($s)/WIDTH)
    {
      substr($s,$i*WIDTH-1,1)=q{'};
    }

    print $s,"\n";

----ScottG.


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

Date: 15 Sep 2004 13:26:33 -0700
From: mh2521@hotmail.com (Mimi)
Subject: require("filex.pl")  , where the file?
Message-Id: <67ed7834.0409151226.53da1fcb@posting.google.com>

I'm new to Pearl.  I read some asp file and see the line '
require("filex.pl")', I thought that filex should be in the same
directory, but it wasn't.  How can I know where the file located, or
it point to a dll file?   Try to read some documents about perl, but
noone mention it.  Thanks


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

Date: Wed, 15 Sep 2004 20:38:37 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: require("filex.pl")  , where the file?
Message-Id: <Xns9565A94EFB5E9dkwwashere@216.168.3.30>

Mimi <mh2521@hotmail.com> wrote:

> I'm new to Pearl.  I read some asp file and see the line '

Perl, not Pearl.

> require("filex.pl")', I thought that filex should be in the same
> directory, but it wasn't.  How can I know where the file located, or
> it point to a dll file?   Try to read some documents about perl, but
> noone mention it.  Thanks

'require' also looks in the list of places in @INC. 

See 

perldoc -f require
perldoc perlvar          # for info about @INC
perldoc lib              # manipulating @INC



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

Date: Wed, 15 Sep 2004 14:02:48 -0400
From: "Barry_Alder" <alder.bw@forces.gc.ca>
Subject: Re: Running as a Service
Message-Id: <e3c5ae0f92cc945573ba98808e9970ae@localhost.talkaboutprogramming.com>

Hi all:

Thanks for the comments and advice. My script wasn't using the
Win32::Daemon extension, which explains the odd behaviour. Unfortunately,
at the moment we are running with ActiveState PERL version 5.004-02 on
Windows NT4, and the oldest version of the Daemon extension that I've
found doesn't seem to work with it. However, the script, as is, works fine
as an 'at' job. 

ceo: thanks for the pointer to the David Roth site. It has all that I need
to get my script working properly for WIN2K, where we will be going to
later this year.

Thanks again!

Barry



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

Date: Wed, 15 Sep 2004 21:24:28 GMT
From: les0624@_cox.net
Subject: Re: Using RE's to match a word split across lines?
Message-Id: <Qb22d.299855$Oi.207801@fed1read04>

Thank you Paul and Uri. I used parts from your idea's and got it working!

Thanks,
Les


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

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


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