[10235] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3828 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 25 19:07:17 1998

Date: Fri, 25 Sep 98 16:00:19 -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           Fri, 25 Sep 1998     Volume: 8 Number: 3828

Today's topics:
    Re: any way to encrypt my script? <zenin@bawdycaste.org>
        Anyone have a set of Coding Standards? <gnat@frii.com>
        Best inexpensive database? (Garrett Casey)
    Re: cat reese > /dev/null (was Re: Perl & Java - differ (Bart Lateur)
    Re: cat reese > /dev/null (was Re: Perl & Java - differ (Abigail)
    Re: cat reese > /dev/null (was Re: Perl & Java - differ (Abigail)
    Re: cat reese > /dev/null (was Re: Perl & Java - differ <borg@imaginary.com>
    Re: Code explanation (Pete Ratzlaff)
    Re: desperate for socket help <baliga@synopsys.com>
    Re: help with removing leading zeros with reg-exp (Gene Johannsen)
    Re: help with removing leading zeros with reg-exp Lee.Lindley@bigfoot.com
    Re: help with removing leading zeros with reg-exp (Larry Rosler)
    Re: help with removing leading zeros with reg-exp (Abigail)
        How do i unpack a 64-bit long? harry@my-dejanews.com
        How to redirect and kill an asynchronous process? <seth@claritech.com>
    Re: newbie array question (Pete Ratzlaff)
    Re: Perl and ODBC? <sjohns17@uic.edu>
    Re: Perl and ODBC? <sjohns17@uic.edu>
    Re: Perl as http User Agent?! (Alan Barclay)
        Perl version compatability <ian@no-spam.4site.co.uk>
    Re: Poll: How Did You Learn Perl? <camerond@mail.uca.edu>
        Problem Joining Lines In Delimited Data <ernestm@towery.com>
    Re: Redirection Question <tturton@cowboys.anet-dfw.com>
    Re: Redirection Question (Bart Lateur)
    Re: Rotating an array. <rick.delaney@shaw.wave.ca>
        Shell for testing Perl/CGI scripts!? <flanker@sonnet.ru>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 25 Sep 1998 21:35:14 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: any way to encrypt my script?
Message-Id: <906759200.29806@thrush.omix.com>

fnantes@my-dejanews.com wrote:
: The FAQ:
:    ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/doc/manual/html/pod/perlfaq3.html
: reads:

	The FAQ is wrong.  I'll probably be submitting a patch when I have
	the time.

: First of all, however, you can't take away read permission, because the source
: code has to be readable in order to be
: compiled and interpreted.

	This is incorrect.  Perl needs to be able to read it, but the user
	doesn't.  Perl code can be wrapped in C and feed to perl, which
	eliminates the requirement for the program to need read permissions.

	See my other post for an example.

	>snip<
: You can try using the native-code compiler described below,
: but crackers might be able to disassemble it.

	Only if they can read it, which object files can prevent as
	executables do not need read permission.

: These pose varying degrees of
: difficulty to people wanting to get at your code, but none can definitively
: conceal it (this is true of every language, not just Perl).

	This is true of all security, not just computer languages.

: You see how a trip to the FAQ can save a LOT of bandwidth?

	Not really.  The FAQ doens't answer the question, it only really
	says why it's a bad idea.

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


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

Date: 25 Sep 1998 16:06:26 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Anyone have a set of Coding Standards?
Message-Id: <5qsohfalul.fsf@prometheus.frii.com>

lemull@unx.sas.com (Lee Mulleady) writes:
> Can anyone point me to a set of Coding Standards developed
> specifically for Perl?

We get these questions once or twice a month.  Surely *someone* has
prepared, either for their own use or for their company/department's
use, a set of coding standards?

Everyone answers with "man perlstyle", I know, but this isn't what the
people asking the questions want to hear.  I'd like to collect a
couple of sets of standards, regardless of how formal.

Anyone ready to volunteer their company's?

Nat






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

Date: Fri, 25 Sep 1998 21:28:20 GMT
From: nospamno_adms1@cts.com (Garrett Casey)
Subject: Best inexpensive database?
Message-Id: <360c07df.368445716@nntp.cts.com>

I am using FreeBSD version 2.2.5-RELEASE, Perl version 5.004_01, and
Apache 1.2.6.

I want to create a Perl application to be used over the web (cgi).
What do you think is the best database that is inexpensive, fast,
supports a large amount of data, and works well with perl?  Since many
people will reading and writing to this database, it is imperative
that the tables will lock properly to avoid corruption.  I have heard
of mySQL and mSQL.  Are they good? Do you have any other suggestions?


Garrett Casey
nospamo_adms1@cts.com
Remove "nospamo_" To send me email.


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

Date: Fri, 25 Sep 1998 22:13:56 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <360c1440.98700@news.ping.be>

It might be just my Unix ignorance, but could somebody explain to me
what could be the possible use of copying something into the bin?

You're still stuck with the original.

	Bart.


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

Date: 25 Sep 1998 21:41:15 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <6uh2lr$7se$1@client3.news.psi.net>

George Reese (borg@imaginary.com) wrote on MDCCCLI September MCMXCIII in
<URL:news:wYRO1.2141$Ge.6836178@ptah.visi.com>:
++ 
++ Computer science majors are 100% irrelevant.

You are 100% irrelevant.

++                                               While I do have 6 years of
++ professional programming experience and 8 years of overall programming
++ experience, # of years of experience is actually a very poor guide to
++ what someone knows.

The horrible code I had to maintain of you was written not earlier than 1992.

That must have been some of your professional programming experience then.




Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 25 Sep 1998 21:52:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <6uh3ae$7se$2@client3.news.psi.net>

George Reese (borg@imaginary.com) wrote on MDCCCLI September MCMXCIII in
<URL:news:yRRO1.2136$Ge.6836178@ptah.visi.com>:
++ In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
++ : So you really mean: A "decade" is a good approximation of 7 years.
++ : 30%-43% error is not what I'd call a good approximation.
++ 
++ : In any case, a "decade" is a very poor approximation of 5 years.
++ : According to your resume, you first worked as a programmer in 1993.
++ : Your first attested programming experience (muds) was in late 1992.
++ 
++ : So I take it that by "a decade" you're just rounding 6 up to the
++ : nearest whole number of decades.
++ 
++ I have been programming for just shy of 8 years.  You can play all
++ sort of games with numbers you like, but it won't change the facts.

Djee, George, you also wrote:
> It depends if I were quoting a price or giving an approximation.  In
> the case above, the exact number of years was wholly irrelevant.  It
> was the fact that all she has ever seen is the first piece of code I
> wrote.

Where "she" is referring to me. Now, I happen to know that you started
that code in 1992 - simply because you started in that particular mud
after I did, and I started in the last days of 1991.

1998 - 1992 == 6. Half a decade is a much closer approximation than
a decade.



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Fri, 25 Sep 1998 22:17:12 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <IDUO1.2175$Ge.6965866@ptah.visi.com>

In comp.lang.java.programmer Abigail <abigail@fnx.com> wrote:
: Djee, George, you also wrote:
:> It depends if I were quoting a price or giving an approximation.  In
:> the case above, the exact number of years was wholly irrelevant.  It
:> was the fact that all she has ever seen is the first piece of code I
:> wrote.

: Where "she" is referring to me. Now, I happen to know that you started
: that code in 1992 - simply because you started in that particular mud
: after I did, and I started in the last days of 1991.

: 1998 - 1992 == 6. Half a decade is a much closer approximation than
: a decade.

January 1991 to September 1998. Three months shy of 8 years. 

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: 25 Sep 98 14:58:19 GMT
From: rpete@ascda3.harvard.edu (Pete Ratzlaff)
Subject: Re: Code explanation
Message-Id: <360baf8b.0@cfanews.harvard.edu>

cs - Elton Kong (cselton@hkp.hk) wrote:
> Hi!

> I'm a perl newbie and in the process of learing it. Could anyone
> tell me what the below code means?

> # string = &rand_pass(length)
> sub rand_pass {
>   my @chars = ('A'..'Z', 'a'..'z', '0'..'9');
>   join "" => @chars[map rand @chars => 1 .. shift]
> }

@chars ends up being an array containing the values of all alpha-numeric
characters. 'rand @chars' returns an arbitrary number between 0 and
'scalar @chars'. So if we grab an arbitrary index (rand @chars) of the
@chars array and get the corresponding character ($chars[rand @chars]) as
many times as we need to fill the password (the length argument in the
function call - the value returned by shift() in the function itself)
and pack them all together using join(), then we'll have a random
password of the required length containing only alpha-numeric characters.

Here is a clearer implementation:

sub rand_pass {
	my $length = $_[0]; # requested password length
	my @chars = ('A'..'Z', 'a'..'z', '0'..'9');

	my @password_chars = (); # array of random characters

	foreach (1..$length) {
		my $rand_index = rand(scalar @chars);
		push @password_chars, $chars[$rand_index];
	}
	my $rand_password = join('', @password_chars);

	return $rand_password;
}

-------------
Peter Ratzlaff                    Harvard-Smithsonian Center for Astrophysics
Office B102                       60 Garden St, MS 21, Cambridge MA 02138 USA
<pratzlaff@cfa.harvard.edu>       phone: 617 496 7714


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

Date: Fri, 25 Sep 1998 15:38:03 -0700
From: Yogish Baliga <baliga@synopsys.com>
To: Eli Glanz <deg28@columbia.edu>
Subject: Re: desperate for socket help
Message-Id: <360C1B4B.3FF56615@synopsys.com>

Reading from a socket's input stream ( <SOCKET> ) is same as reading from any
other files. Reading from a file returns false only when the EOF is read. So
the writing
side for a socket must write a EOF to the socket so that the client can come
to know that
the reading should be stopped. Otherwise, it keep on reading the socket till
the end...

 and more thing, the Socket can be blocked till the input is available for
reading using
fcntl call. Check this possibility also...

-- Baliga

Eli Glanz wrote:

> here is the relevant source:
>
>         $protocol = getprotobyname('tcp');
>
>         socket(SOCKET, PF_INET, SOCK_STREAM, $protocol) || die $!;
>         $local_sok = sockaddr_in(0, gethostbyname('localhost')) || die $!;
>         bind(SOCKET, $local_sok) || die "Bind: $!";
>
>         $remote_ip_addr = gethostbyname($server);
>         $remote_sok = sockaddr_in($port, $remote_ip_addr);
>
>         connect(SOCKET, $remote_sok);
>
> the above lines work, and connects me a server specified by $server and
> $port. however if i do:
>
>         while (<SOCKET>) {print}
>
> to read the server greeting, the script gets stuck in this while loop. how
> can i make it stop once its read the text.
>
> tnx





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

Date: 25 Sep 1998 20:54:04 GMT
From: gej@spamalot.mfg.sgi.com (Gene Johannsen)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <6ugvtc$dq0$1@murrow.corp.sgi.com>

Mark Stackhouse <stackhou@execpc.com> writes:

| Could someone please clear up my misunderstanding of "tr"?
| 
| I'm trying to remove leading zeros in the first six elements of file
| lines.  The closest code I can come up with is:
| 
| for ($k=0; $k<=5; $k++)	#check the first 6 elements 
|  {
|    if ($line_element[$k] =~ /^0/) #match leading zeros 
|     {
|      $line_element[$k] =~ tr/1-9//cd; #remove zeros 
|     }
|  }
| 
| I want 	"000" to be "0"
| 	"001" to be "1"
| 	"002" to be "2"
| 	     etc.
| 	"010" to be "10" and so on all the way up to "71"
| 
| With the above code, I delete the "0" and "10" becomes "1" etc.
| I've searched through the FAQ's, Perlre and re-read the chapter on
| reg-exp in Learning Perl but didn't recognize what I need here.  Can
| someone help me out here?

	Just use 'int':

for ('000', '001', '002', '003', '004', '005', '010') {
    print $_, ' becomes ', int $_, "\n";
}


Produces:

000 becomes 0
001 becomes 1
002 becomes 2
003 becomes 3
004 becomes 4
005 becomes 5
010 becomes 10

gene

| 
| Thanks,
| --
| Mark Stackhouse
| 
| ***********************************************************************
| 
| homepage: http://www.execpc.com/~stackhou
| 
| "The best things in life aren't things."
| --Art Buchwald
| 
| ***********************************************************************


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

Date: Fri, 25 Sep 1998 21:33:49 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <6uh27t$ral$1@nnrp1.dejanews.com>

In article <MPG.10756be7549791319897bc@nntp.hpl.hp.com>,
  lr@hpl.hp.com (Larry Rosler) wrote:
> <snip>
>
> The latter benchmarks faster, but doesn't use a regex (as your subject
> demands :-).
>
> #!/usr/local/bin/perl -w
> use Benchmark;
>
> my @a = qw( 000 001 002 003 004 005 006 007 );
> print "@a\n";
>
> timethese (1 << (shift || 0), {
>     Regex   => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+// } },
>     Save_0  => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+(?=\d)// },
>     Sum     => sub { my @b = @a; foreach (@b[0 .. 5]) { $_ += 0 } },
> } );
>
> Benchmark: timing 16384 iterations of Regex, Save_0, Sum...
>      Regex: 15 secs ( 3.45 usr  0.02 sys =  3.47 cpu)
>     Save_0: 21 secs ( 3.61 usr  0.02 sys =  3.63 cpu)
>        Sum: 15 secs ( 3.09 usr  0.02 sys =  3.11 cpu)
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com

Hmmm.  I had to modify your sample a little bit to get it to work
(missing right bracket and I wanted to see just how wasteful it is
for map to generate an ignored return array),
but on a Sparc 20 running Solaris 2.5.1
with perl 5.004_01, the results are quite different.


rgsun5{ltl}ksh: cat x2.pl
#!/usr/lib/lprgs/perl -w
 use Benchmark;

  my @a = qw( 000 001 002 003 004 005 006 007 );
  print "@a\n";

  timethese (16384 , {
      Regex   => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+// } },
      Save_0  => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+(?=\d)// } },
      Sum     => sub { my @b = @a; foreach (@b[0 .. 5]) { $_ += 0 } },
      Map     => sub { my @b = @a; map s/^0+(?=\d)//, @b[0 .. 5]; },
  } );
rgsun5{ltl}ksh: ./x2.pl
000 001 002 003 004 005 006 007
Benchmark: timing 16384 iterations of Map, Regex, Save_0, Sum...
       Map:  4 secs ( 4.05 usr  0.00 sys =  4.05 cpu)
     Regex:  4 secs ( 3.42 usr  0.00 sys =  3.42 cpu)
    Save_0:  4 secs ( 3.70 usr  0.00 sys =  3.70 cpu)
       Sum:  4 secs ( 4.35 usr  0.00 sys =  4.35 cpu)

But why is the "Sum" case taking so long?


--
// Lee.Lindley@Bigfoot.com
// Be nice.  It isn't that hard to do and it
// makes people happy.

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


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

Date: Fri, 25 Sep 1998 15:15:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <MPG.1075b5e34eb260d79897c4@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6uh27t$ral$1@nnrp1.dejanews.com> on Fri, 25 Sep 1998 21:33:49 
GMT, Lee.Lindley@bigfoot.com <Lee.Lindley@bigfoot.com> says...
 ...
> but on a Sparc 20 running Solaris 2.5.1
> with perl 5.004_01, the results are quite different.
 ...
> Benchmark: timing 16384 iterations of Map, Regex, Save_0, Sum...
>        Map:  4 secs ( 4.05 usr  0.00 sys =  4.05 cpu)
>      Regex:  4 secs ( 3.42 usr  0.00 sys =  3.42 cpu)
>     Save_0:  4 secs ( 3.70 usr  0.00 sys =  3.70 cpu)
>        Sum:  4 secs ( 4.35 usr  0.00 sys =  4.35 cpu)
> 
> But why is the "Sum" case taking so long?

timethese (16384 , {
  Control => sub { my @b = @a; },
  Int     => sub { my @b = @a; foreach (@b[0 .. 5]) { $_ = int $_ } },
  Map     => sub { my @b = @a; map s/^0+(?=\d)//, @b[0 .. 5]; },
  Regex   => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+// } },
  Save_0  => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+(?=\d)// } },
  Sum     => sub { my @b = @a; foreach (@b[0 .. 5]) { $_ += 0 } },
} );

On HP 9000/819 running HP-UX 10.20 with perl 5.004_03:

Benchmark: timing 16384 iterations of Control, Int, Map, Regex, Save_0, 
Sum...
   Control:  3 secs ( 1.25 usr  0.01 sys =  1.26 cpu)
       Int:  9 secs ( 3.61 usr  0.04 sys =  3.65 cpu)
       Map: 11 secs ( 4.72 usr  0.08 sys =  4.80 cpu)
     Regex:  9 secs ( 3.90 usr  0.06 sys =  3.96 cpu)
    Save_0:  7 secs ( 3.91 usr  0.05 sys =  3.96 cpu)
       Sum:  4 secs ( 3.02 usr  0.00 sys =  3.02 cpu)

On HP Vectra XU 6/200 running Windows NT 4.0 SP3 with perl 5.005_02:

Benchmark: timing 16384 iterations of Control, Int, Map, Regex, Save_0, 
Sum...
   Control:  2 wallclock secs ( 1.20 usr +  0.00 sys =  1.20 CPU)
       Int:  4 wallclock secs ( 4.11 usr +  0.00 sys =  4.11 CPU)
       Map:  5 wallclock secs ( 4.39 usr +  0.00 sys =  4.39 CPU)
     Regex:  3 wallclock secs ( 3.45 usr +  0.00 sys =  3.45 CPU)
    Save_0:  4 wallclock secs ( 3.84 usr +  0.00 sys =  3.84 CPU)
       Sum:  4 wallclock secs ( 3.76 usr +  0.00 sys =  3.76 CPU)

Conclusions:

'Map' is indeed slowest, as I asserted.  Of all the solutions that give 
the right answer ('Regex' doesn't), Sum is fastest on these two 
architectures.  But these are not enormous differences.

Why 'Sum' is so slow on your Sun box, God (or Bill Joy) Only Knows.  Now 
you know what I overlooked: to always add YMMV to Benchmark results. :-)

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


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

Date: 25 Sep 1998 22:43:15 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <6uh6a3$9gs$1@client3.news.psi.net>

Craig Berry (cberry@cinenet.net) wrote on MDCCCLI September MCMXCIII in
<URL:news:6uggsd$avu$2@marina.cinenet.net>:
++ 
++ In 5.005 you can express that even *more* tersely, believe it or not. :)
++ 
++ The idea is to use an array slice to pull out the @line_element members
++ you want to transform, iterating over them with $_ aliased to each array
++ member in turn.  The substitution then replaces any initial string of one
++ or more '0' characters with nothing.  Make sense?


No, because that doesn't gain anything.

    map {s/^0+//} @line_element [0 .. 5];


Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: Fri, 25 Sep 1998 21:53:48 GMT
From: harry@my-dejanews.com
Subject: How do i unpack a 64-bit long?
Message-Id: <6uh3dc$se1$1@nnrp1.dejanews.com>

How can I read and unpack a 64-bit long integer from a file?

 Thanks,
 Harry

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


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

Date: Fri, 25 Sep 1998 18:04:22 -0400
From: "Seth Sternberg" <seth@claritech.com>
Subject: How to redirect and kill an asynchronous process?
Message-Id: <6uh401$t3d$1@firma.jprc.com>

I do QA for a company that does analysis on large text databases. In order
to run some of our tests, I need to start up the database server
asynchronously and have a handle to it so that I can kill it when the test
completes. I currently do this with Win32::Process on NT and fork on Unix.
The probelm is, I now need to capture the output from the server. The
cleanest way to do this (without altering the server code) is to redirect
the output. Adding ">>filename" to the process causes the server to die, and
using a system or other direct call doesn't give me the handle to kill it.
(NT process IDs are far from normal.)

Any ideas on how to redirect the output of an asynchronous process to a file
and maintain a handle to kill it later? I've tried various subshells, and my
current thought is to redefine STDOUT. But I don't know how to do that
either.

Any help is greatly appreciated.

Thanks!
-Seth




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

Date: 25 Sep 98 15:22:29 GMT
From: rpete@ascda3.harvard.edu (Pete Ratzlaff)
Subject: Re: newbie array question
Message-Id: <360bb535.0@cfanews.harvard.edu>

James Dean (jgdean@columbus.rr.com) wrote:
> I have a very simple app built in Javascript that assigns three
> different variables to each element of an array. Example :

>      group[0].reg == "east"
>      group[0].name == "Martha"
>      group[0].email == "Martha@m.com"

>     group[1].reg == "west"
>    etc.,

I would implement this as an array of hashes:

my @group;
push @group, { reg => 'east', name => 'Martha', email => 'Martha@m.com' };
push @group, { reg => 'west', name => 'Martha', email => 'Martha@m.com' };

Then you dereference like:

print "reg[0] = $group[0]{reg}\n";
print "name[0] = $group[0]{name}\n";

etc.

Of course, the optimum solution depends on how you ultimately want to
extract the data from your data structure, but this is one solution.
later, but this is one

-------------
Peter Ratzlaff                    Harvard-Smithsonian Center for Astrophysics
Office B102                       60 Garden St, MS 21, Cambridge MA 02138 USA
<pratzlaff@cfa.harvard.edu>       phone: 617 496 7714


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

Date: Fri, 25 Sep 1998 16:13:30 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Perl and ODBC?
Message-Id: <Pine.A41.3.96.980925161257.142080A-100000@tigger.cc.uic.edu>

http://www.roth.net/odbc/



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

Date: Fri, 25 Sep 1998 16:15:32 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Perl and ODBC?
Message-Id: <Pine.A41.3.96.980925161359.142080B-100000@tigger.cc.uic.edu>

One additional thing -- the ODBC module comes with ActivePerl, 
(www.activestate.com) so there is no need to install/compile it 
separately.

-Seth Johnson

On Fri, 25 Sep 1998, David J. Topper wrote:

> Hello there,
> 
> I'm trying to convince my boss to use perl instead of cold fusion.  The
> snags are:
> 
> a)  he needs to use NT (ok ... there is perl for NT)
> b)  he wants to talk with an MS Access database (preferrably with ODBC)
> 
> I've heard there are other mechanisms for talking with MS Access, but he
> seems to really want ODBC stuff.  I don't even know what the hell the
> difference is. We used to use sybperl back at Time Inc., then later some
> special functions that opened connections with a Sybase database.
> 
> Any input would be appreciated.
> 
> Thanks,
> 
> Dave Topper
> --
> Technical Director, Virginia Center for Computer Music
> Programmer / Analyst, Dean's Office (School of A&S)
> http://www.panix.com/~topper
> (804) 924-6887
> 
> 



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

Date: 25 Sep 1998 22:47:39 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Perl as http User Agent?!
Message-Id: <906763657.627369@elaine.drink.com>

In article <8csohgpasg.fsf@gadget.cscaper.com>,
Randal Schwartz  <merlyn@stonehenge.com> wrote:
>>>>>> "Soren" == Soren Andersen <sorentin@m6.sprynet.com> writes:
>Soren> about who my mystery visitor was? A search bot or spider implemented in 
>Soren> Perl?
>
>Boy, you're gonna be really confused when my LWP-based bot connects
>up to your site and calls itself "Mozilla/19.2 (SonyPlaystation)".
>

"Mozilla/4.05 (ZX-81)" is my usual useragent.


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

Date: Fri, 25 Sep 1998 20:49:08 GMT
From: "Ian Wilkinson" <ian@no-spam.4site.co.uk>
Subject: Perl version compatability
Message-Id: <01bde8c5$5b251480$0100007f@quibhrgm>

Hi there.

My access to Perl (v5.001) is provided by one of the largest ISPs in Europe,
with sites hosted under Apache 0.8.14.  (They provide newer environments and I
have an option to transfer from the old server should I wish). 

When asked recently about upgrading to a more recent version of Perl, a
representative replied - "It has not been upgraded to avoid possible problems
with existing scripts".  I'm not in a position to argue about the merits of
that statement (having only completed the first two chapters of the 'camel'
book :), so I would like to ask this group whether or not (and what) problems
would, in fact, exist.  Isn't Perl 5 backwardly compatible?

Also, is it possible for two or more flavours (sic) of Perl 5 to co-exist on
the same server - with scripts just 'requiring' the desired version?  Or could
this be handled in the shebang line?  Or am I being completely niaive?

TIA.
-- 
Ian Wilkinson
s/no-spam.//i
The Tie Post: http://www.scotlanddirect.co.uk/tiepost/
(Shameless plug!)


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

Date: Fri, 25 Sep 1998 16:06:59 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <360C05F3.E6064C99@mail.uca.edu>

Come on now isn't there *ANYBODY* out there other than me who
learned^H^H^H^H^H^H^H is learning Perl using the Gecko (LPW32S)? Tom,
you can't even disparage this, your name's on it (yes, I know why, we've
been through that).

Cameron
camerond@mail.uca.edu

John Porter <jdporter@min.net> wrote:
> 
>From what resource(s) did you learn Perl?

[Camels, Llamas, other stuff on- and off-line listed]


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

Date: Fri, 25 Sep 1998 17:03:47 -0500
From: Ernest Mueller <ernestm@towery.com>
Subject: Problem Joining Lines In Delimited Data
Message-Id: <360C1343.5B9FF4F0@towery.com>

OK, here's the problem I'm faced with.  Data exported from a database
(Access in this case) into a tab-delimited format is fairly easy to work
with, except for text fields that have hard returns in them - splitting
one data record across multiple lines in a data file.  Example (using
colons instead of tabs for clarity):

one word:two words:three words
but now:a
broken
ass:word field

I need to join the broken lines into full lines, replacing the newlines
with spaces or something.  I wrote a script that works for short lines:

#!/usr/bin/perl
open (FILE, "dataraw.txt");
open (NEWFILE, "> datacooked.txt");
while (<FILE>) {
chomp;
$line .= $_;
if ($line =~ /^.*?\t.*?\t.*?$/) {
print NEWFILE "$line\n";
$line = ""; }
else {
$line .= " "; }                             
}
close FILE;
close NEWFILE;
exit 0;

But if I use this for the real file (extending the regexp to 28 fields
instead of the sample 3 above) oooo, it pegs my CPU and works
super-duper slow, I assume it's just such a hairy regexp that it's a
problem.  Also, it doesn't work if it's the last field that's split up. 
Not to mention it's not too robust in the face of a bad record.

Anyone have a better suggestion on how to do this?  I briefly thought
about using split but wasn't able to figure out how to do that in a
multiline format...

Thanks,
Ernest
-- 
Ernest C. Mueller                               ernestm@towery.com
Vice President for Technical Development        Phone: (901) 251-7000
Towery Publishing                               http://www.towery.com


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

Date: Fri, 25 Sep 1998 16:20:29 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
Subject: Re: Redirection Question
Message-Id: <360C091D.8E77FA91@cowboys.anet-dfw.com>



Zenin wrote:

> Tom Turton <tturton@cowboys.anet-dfw.com> wrote:
>         >snip<
> :        Where is use strict?

Ya got me.  Put it in, but no change.

> : open STDERR, ">/home/tturton/PERL/error.log";
>
>         Bad.
>
> :     open (STDERR, ">-");      # ports it to STDOUT, instead of default STDERR
>
>         Bad.
>
> : open STDERR, ">&STDOUT";
>
>         Bad.
>
>         What happends if you add "or die $!" to the end of all those open()s?

Aside from being a little ugly, what is bad about the above?
Added  " or die " messages to all the opens, but it chugged along just as before
(no die messages, print statements ended up in same files as before).

---Tom



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

Date: Fri, 25 Sep 1998 22:52:22 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Redirection Question
Message-Id: <360f1cb5.2264392@news.ping.be>

It could be me, but it looks to me taht both cases work properly, but
not as you described.

  open(STDERR,">-");

>#  normal.log:
>2) This should go to screen if interactive; abnormal if cronjob.              X

Wrong. STDOUT is to normal.log. Since you redirected STDERR (default
"abnormal.log") to STDOUT ("normal.log"), I think it does as it should.
Your text is wrong: it assumes redirecting STDOUT to STDERR.


  open STDERR, ">&STDOUT";

>4) This should go out to screen if interactive; normal.log if cronjob
>OK

Idem. Both redirect STDERR to normal.log, i.e. STDOUT. That's what I
would expect.

Perhaps you ment to redirect STDOUT to STDERR?

	Bart.


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

Date: Fri, 25 Sep 1998 22:06:01 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Rotating an array.
Message-Id: <360C1558.81D70C5@shaw.wave.ca>

[posted & mailed]

Casper Kvan Clausen wrote:
> 
> I guess this problem doesn't really lend itself to a twisted solution.
> Shame.

Well, now you've made it a challenge.  I'm sure there are many solutions
more twisted than this, but it should qualify.

@words = qw(one two three four five);
$rot = 2;
{
local
$"=$;;($_="@words")=~s/(([^$"]*$"){$rot})(.*)$/$3$"$1/;@b=split/$"/;
}
print "@b\n";


-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sat, 26 Sep 1998 01:14:03 +0100
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Shell for testing Perl/CGI scripts!?
Message-Id: <6uh0lf$qio$1@bison.rosnet.ru>

Hi

Does anyone know any software for testing being written Perl/CGI scripts
(shell or any more and where to download)?

--
Yours sincerely,


Michael Yevdokimov (flanker@sonnet.ru)
----------------------------------------------------------------------
The Basic Network
(Developers Support Site)
http://www.basicnet.sonnet.ru
quests@basicnet.sonnet.ru
----------------------------------------------------------------------




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

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

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