[10379] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3972 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 14 12:07:13 1998

Date: Wed, 14 Oct 98 09:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Oct 1998     Volume: 8 Number: 3972

Today's topics:
    Re: Are there any "perl.newbie" group or forum? (Andrew M. Langmead)
    Re: Are there any "perl.newbie" group or forum? <eashton@bbnplanet.com>
    Re: Checking file size and date in Perl Win32 <mikei@ix.netcom.com>
    Re: Continuing s/// from the last position. <erhmiru@erh.ericsson.se>
    Re: Curious perl -pe Question? (Andrew M. Langmead)
    Re: Equivalent of "unload" after "require"? (Mark-Jason Dominus)
        fcntl <caa@strata-group.com>
    Re: fcntl <jdf@pobox.com>
    Re: File Date/Time Stamp (Tad McClellan)
        Help! (_cim_)
        matching problems <troy.bull@uni.edu>
    Re: matching problems <jdf@pobox.com>
    Re: Need IP Address Sort Subroutine <williams@clark.net>
    Re: NET::FTP problem marcusj2764@my-dejanews.com
    Re: Perl Cookbook - is this the best perl book? (Karlon West)
        Perl on NT questions keydet89@yahoo.com
        perl plotting tool? <huang2@andrew.cmu.edu>
    Re: perl plotting tool? <eashton@bbnplanet.com>
    Re: POLL: Perl features springing into your face <h.b.furuseth@usit.uio.no>
        Sending mail via CGI/Perl ? <wezzy@dds.nl>
    Re: Sending mail via CGI/Perl ? <burt.adsit@gte.net>
    Re: Sorry (Tad McClellan)
        Sybperl problem: error/message handlers don't work in P (Rich Miller)
        Want to Learn CGI? (Trent Johnson)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 14 Oct 1998 14:13:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <F0tM6F.Esx@world.std.com>

Randal Schwartz <merlyn@stonehenge.com> writes:

>Having said that, I've heard of a number of people that have
>successfully used the llama to learn Perl as their first programming
>language.  I can only presume that they were naturally talented or
>perhaps a programmer in a previous lifetime or something.  :-)

Or else they've *used* computers enough to get a feel on how things
might be done. There would be some people who would say that
programmers haven't done a good job of hiding how a computer works.

When someone sees variable assignment, it may look like the
configuration files they've had to fiddle with (or even the
filesystem, a name associated with its data.) They may recognize
various operators and functions from their spreadsheet program. Arrays
might look like a table in a database they've been using. The common
sequence of programming, get input, manipulate data, output data,
might even look like they way they use a word processor.

Of course, these people aren't the ones with instructions written on a
postit attatched to their monitor. (The ones who miss a step and keep
going on, then get totally confused when they aren't where they are
supposed to be.) Maybe that does qualify as being naturally talented.

-- 
Andrew Langmead


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

Date: Wed, 14 Oct 1998 15:49:50 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <3624C59D.1369B62@bbnplanet.com>

Matt Curtin wrote:

> ObPerl: I do not think Perl is a good first programming language.
> Giving a new person who wants to "write programs" (or be a CS major)
> something with the power and flexibility of Perl before they
> understand what their choices entail is likely to produce the
> *opposite* result that an experienced programmer will see.  The very
> things about Perl that make it so liberating for the experienced
> programmer are what make it so encumbering for a non-programmer trying
> to understand how to program.

You make a good point here but I doubt that a CS degree guarantees the
ability to write and understand Perl or any other language. Scheme used
to be the training wheel of choice but I see a lot of curricula these
days using Java for some reason. As far as non-programmers go I think
Perl is a lot more friendly and useful than Java. IMOHO. At this point
one should start asking, how low do you go? How simple do you make it?
Do you start talking about the history of computing and why things are
the way they are? Then launch into the ultra basics of programming? How
much hand holding?

> Consider "our motto": "There's more than one way to do it."  Someone
> who doesn't know *any* ways to do it is likely to be overwhelmed by
> the number of choices for doing some of the most basic tasks.

I've always thought that the motto was rather welcoming and not
overwhelming. There is more than one correct answer and some are more
elegant than others. I also think the cookbook is a wonderful way for
people to get an idea of how things are done. I'm not trying to say
being hostile is the way, but there has to be a point of 'tough love'
here by saying you need to help yourself first. 

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Wed, 14 Oct 1998 10:27:28 -0400
From: Lyubov Ignatovsky <mikei@ix.netcom.com>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Checking file size and date in Perl Win32
Message-Id: <3624B4D0.84D5ECCE@ix.netcom.com>

Perhaps I should have been clearer in my post.
Let me explain the point.
Here is a transcript of the Win32 session:


D:\>dir ftest.pl
 Volume in drive D has no label.
 Volume Serial Number is 2628-16EF

 Directory of D:\

10/14/98  09:59a                   290 ftest.pl
               1 File(s)            290 bytes
                             23,166,976 bytes free

D:\>type ftest.pl
#!d:/perl/5.00502/bin/MSWin32-x86-object/perl.exe -w

@times = (stat($0))[8 .. 10];
@labels=("access",  "modify",  "create");
foreach $i (0 .. 2)
{
    ($min,$hour,$mday,$mon,$year) =  (localtime($times[$i]))[1 .. 5];
   print "$labels[$i]: ", $mon+1, "/$mday/$year $hour:$min\n";
}
D:\>perl ftest.pl
access: 10/14/98 0:0
modify: 10/14/98 9:59
create: 10/13/98 19:4

D:\>


Here is a transcript of the UNIX Shell session:

bash$ ls -al ftest.pl
-rwxr-xr-x   1 harocons wsmuser      250 Oct 14 10:09 ftest.pl
bash$ cat ftest.pl
#!/usr/loca/bin/perl

@times = (stat($0))[8 .. 10];
@labels = ("access", "modify", "create");
foreach $i (0 .. 2)
{
   ($min,$hour,$mday,$mon,$year) =  (localtime($times[$i]))[1 .. 5];
   print "$labels[$i]: ", $mon+1, "/$mday/$year $hour:$min\n";
}
bash$ perl ftest.pl
access: 10/14/98 10:11
modify: 10/14/98 10:9
create: 10/14/98 10:9
bash$

As you can see, the  last access time in Win32 is not reported correctly.
BTW,  it wasn't my intention to create his heated discussion  over such a small
issue.
Lyubov

Larry Rosler wrote:

> [Posted to comp.lang.perl.misc and copy mailed.]
>
> In article <upvbwsl01.fsf@jimbosntserver.soundimages.co.uk> on 13 Oct
> 1998 13:29:34 +0100, Jim Brewer <jimbo@soundimages.co.uk> says...
> > lr@hpl.hp.com (Larry Rosler) writes:
> ...
> > > #!/usr/local/bin/perl -w
> > > print -A $0, ' ', -C $0, ' ', -M $0, "\n";
> > > __END__
> > >
> > > And guess what -- it all works!  And even better than on Unix, because
> > > the -C gives the creation date as advertised, not the inode-change date.
> > > (No inodes, you know.)
> >
> > Well, somewhat misleading as well. These times are relative to when
> > your script began execution, not the dates the file system maintains
> > for these values. You would have to calculate the system dates from
> > the times returned by -x file tests above. They are not quite ready
> > for consumption in their raw form. Unless one only begins to live
> > while ones script is running. :)
>
> This carping has nothing whatever to do with the issue, which is that
> these three times *are* available for Windows/DOS systems, which was
> denied outright by the person I was responding to.  I chose to
> demonstrate this using the -x file tests.  If it makes you happier, use
> this to get the file system's Epoch times directly:
>
>     #!/usr/local/bin/perl -w
>     printf "%d %d %d\n" => (stat $0)[8, 10, 9];
>     __END__
>
> Yawn...
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com





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

Date: 14 Oct 1998 16:58:28 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: antti.boman@helsinki.fi
Subject: Re: Continuing s/// from the last position.
Message-Id: <lahfx78a23.fsf@erh.ericsson.se>

"Antti Boman" <antti.boman***NOSP@M***helsinki.fi> writes:
[...]
> [snip]
> 
> No I won't, it wasn't the answer :) Let me rephrase:
> 
> $str="This is the thing I want to change";
> $str=~s/the/a/;
> $str=~s/want/need/;

Sorry, but I've just missed the original question. Still I cannot find
it on my news server. Therefore I missinterprated Uri's answer. Uri,
take my apologies.

> This works. Ok, but for efficiency, if the string was huge, how can I
> continue the second search-replace from the point where the first one
> left??? 

Simply by cutting $str.

> I don't want to run thru all n gigabytes of the start of the data to
> find the thing from the end, if I know it's in the end.

Ok. I still don't know the original problem, but consider this code,
which changes your string back:

$str =~ s/(.*?)a/&p('the')/e;
$str =~ s/(.*?)need/&p('want')/e;
$str = $tmp.$str;

sub p{
    $tmp .= $1.shift(@_);
    '';
}

> Obviously the only way to do it is that C kind of solution, which works,
> even if it's not the easiest way there could be.

No, not the only way. This is PERL -> there are more ways to do things.
See my example before.

> I'll put this on the perl wish list. To get  \G to s///. That would solve
> it.

It would be nice, but it is usually not a good thing to require a language
change to solve a programming problem. This is my private opinion so
you don't need to agree.

Michal

> 
> Thanks to everyone.
> 
> -a


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

Date: Wed, 14 Oct 1998 14:40:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Curious perl -pe Question?
Message-Id: <F0tnG7.Cou@world.std.com>

liteindie@my-dejanews.com writes:

>perl -pe '$a=<STDIN>;print (a);'
[sample output deleted]
>Ain't the -p and -n switch suppose to put a enclose the statements in a loop?
>The printing order is confusing me

Yes, the "-p" switch does create a loop. It creates one like this
(with line numbers added so I can refer to them later)

1: while($_ = <ARGV>) {
2:  $a=<STDIN>;
3:  print $a;
4: }
5: continue {
6:   print $_;
7: }

The first line reads the next line from the next file on the command
line (or from STDIN if no files are present) and stores in in the
variable $_. The second line reads from standard input and stores it
in $a. The third line prints the line read from STDIN, and the sixth
line prints the contents of $_.

So with no files on the command line, it reads one line from STDIN,
and stores it in $_. Then it reads a second line from STDIN and stores
it in $a. Then it prints $a. Then it prints $_. And then it loops
around again.

(As a side note, what the first line does varies a bit depending on
your version of perl. The filehandle read line operator <> returns
undef on end of file, which evaluates to false in the while
conditional. There is one bizzare case that a line of text returned
from <> can also be false. Older perls's used to ignore this bounddry
condition and the implicit while loop acted exactly as above. Then
perl was fixed so that the implicit loop did
"while(defined($_=<ARGV>)". But then there was so much documentation
that said that the implicit assignment in a while loop looked like the
above that when people wanted to use an explicit assignment, they used
the code above without the defined(), so perl gave a warning about the
above construct when the "-w" switch was used. Finally, since so many
people got the error message, they changed the while construct so that
an implict defined() is done if the conditional is a read from a
filehandle assigned to a variable. So in the current version of the
perl inperpreter, even though I left out the defined() part it still
is acting like "-p"'s implicit loop. All of this parenthetical comment
is just to prevent someone posting a followup complaining about the
lack of defined(), although now I'm thinking that it would have been
easier just to put it in.)
-- 
Andrew Langmead


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

Date: 14 Oct 1998 10:15:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <702bl6$7tk$1@monet.op.net>

In article <7029m7$18h$1@nnrp1.dejanews.com>,  <wyndo@cxo.com> wrote:
>This works fine and it lets me load a player by simply REQUIRE-ing that save
>file. It's worked really great up until now.
>
>The problem I'm having is that you can only require the file one
> time. 

Use `do' instead of `require'.

Or (more normal) put the code into a subroutine, `require' it once
when the program starts up, and then call the subroutine when you want
to call the subroutine.



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

Date: Wed, 14 Oct 1998 09:33:38 -0500
From: "Charlene Abrams" <caa@strata-group.com>
Subject: fcntl
Message-Id: <702cmo$sv5$1@newsin-1.starnet.net>

I can't get fcntl to lock my file and have no idea why.

Background: In the C portions of our application,we successfully use fcntl
to put a lock on a file so that only one instance of [some] program will be
running. In the perl portions we had used a database table to similar
effect, but would rather steer clear of this method, preferring fcntl,
believing it to be more reliable.

I open the file for writing, chmod to 666, and then try:

fcntl FH, &F_SETLK, &F_WRLCK;

which fails.

I've perused all the books I have (the camel book), searched the FAQs and
everything I could find at www.perl.com and have come up blank. I'd
appreciate any and all help.

Thanks
Charlene Abrams
mailto:caa@strata-group.com





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

Date: 14 Oct 1998 17:47:38 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Charlene Abrams" <caa@strata-group.com>
Subject: Re: fcntl
Message-Id: <m3ogrfqh5x.fsf@joshua.panix.com>

"Charlene Abrams" <caa@strata-group.com> writes:

> I can't get fcntl to lock my file and have no idea why.

> I open the file for writing, chmod to 666, and then try:
    ^^^^^^^^^^^^^^^^^^^^^^^^^
Could you be more specific about the mode you're using?  If you open
the file like so

  open(F,">foo")

then you're clobbering it before you can ask for the lock.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Wed, 14 Oct 1998 08:42:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: File Date/Time Stamp
Message-Id: <ho9207.nlf.ln@flash.net>

r j huntington (wolph@merlin.albany.net) wrote:
: How can I get a file's timestamp in perl? I need to know when
: a file was created and compare it to time() minus some number
: of seconds. Thanks from a perl newbie.	-rh-


Perl FAQ, part 5:

   "How do I get a file's timestamp in perl?"


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


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

Date: Wed, 14 Oct 1998 15:35:05 GMT
From: cim@online.ee (_cim_)
Subject: Help!
Message-Id: <3624c413.35693622@news.online.ee>

I use this:

($final = $INPUT{update}) =~ s!</P>.*!!s;

to get all text up to the point when </P> appears.

I need it to check if </P> is among the 300 first chars. and if not
then only get all text up to char number 300.




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

Date: Wed, 14 Oct 1998 09:32:56 -0500
From: "Troy Bull" <troy.bull@uni.edu>
Subject: matching problems
Message-Id: <702cks$3kc@news.uni.edu>

I have a small program that does a search of the form

s/(\w{3}):(\w{3})/wrap stuff around $1 and $2/g

the problem is that it matches one case that I need for it not to
___:___ needs to not match  this is the only case that needs to
fail, if any one of the six underscores is a [a-zA-Z0-9] it should
match.  I am stuck on this one, if anyone has any ideas I would
appreciate the help.
thanks in advance

--
Troy Bull
Sr. Programmer Analyst
University of Northern Iowa





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

Date: 14 Oct 1998 17:54:35 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Troy Bull" <troy.bull@uni.edu>
Subject: Re: matching problems
Message-Id: <m3lnmjqguc.fsf@joshua.panix.com>

"Troy Bull" <troy.bull@uni.edu> writes:

> s/(\w{3}):(\w{3})/wrap stuff around $1 and $2/g
> 
> the problem is that it matches one case that I need for it not to
> ___:___ needs to not match  this is the only case that needs to
> fail, if any one of the six underscores is a [a-zA-Z0-9] it should
> match.

I'm sure you'll see several clever regex answers to this question, but 
I'd go with the obvious

  s{(\w{3}):(\w{3})}
   { ($1 eq '___' && $2 eq '___') 
     ? "$1:$2" 
     : "funky $1 and groovy $2"
   }gex

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Wed, 14 Oct 1998 10:05:35 -0500
From: "Joe Williams" <williams@clark.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <702ek9$fuf$1@news.onramp.net>

Gary - Many TXs. That's helpful. Here's another explanation of the same
problem (subroutines are at the end):

The subroutine below, get_ipa, is the standard way to pack an IP address. It
does, in fact, recreate the 32-bit IP address from the dotted quad address
by packing each quad number into an 8-bit byte and then concatenating each
8-bit byte together in the same order as the quads. This is not obvious,
because the ASCII character template "C" is being used to do the conversion.
However, if we know that C persumably works on any number less than 255
(extended ASCII) and that extended ASCII takes 8-bits, AND IP octets must be
less than 256, then all becomes clear. I think.

The binary structure that results will sort correctly using the standard
perl sort routine (which, with no alteration, sorts characters). This works
because ASCII chars are represented in 8-bit bytes, and sorting a binary
number like this works just fine. The number sort version of sort would NOT
work, because it would not be able to treat our binary structure as one of
the binary structures that it recognizes as representing decimal numbers.

The dotted_to_int function below takes a dotted quad and produces the
decimal equivalent, which as your calculation indicated, is 3343766983. This
should run on your system with no problem. The packed binary approach seems
to be standard to Perl's net subroutines, but if we converted to decimal
like this, we could certainly sort on the resulting decimal equivalents of
the IP address. This time however, we would have to use the numerical
version of Perl's sort routine for it to work correctly.

print dotted_to_int(199.77.210.67);

I first thought the following would work, but it doesn't:

print "Bintodec: "; print bintodec(pack("C4",199,77,210,67),"\n");  # Avoid
split function by beginning with the four quads.

The reason it doesn't is that bintodec takes a binary number and first packs
it into a 32-bit long binary structure, and then "unpacks" it as a decimal.
This doesn't work, because pack("C4",199,77,210,67) has ALREADY converted
the dotted quad into a binary number. The following works, however, as it
should, and produces the decimal equivalent of the IP address, 3343766983,
just like dotted_to_int above. At least, it works on my machine, and should
on yours.

print unpack("N", (pack("C4",199,77,210,67)) );

On a slightly different subject, you were puzzled by the bintodec routine,
and I can understand why. It is not straightforward. The "0" x 32 creates a
string of 32 zeros. The shift function without an argument uses by default
the argument of the subroutine @_. It "shifts" the argument string left on
one (sort of pops it off the left) and returns that value. The dot between
32 and shift concatenates the shifted argument to the 32 zeros. That is, if
the subroutine argument was 5 in binary, 101, you get 32 zeros, and 101, a
string 35 chars long. This is the first argument of the substr function. The
second argument is -32. The result is that 32 chars are clipped from the
right end of the 35 char string. This produces a 32 char string, in this
case, 32 zeros followed by 101. This is then packed into a 32-bit structure
by pack with the B32 argument.

This version of bintodec works just as well and is slightly clearer, I
think: unpack("N", pack("B32", substr("0" x 32 . $_[0], -32) ) );

The subroutines mentioned above are as follows:

sub bintodec { unpack("N", pack("B32", substr("0" x 32 . shift, -32) ) ); }

sub get_ipa{
     $_[0] =~ /([\d.]+)/;print "\n";
   return pack("C4",split(/\./,$1));
}

 sub dotted_to_int
{
  my @a = split /\./, $_[0]; # Each octet is in an array element of @a
  # Cycles from 0 to 3 over the four octets produced by split. The ..
operator expands $#a
 for ( 0..($#a) ) # $#a = number of array elements. The .. operator expands
$#a.
 {
  $n = $n + ( $a[$_] * (256**(3-$_)) ) ; # converts each octet to decimal &
adds them
    }
return $n;
 }

Thanks again for your help.

Joe Williams




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

Date: Wed, 14 Oct 1998 15:06:54 GMT
From: marcusj2764@my-dejanews.com
Subject: Re: NET::FTP problem
Message-Id: <702eme$93r$1@nnrp1.dejanews.com>

In article <01bdf706$9962dee0$77ea1286@steelres-pcm657.resmel.bhp.com.au>,
  "Ron Savage" <Savage.Ron.RS@bhp.com.au> wrote:
> You might be using the ActiveState Perl V 5.005.02, which butchered a few
> things. In particular, Net::FTP won't work >:(. Delete it and install the
> standard distribution (seriously).

Oops.  I'm using the ActiveState Perl V 5.005.02 distribution with
the libnet module insallted via PPM (last week) and have
been wondering why the Net::FTP stuff appears to be broken!  I switched
on debugging in the ftp constructor.  Looking at the debug output I saw
that I could log on OK, but as soon as I tried to do anything useful like
get a directory listing from the server I got a PORT error.

So, Ron, when you say 'install the standard distribution', please be a
bit more explicit.  Do you mean install the standard distribution of Perl,
the standard distribution of libnet, the network stuff in the box in
5.005.02 or what?  I would like to keep on using ActiveState's 5.005.02
but I also _need_ the Net::FTP module (or something a lot like it in
functionality).  Is there a solution?

Marcus

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


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

Date: 14 Oct 1998 15:09:04 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <702eqg$h4r@crchh14.us.nortel.com>

Brand Hilton (bhilton@tsg.adc.com) wrote:
> In article <MPG.108d6f7099de16f2989809@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >
> >My guess is that you eschewed 'grep' because it requires ~< two copies of 
> >the array at the same time.  Other than that, it would seem to be more 
> >efficient than repeated splices.
> >
> >Yes/no?

> Surprisingly not, according to recent my recent benchmarking
> (available in my reply to Abigail in this thread.)  It intrigued me so
> much that I decided to run a few more.  These probably won't be as
> accurate.  I cut down on the iterations so I wouldn't have to leave
> them 'til morning.

And a few more benchmarks, this time with big arrays.

You're right, fewer deletes, the nod goes to splice.
But if you have no idea what the data may be,
grep should probably be the usual choice, because
the best-case splice isn't a LOT better than the 
worst-case grep, but the worst-case splice is
terrible:

===================================================
** 100,000 element array, deleting over 40,952 elements

Benchmark: timing 4 iterations of grep, map, splice...
      grep: 12 secs (10.50 usr  0.12 sys = 10.62 cpu)
       map: 18 secs (13.60 usr  0.15 sys = 13.75 cpu)
    splice: 220 secs (168.06 usr  0.55 sys = 168.61 cpu)
===================================================

** 100,000 element array, deleting 20 elements
Benchmark: timing 4 iterations of grep, map, splice...
      grep: 14 secs (11.82 usr  0.09 sys = 11.91 cpu)
       map: 22 secs (15.87 usr  0.15 sys = 16.02 cpu)
    splice: 16 secs (11.28 usr  0.04 sys = 11.32 cpu)
===================================================

use Benchmark;

$count = 2;
timethese (1 << ($count || 0), {
  splice  => sub {@array3=(1..100000);
                  for ($index = $#array3; $index >= $[; $index--) {
                     if ($array3[$index] =~ /2/) {
                       splice @array3, $index, 1;
                     }
                   }
                  },
  map     => sub {@array4=(1..100000);
                  @array4 = map {/2/ ? () : $_} @array4; },
  grep    => sub {@array2=(1..100000);
                  @array2 = grep !/2/,@array2; },
});

timethese (1 << ($count || 0), {
  splice  => sub {@array3=(1..100000);
                  for ($index = $#array3; $index >= $[; $index--) {
                     if ($array3[$index] =~ /2222/) {
                       splice @array3, $index, 1;
                     }
                   }
                  },
  map     => sub {@array4=(1..100000);
                  @array4 = map {/2222/ ? () : $_} @array4; },
  grep    => sub {@array2=(1..100000);
                  @array2 = grep !/2222/,@array2; },
});


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

Date: Wed, 14 Oct 1998 14:23:37 GMT
From: keydet89@yahoo.com
Subject: Perl on NT questions
Message-Id: <702c58$4j3$1@nnrp1.dejanews.com>

I am somewhat new to Perl on NT, and I have the latest version
of Perl...ActivePerl from ActiveState...

1.  Does anyone know where I can find example scripts used by
sysadmins?  I am curious as to how the functionality of Perl is
used on NT for sysadmin and security functions...specifically
managing ACLs, the Registry, etc.

2.  Does anyone know where I can find the Win32::GUI or Tk modules?
I don't seem to have them in my distribution.  Also, is there someplace
where I can find examples to see how they are used, or a tutorial?

Thanks
Carv

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


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

Date: Wed, 14 Oct 1998 11:05:38 -0400
From: Cathy Huang <huang2@andrew.cmu.edu>
Subject: perl plotting tool?
Message-Id: <3624BDC2.E04E7855@andrew.cmu.edu>

Can anyone recommend a perl graphing tool that only requires perl 5.001?
I've looked at pgperl
(http://www.aao.gov.au/local/www/kgb/pgperl/)- are there any other good
ones? I need to generate html graphs.

Thanks-
Cathy




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

Date: Wed, 14 Oct 1998 15:55:33 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: perl plotting tool?
Message-Id: <3624C6F4.FEB16538@bbnplanet.com>

Cathy Huang wrote:

> Can anyone recommend a perl graphing tool that only requires perl 5.001?

Have you tried GNU Plot? I used to use that quite a bit for graphs
output to the web.
Its not a Perl module but it won't force you to use a newer version of
Perl.

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: 14 Oct 1998 16:50:35 +0200
From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
Subject: Re: POLL: Perl features springing into your face
Message-Id: <HBF.981014mps0@bombur2.uio.no>

M.J.T. Guy writes:
> Use an up-to-date Perl, e.g.
> 
> $ perl5.005 -wle 'print {time => 5}->{time};'
> 5
> $
> 
> This bug will also be mended in the forthcoming perl5.004_05 maintenance
> release.

Great.  Thanks!

-- 
Hallvard


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

Date: Wed, 14 Oct 1998 17:26:22 +0200
From: "WeZzy" <wezzy@dds.nl>
Subject: Sending mail via CGI/Perl ?
Message-Id: <702g2g$b96$1@enterprise.cistron.nl>

passme

Hiya,

I'm trying to make a form-mail-processing script,
that sends the information to an e-mail address
selected from a drop-down-menu...

Picture this:

You fill in a form, and you have to select a country
from a dropdownmenu, the value of this menu-option
is an e-mail address, i.e. you choose Netherlands,
the e-mail goes to netherlands@test.com, you choose
USA, the e-mail goes to usa@test.com get the picture ?

But to be able to do this, I have to know how I can read-out
the selection made in the drop-down-box, I guess that's not
the problem though, the real problem is HOW do I get this
information in the e-mail ?

Thought something like this:

open(MAIL,"|mail sales\@ggo.nl");

print MAIL <<"EOT";

This is a simple email response from a form.

Name:  $in{"name"}
Address: $in{"address"}
City:  $in{"city"}
State:  $in{"state"}
Zip:  $in{"zip"}
Phone:  $in{"phone"}
Email:  $in{"email"}

EOT

close(MAIL);

But instead of sales@ggo.nl the script has to insert the e-mail
address selected in the drop-down-box...

I hope I was clear enough in explaining the problem, if not please
e-mail me and I'll try to clearen it up.

Thanks in advance !

Wesly Grefrath








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

Date: Wed, 14 Oct 1998 11:49:23 -0400
From: Burt Adsit <burt.adsit@gte.net>
Subject: Re: Sending mail via CGI/Perl ?
Message-Id: <702h5k$4oj$1@news-1.news.gte.net>

Ya, I just use sendmail:

  open(MAIL,"|/usr/lib/sendmail -t");
  local($xxx)=select(MAIL); $|=1; select($xxx); # set flush control
  print MAIL "To: $to\n";
  print MAIL "From: $from\n";
  print MAIL "Subject: $subject\n\n";
  print MAIL "$body\n";
  close (MAIL);

Burt

WeZzy wrote:
> 

> Thought something like this:

snip

> 
> open(MAIL,"|mail sales\@ggo.nl");
> 
> print MAIL <<"EOT";
> 
> This is a simple email response from a form.
> 
> Name:  $in{"name"}
> Address: $in{"address"}
> City:  $in{"city"}
> State:  $in{"state"}
> Zip:  $in{"zip"}
> Phone:  $in{"phone"}
> Email:  $in{"email"}
> 
> EOT
> 
> close(MAIL);
>


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

Date: Wed, 14 Oct 1998 08:59:20 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Sorry
Message-Id: <ona207.tnf.ln@flash.net>

Robin Bank (rbank@csf.edu) wrote:

: Hey all... Sorry about my last posts.  I'll think of questions that aren't
: so stupid 


   The problem is not that the questions were stupid, but rather
   that they have already been adequately answered (in the FAQ,
   or in recent threads accessable via a Usenet archive such as
   www.dejanews.com).


   New stuff, even stupid new stuff, is welcomed.


: and won't ask to be e-mailed answers in the future....


   It is generally deemed OK to ask for a _copy_ to be emailed
   (though many will ignore the request anyway).

   Asking for the answer to be emailed (rather than posted and emailed)
   denies other members of our community access to the answer. Which
   may get some undies in a bundle, as we like to help many at once,
   rather than one at a time    ;-)


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


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

Date: 14 Oct 1998 00:50:59 GMT
From: rchmllr@ix.netcom.com (Rich Miller)
Subject: Sybperl problem: error/message handlers don't work in Perl debugger
Message-Id: <700shj$c2l@dfw-ixnews6.ix.netcom.com>

I've found that when I run Sybperl scripts through the Perl debugger,
message and error handlers don't appear to get called when they should
be.  As a simple example, when I run the following script from the
command line:

#!/opt/perl/bin/perl
use Sybase::DBlib;
$handler_called = 'no';
dberrhandle(err_handler);
dbmsghandle(msg_handler);
$dbh = Sybase::DBlib->dblogin('testlogin', 'testpwd', 'TESTSERVER');
$dbh->dbcmd('notacommand');
$dbh->dbsqlexec;
$dbh->dbclose
print "*** handler called? $handler_called ***\n";
exit;
sub err_handler {$handler_called = 'yes'; return INT_CANCEL;}
sub msg_handler {$handler_called = 'yes'; return 0;}

I get the expected result of

*** handler called? yes ***

with no error messages, indicating that the handlers were invoked
correctly when the invalid command was passed to the server for
processing.  When I add the -d debugging option to the magic line
and single-step through the program, however, I get the error message
from the server which should have been intercepted by the handlers,
and at the end I get the result

*** handler called? no ***

which seems to indicate that the handlers were never invoked.  Does
anyone have any experience with this problem, or any idea what could
be causing it?  For the record, I'm using Perl 5.004 and Sybperl 2.09
running under Solaris 2.6 to connect to a Sybase 11.0.3 server through
with the OpenClient 11.1.1 libraries.

Thanks,
Rich Miller
rchmllr@ix.netcom.com


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

Date: 14 Oct 1998 15:00:37 GMT
From: useractive@uiuc.edu (Trent Johnson)
Subject: Want to Learn CGI?
Message-Id: <702eal$oh1$2@vixen.cso.uiuc.edu>

Hiya,

Want to learn CGI with perl quickly, and have fun at the same time?  Check
out the great tutorials at www.useractive.com.  Once you finish the perl
tutorial, you can go on to try the javascript, and HTML tutorials.  Stop
by useractive.com today, and take our guided tour.  You'll love it. 


------------------------------------------------------------------------
http://www.useractive.com
The Best Tutorials, Lowest Hosting Rates, CGI Compiling, AND a complete
File Management Interface--for Amateur and Professional Web Developers.
------------------------------------------------------------------------



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3972
**************************************

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