[12686] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 95 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 9 17:07:18 1999

Date: Fri, 9 Jul 1999 14:05:10 -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           Fri, 9 Jul 1999     Volume: 9 Number: 95

Today's topics:
    Re: $variable bigcheese@my-deja.com
    Re: 'making' perl <dtse@earthweb.com>
    Re: <STDIN> with password? (Greg Bacon)
        Assigning args with regular expressions <eoddonetha@akefilesqua.com>
    Re: Connecting to an Oracle DB with PERL 5 <mwatkins@nospam.lexmark.com>
    Re: Could anybody help me with this?? (Larry Rosler)
    Re: creating stock charts <burton@lucent.com>
    Re: Deleting everything after a pattern? (Bart Lateur)
    Re: Deleting everything after a pattern? (I R A Aggie)
    Re: DNS question then sorting by values (Kevin Johnson)
    Re: DNS question then sorting by values (Larry Rosler)
    Re: FAQ 5.7: How can I use a filehandle indirectly? (Sameer Siruguri)
    Re: FAQ 5.7: How can I use a filehandle indirectly? <tchrist@mox.perl.com>
    Re: long long in perl? <garethr@cre.canon.co.uk>
    Re: long long in perl? (Ilya Zakharevich)
        match multiple lines infogateinc@usa.net
    Re: Newbie: Upgrade from 5.004_04 to 5.005_03 <dtse@earthweb.com>
    Re: Pattern match counting (Larry Rosler)
    Re: Pattern match counting (Greg Bacon)
    Re: Pattern Matching Question (Greg Bacon)
        Perl & mySQL - Please Help! <nick@auger.net>
    Re: Perl - problem with 'open' (Philip 'Yes, that's my address' Newton)
    Re: Random Numbers <uri@sysarch.com>
    Re: Random Numbers (Larry Rosler)
    Re: Script will not work <jcreed@cyclone.jprc.com>
    Re: Script will not work <uri@sysarch.com>
    Re: Self-referencing hash? Ick? (Ilya Zakharevich)
        Sending Attachments with email simchadov@my-deja.com
    Re: Sending Attachments with email <swiftkid@bigfoot.com>
    Re: Sending Attachments with email <garyg@gator.net>
        Variable <technology@workmail.com>
        Writing to file descriptor <jjchen@leland.stanford.edu>
    Re: Writing to file descriptor (Greg Bacon)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 09 Jul 1999 19:43:47 GMT
From: bigcheese@my-deja.com
Subject: Re: $variable
Message-Id: <7m5jdg$j5b$1@nnrp1.deja.com>

In article <37852CE6.E4678B23@workmail.com>,
  Raj <technology@workmail.com> wrote:
> Hi,
> If i click on a hyperlink on my CGI/Perl page, a flag value should be
> written to flatfile.
>
> I used a Hidden form field whose value i'd set in JavaScript function.
> then I set this modified form field value to a $variable
> and tried to write that $variable to a file.
>
> The problem is the $variable is not getting updated after returned
from
> JavaScript fn. ? any help please.... TIA,

Hmm... is your form being submitted? If you are just changing the hidden
field value and letting people click on a hyperlink, it won't submit the
form data to your script.

You would need to put a "document.forms[0].submit()" somewhere to submit
your form.
The problem with that is it will try to point the browser at your
script, so you might need to change your script from using a form for
input to being accessed when someone clicks on a hyperlink.

You could change the hyperlinks to something like
"script.pl?goto=thispage.html&formvalue=variable" (assuming the script
is script.pl)

Then your script could take in the variable and print something like
"Location: $FORM{'goto'}\n\n" or something to redirect the browser to
the page you want to go to (you'll need a query string parser).

Then, to get the value from JavaScript, it depends if the flag variable
is changed after the page loads. If it is you would have to do some
fancy stuff to change the variable in the link, otherwise you could just
print the links in JavaScript,
<SCRIPT LANGUAGE="JavaScript">
var variable="whatever";
document.write("<A
HREF='script.pl?goto=thispage.html&formvalue="+variable+">link</A>");
</SCRIPT>
(copy, paste and edit as you need it)

Hope that helps!
- Dan


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 09 Jul 1999 20:09:07 GMT
From: "angelonearth" <dtse@earthweb.com>
Subject: Re: 'making' perl
Message-Id: <DFsh3.25228$Xr4.214227@c01read02-admin.service.talkway.com>

On Thu, 08 Jul 1999 12:49:54 -0400 henning hummert
<hummerth@egr.msu.edu> wrote:
> hi,
> i am trying to install a new version of perl on a linux box. problem is:
> i can run the Configure script without any trouble, make dep is running
> well too, but when i try to run make i get an error saying : error in
> makefile pointing to the last line of it.
> 
> has anybody an idea how to solve this problem?
> 
Not sure if this fully answers yoru current dilemma, but there are a
bunch of hands-on Perl tutorials at
http://www.opensourceit.com/subjects/perl.html
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).



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

Date: 9 Jul 1999 19:25:03 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: <STDIN> with password?
Message-Id: <7m5iaf$ctl$3@info2.uah.edu>

In article <7m5ghb$hrh$1@nnrp1.deja.com>,
	chenlg@my-deja.com writes:
: I have a simple perl program (runing on the SUN)
: which ask the user for password by using the
: <STDIN>, my question is how to turn off the echo
: on the system so that when the user typing the
: password on the command line, the password would
: not be shown explicitly.

    % man perlfaq8
    [...]
    How do I ask the user for a password?
    [...]

Greg
-- 
File names are infinite in length where infinity is set to 255 characters.
    -- Peter Collinson


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

Date: Fri, 9 Jul 1999 15:49:18 -0500
From: "theoddone33" <eoddonetha@akefilesqua.com>
Subject: Assigning args with regular expressions
Message-Id: <7m5n38$td8$1@news.inc.net>

I know that this code works:
----
 if( ($a,$b) = /(.*) blah blah blah (.*)) { }
----
but this code doesn't
-----
sub mainrec {
  my($arg1,$arg2) = @_;
  #rest of function
}
#more code here
if( mainrec($a,$b) = /(.*) yada yada (.*)/) { }
-----

Am I missing something or is this assignment not possible?  Can I amend
something to do it this way, or will I be forced to call the function from
within the if statement?

--
theoddone33
"These are not my pants" - Reese Roper
AGQ2 Configs Page:
http://www.quakefiles.com/agq2configs/
Also visit:
http://www.fiveironfrenzy.com
To email, descramble the pig latin





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

Date: 9 Jul 1999 11:38:07 -0500
From: "Mark Watkins" <mwatkins@nospam.lexmark.com>
Subject: Re: Connecting to an Oracle DB with PERL 5
Message-Id: <01beca20$fd26df60$f57db89d@mwatkins.boulder.lexmark.com>

David, 

I do a very similar thing in Perl on a Sybase database.  Basically, Sybase
has a
program called isql which allows you to use the following command line
options:
isql -Uusername -Ppassword -iInputfile > tmp.file

This allows me to do a simple system(command) in perl and redirect the
output to 
a file.  I then open the file in perl and parse the data into variables in
perl.

I assume sqlplus for Oracle has similar ways of doing this.  It may not be
the most
ellegant but it was WAY easier then using the ODBC library in perl.

I use this programming to get to the database via an intranet and generate
queries
through Netscape or IE5.  It works very well for the number of users I
have.

Mark Watkins
email::mwatkins@lexmark.com


David Riggs <driggs@dsw.net> wrote in article
<3784DD48.4D999E1E@dsw.net>...
> Hi -
> 
> Basically what I'd like to be able to do is jump into an oracle database
> within a perl script and, within the perl script, run select statements
> to extract the data out of the database and put it in variables in the
> script.  For instance, at the command line on the UNIX system, I type:
> 
> sqlplus
> <then I enter my user name and pw>
> select colname1, colname2, colname3 from table1;
> 
> From here it outputs a few rows of data from the 3 columns in table1.
> This should be clear to anyone familiar with SQL.  I'm just not sure how
> to get those rows of data into variables in my perl program.  I imagine
> that I need some library that contains functions to connect to the
> database and functions to run select statements and store the results.
> 
> I really appreciate any help!  Thanks!
> 
>     - Dave
> 
> 


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

Date: Fri, 9 Jul 1999 13:20:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Could anybody help me with this??
Message-Id: <MPG.11eff9833bf10b6d989c88@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7m588t$g33$1@enterprise.cistron.net> on Fri, 9 Jul 1999 
18:34:21 +0200, E.G. van Haandel <newsgrouppost@smartmedia.nl> says...
> I'm using a postcard script from and I like the script very much!!!

I'm glad for you.  To me, it looks like the typical garbage (and Perl 4, 
at that).

> I'm using it on the following site (Dutch):
> 
> http://www.party2000.nl/kaart/
> 
> But there is a little thing that I would like to change... The part where
> the current time and date are captured, uses the time from the server. But
> the server I'm using is in the US and I'm living in the Netherlands. So the
> time isn't correct. Is it possible to adjust the time difference???

I would suggest replacing the call to localtime by a call to gmtime, and 
adding one or two hours to get your Central European Time depending on 
your local Summer Time conventions, which are different from those in 
the US.

> I would like to change the names of the month to the Dutch language. I
> allready edited the '@month' variable in the 'gets the current date'
> section, but that didn't do the trick...

It didn't do the trick because the garbage program sets up the variables 
and doesn't use them.  See below!

> Could anybody do a little programming for me???

No one here will program for you for free.  But we will help you do the 
programming yourself.

> The complete script is on:
> 
> http://www.aestheticsurgerycenter.com/scripts/postcard/card.txt
> 
> >>>>>>>>>>>>> This section of your script did I edit <<<<<<<<<<<<<<<<<

Heh, heh.  That is after the piece of the program that says this:

########################################################
########################################################
# Don't Edit Passed Here                               #
########################################################
########################################################

I think they meant Past, but why should they know English any better 
than they know Perl?
 
> ############################################
> #Gets the Current Date
> ############################################
>    ($sec,$min,$hr,$day,$month,$year,$day_of_week,$day_of_year,$some) =
> localtime(time);
>    @months =
> ("januari","februari","maart","april","mei","juni","juli","augustus","septem
> ber","oktober","november","december");
> 
>    $minute = $min + 10;
>    $hour = $hr + 10;
>    $second = $sec + 10;

That part is simply hilarious.  Words escape me.

>    $DATE = `date +"%d-%B-%Y.dat"`;
>    chop ($DATE);
> 
>    $SHORTDATE = `date +"%d %B, %Y om %T %Z""`;
>    chop ($SHORTDATE);

So after all the setup, they call the local system 'date' command.  
Sheesh!

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

     my $tz_offset = +1 * 60 * 60;
     my ($sec, $min, $hr, $day, $month, $year) =
         gmtime(time + $tz_offset);
     my @months = qw(januari februari maart april mei juni
             juli augustus september oktober november december);
 
     printf '%d %s, %d %.2d:%.2d:%.2d' =>
         $day, $months[$month], 1900 + $year, $hr, $min, $sec;
__END__

9 juli, 1999 21:19:23

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


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

Date: Fri, 09 Jul 1999 15:19:18 -0500
From: Burton Kent <burton@lucent.com>
Subject: Re: creating stock charts
Message-Id: <37865946.C6DCEECD@lucent.com>

See www.cpan.org

B

baga@gmx.net wrote:
> 
> Hello,
> 
> I want to write a program that takes my saved data and create charts
> out of it. Does someone know if there are already perl programs/moduls
> available which I can use to start? I want to use that for stocks.
> 
> Thanks a lot!
> 
>   Hans
> baga@gmx.net


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

Date: Fri, 09 Jul 1999 19:09:06 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Deleting everything after a pattern?
Message-Id: <378a488b.1602107@news.skynet.be>

I R A Aggie wrote:

>
>These aren't the same, are they? If my ESP::PerlParse module is installed
>in my head correctly, the first is 'ax...(1000 x's)...xb', and the second
>is 'abx...(1000 x's)'.
>
>Is that not the reason you get such a radical flip in "efficeincies"?

Of course it is.

All I wanted to show is that if you want to test an "a" followed by a
"b" (at whatever distance), efficiency of the greedy versus the
non-greedy regex may STRONGLY depend on the data. There is no general
rule that one is clearly better than the other.

	Bart.


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

Date: 9 Jul 1999 20:05:30 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Deleting everything after a pattern?
Message-Id: <slrn7oclkk.lar.fl_aggie@thepentagon.com>

On Fri, 09 Jul 1999 19:09:06 GMT, Bart Lateur <bart.lateur@skynet.be>, in
<378a488b.1602107@news.skynet.be> wrote:

+ All I wanted to show is that if you want to test an "a" followed by a
+ "b" (at whatever distance), efficiency of the greedy versus the
+ non-greedy regex may STRONGLY depend on the data. There is no general
+ rule that one is clearly better than the other.

D0H! Thanks, that helps.

James


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

Date: 9 Jul 1999 19:45:24 GMT
From: kevin@prism.ig.utexas.edu (Kevin Johnson)
Subject: Re: DNS question then sorting by values
Message-Id: <7m5jgk$2vd$1@geraldo.cc.utexas.edu>

Kevin Johnson (kevin@prism.ig.utexas.edu) wrote:
: Hi. 

: I'm writing a log file analyser in Perl (obviously) and have 
: run into a couple of questions. Hopefully, they are easy :-)

: Second, I have the following bit of code to create the aforementioned
: statistics:

: sub addTarget {
:         local($target)=@_;
:         if (defined($target)) {
: targetExists: {
:                 foreach $name (@targetNames) {
:                         if ($target eq $name) {
:                                 $targetSums{$target}++;
:                                 last targetExists;
:                                 }
:                         }
:                 $targetNames[++$#targetNames] = $target;
:                 $targetSums{$target}=1;
:         }
:         }
: }

Okay. I took a second look at this and received some helpful
comments from lr@hp and found that this pos can be reduced to

sub addTarget {
        local($target)=@_;
        $targetSums{$target}++ if defined $target;
}

*ducks to avoid pies from the audience*

This appears to work fine now. 

: What I want to do after this is sort by the values in %targetSums
: and print the value with the corresponding key. This is opposite
: of what you usually do I know. The immediate way I thought of doing
: this was by copying the assoc array to another with keys and values
: swapped. I did this by 

: while (($key,$value) = each %targetSums) {
:         $sumByTarget{$value}=$key;
: }
: foreach $key (sort keys(%sumByTarget)) {
:         print $key,"\t",$value,"\n";
:         }

This turns out to be in perlfaq4...

http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_sort_a_hash_optionally

So I have changed this code to do this:

foreach $key (sort { $targetSums{$b} <=> $targetSums{$a} } keys(%targetSums))
        print $targetSums{$key},"\t",$key,"\n";
        }

This almost works correctly. It is printing the "\t",$key,"\n" part 
in correct sorted order. (My earlier code attempt fails in part to
the fact the values are not unique. duh.) This does not print the
$targetSums{$key} values though. I don't understand why not. Any
help would be much appreciated. Thanks again.

Kevin

--
Kevin Johnson				University of Texas
Systems Analyst				Institute for Geophysics


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

Date: Fri, 9 Jul 1999 13:25:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: DNS question then sorting by values
Message-Id: <MPG.11effaaaeaaf3591989c89@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7m57kf$en2$1@geraldo.cc.utexas.edu> on 9 Jul 1999 16:22:39 
GMT, Kevin Johnson <kevin@prism.ig.utexas.edu> says...
 ...

You should use separate posts for separate questions.

+ Second, I have the following bit of code to create the aforementioned
+ statistics:
+ 
+ sub addTarget {
+         local($target)=@_;
+         if (defined($target)) {
+ targetExists: {
+                 foreach $name (@targetNames) {
+                         if ($target eq $name) {
+                                 $targetSums{$target}++;
+                                 last targetExists;
+                                 }
+                         }
+                 $targetNames[++$#targetNames] = $target;
+                 $targetSums{$target}=1;
+         }
+         }
+ }

Ouch.  That is so convoluted and inefficient.  The hash autoincrement 
does everything without needing that list of existing keys.  Here is 
what you seem to be doing:

  sub addTarget {
          my $target = shift;
          $targetSums{$target}++ if defined $target;
  }
 
+ What I want to do after this is sort by the values in %targetSums
+ and print the value with the corresponding key. This is opposite
+ of what you usually do I know. The immediate way I thought of doing
+ this was by copying the assoc array to another with keys and values
+ swapped. I did this by 
+ 
+ while (($key,$value) = each %targetSums) {
+         $sumByTarget{$value}=$key;
+ }
+ foreach $key (sort keys(%sumByTarget)) {
+         print $key,"\t",$value,"\n";
+         }
+ 
+ Is there a better way to do what I'm trying to do?

perlfaq4: "How do I sort a hash (optionally by value instead of key)?"

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


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

Date: 9 Jul 1999 20:14:03 GMT
From: siruguri@cs.rice.edu (Sameer Siruguri)
Subject: Re: FAQ 5.7: How can I use a filehandle indirectly?
Message-Id: <slrn7ocm0a.b26.siruguri@swing.cs.rice.edu>

On 9 Jul 1999 04:57:07 -0700, Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
>    In the examples above, we assigned the filehandle to a scalar
>    variable before using it. That is because only simple scalar
>    variables, not expressions or subscripts into hashes or arrays, can
>    be used with built-ins like `print', `printf', or the diamond
>    operator. These are illegal and won't even compile:

Why are these illegal? I couldn't find anything in the Perl documentation that
says so. Why is Perl unable to parse the array variable, $foo[N], and return
the filehandle stored in it? i.e. why does:

$a[0]=FileHandle->new();
open($a[0], "<file");
$x=<$a[0]>;
print $x;

not print the first line in "file"? Note that it compiles though. It doesn't
print anything however. I use Perl 5.005_01 for sun4-solaris.

Thanks. Sam.

-- 
Sameer Siruguri				  Graduate student, CS, Rice University
siruguri@cs.rice.edu	       713 630 9243           www.cs.rice.edu/~siruguri


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

Date: 9 Jul 1999 14:25:45 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 5.7: How can I use a filehandle indirectly?
Message-Id: <37865ac9@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    siruguri@cs.rice.edu (Sameer Siruguri) writes:
:Why are these illegal? I couldn't find anything in the Perl documentation that
:says so. Why is Perl unable to parse the array variable, $foo[N], and return
:the filehandle stored in it? i.e. why does:
:
:$a[0]=FileHandle->new();
:open($a[0], "<file");
:$x=<$a[0]>;
:print $x;
:
:not print the first line in "file"? Note that it compiles though. 

Because those are the rules.  This is part of why I hate the
mad drive to the I/O modules.  They provide nothing we didn't have
before, and don't fix the problems we did have.

    print $a[0] "stuff\n"

is illegal because it is not a simple scalar variables, and 

    $line = <$a[0]>

is not illegal, but doesn't do what you want, because since it is
not a simple scalar variable, it's a fileglob. 

--tom
-- 
    "Don't wear rollerskates to a tug-of-war." --Larry Wall


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

Date: Fri, 9 Jul 1999 19:33:14 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: ahornbeck@yahoo.com
Subject: Re: long long in perl?
Message-Id: <si4sjdsjnp.fsf@cre.canon.co.uk>

ahornbeck@yahoo.com wrote:
> Is there an 8-byte integer type in perl?  Or a package that supports
> it?

Perl doesn't have "integer types".  The perlop manpage says:

     By default Perl assumes that it must do most of its
     arithmetic in floating point.

On systems where "floating point" means "IEEE 754 double precision", you
can accurately represent all integers from -2**52-1 to 2**52-1 inclusive
(that is, -9_007_199_254_740_991 to 9_007_199_254_740_991).

Unfortunately, Perl's number-to-string conversion doesn't work correctly
for these large integers, so you need to do an explicit

    sprintf("%.16g", $bigint)

to get a string form.  (For `print'ing you can set $#, but be aware that
the perlvar manpage deprecates it.)

If you really need a bigger range of integers, then get Mark Biggar's
Math::BigInt module from CPAN.

If you're just manipulating 64-bit chunks of data, and don't need
mathematical operations, then a vector of bits or bytes may be
appropriate.  See the documentation for `vec' and `pack' in the perlfunc
manpage.

-- 
Gareth Rees


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

Date: 9 Jul 1999 20:52:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: long long in perl?
Message-Id: <7m5ndo$a31$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Gareth Rees 
<garethr@cre.canon.co.uk>],
who wrote in article <si4sjdsjnp.fsf@cre.canon.co.uk>:
> ahornbeck@yahoo.com wrote:
> > Is there an 8-byte integer type in perl?  Or a package that supports
> > it?
> 
> Perl doesn't have "integer types".

Wrong.

Hope th is helps,
Ilya


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

Date: Fri, 09 Jul 1999 20:07:23 GMT
From: infogateinc@usa.net
Subject: match multiple lines
Message-Id: <7m5kph$jnk$1@nnrp1.deja.com>

Hi
I try to extract a range of lines from a file containing patterns on
different lines. How can I get the lines matching the pattern at the
very first time? In the following example, I only want:
abc
edf
efg

But If I run the program, I get the second match, too.

The program is like:
#! /usr/local/bin/perl
use IO::File;

open (DUMP, "text")|| die ("open lynx failed: $text_data\n");

while (<DUMP>) {
      print if (m#abc#i ... m#efg#i );

    }
close(DUMP);

And the file is like:
abc
edf
efg
00000
abc
assf
efg
1111112

Thanks

JC


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 09 Jul 1999 20:10:44 GMT
From: "angelonearth" <dtse@earthweb.com>
Subject: Re: Newbie: Upgrade from 5.004_04 to 5.005_03
Message-Id: <8Hsh3.25230$Xr4.214413@c01read02-admin.service.talkway.com>

On Thu, 8 Jul 1999 12:26:51 +0100 Jamie Kincaid
<jamie@thale.nott.ac.uk> wrote:
> 
> Hi,
> 
> In the INSTALL notes for 5.005 it says about recompiling extensions:
> 
> If you have dynamically loaded extensions
> that you built under perl 5.003 or 5.004, you can continue to use them
> with 5.004, but you will need to rebuild and reinstall those extensions
> to use them 5.005.
> 
> Can I therefore just tar up and move all the stuff into the new site_perl
> directory ie /usr/local/lib/perl5/site_perl/5.005
> 
> I don't understand what is meant by dynamically loaded extensions.
> 
> Jamie
> 
> -------------------------------------------------------------------------------
> Jamie Kincaid
> Nottingham Arabidopsis Stock Centre
> School of Biological Sciences
> University Park
> The University of Nottingham
> Nottingham
> NG7 2RD
> 
> Office: 0115 951 3091
> 
> NASC website:	nasc.nott.ac.uk
> 
> 
Have you checked out the new perl tutorials on 
http://www.opensourceit.com/subjects/perl.html?  They address a lot of
issues with Perl 5.005, free at Open Source IT (
http://www.opensourceit.com)  from “The Perl Journal.”
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).



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

Date: Fri, 9 Jul 1999 12:12:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pattern match counting
Message-Id: <MPG.11efe95f25784d45989c86@nntp.hpl.hp.com>

In article <7m57uu$ark$1@info2.uah.edu> on 9 Jul 1999 16:28:14 GMT, Greg 
Bacon <gbacon@itsc.uah.edu> says...
> In article <MPG.11eec56e17ca4873989c77@nntp.hpl.hp.com>,
> 	lr@hpl.hp.com (Larry Rosler) writes:
> : In article <7m34v0$qna$2@info2.uah.edu> on 8 Jul 1999 21:24:48 GMT,
 ...
> Hey, Chip, make split() in scalar context return the number of fields
> in Topaz. :-)

Oh, and while you're at it, Chip, make grep and map in void context not 
create and discard output lists. :-)
 
> : But
> : 
> : my $count = 1;
> : ++$count while /:/g;
> : 
> : *must* be clearer.
> 
> I fail to see how that follows logically.  Prove your statement or
> retract it.

It is clearer because it doesn't rely on arcana such as '$scalar = () = 
LIST;', let alone 'split ..., -1'.

Just imagine explaining either your locution or mine to students using 
'Learning Perl'.  The /g modifier is in the book for multiple matches; 
all they have to learn is that it can be looped on.

> : And we know it's faster.
> 
> We know it's faster for the particular dataset that you tested.  Let
> go of your performance anxiety.
> 
> : So why bother with '() =' at all?
> 
> Some people like it.  TMTOWTDI.  Get off our collective case.

You are perfectly free to show obscure, slow WTDI to consenting adults 
in private.  But expect some flak in public.

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


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

Date: 9 Jul 1999 19:42:02 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Pattern match counting
Message-Id: <7m5jaa$ctl$5@info2.uah.edu>

In article <MPG.11efe95f25784d45989c86@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:
: In article <7m57uu$ark$1@info2.uah.edu> on 9 Jul 1999 16:28:14 GMT,
:     Greg Bacon <gbacon@itsc.uah.edu> says...
: > I fail to see how that follows logically.  Prove your statement or
: > retract it.
: 
: It is clearer because it doesn't rely on arcana such as '$scalar = () = 
: LIST;',

It's arcane when you give stupid names to the variables.  Please take
me through the thought process of someone with an IQ above that of
the average fern who would find code like

    $count = () = $str =~ /pattern/g;

difficult to understand.

: let alone 'split ..., -1'.

Try reading my post next time.  Here, I'll help you.

> You're ignoring
> 
>     If LIMIT is unspecified or zero, trailing null fields are stripped
>     (which potential users of C<pop()> would do well to remember).
> 
> to focus in on questionable if not buggy behavior of split() to make
> broad generalizations about the C<$scalar = () = ...> syntax.

I'll help you again.

> You're ignoring
>
>     If LIMIT is unspecified or zero, trailing null fields are stripped
>     (which potential users of C<pop()> would do well to remember).
>
> to focus in on questionable if not buggy behavior of split() to make
> broad generalizations about the C<$scalar = () = ...> syntax.

Once more to be sure.

> You're ignoring
>
>     If LIMIT is unspecified or zero, trailing null fields are stripped
>     (which potential users of C<pop()> would do well to remember).
>
> to focus in on questionable if not buggy behavior of split() to make
> broad generalizations about the C<$scalar = () = ...> syntax.

Did you get that?

: Just imagine explaining either your locution or mine to students using 
: 'Learning Perl'.  The /g modifier is in the book for multiple matches; 
: all they have to learn is that it can be looped on.

Now hear this!  Larry Rosler has declared that all Perl code must be
accessible to those who have just completed the LLama.

: You are perfectly free to show obscure,

You keep using adjectives like `obscure' and `arcane' without
justification.  Justify || retract;

: slow WTDI to consenting adults 
: in private.  But expect some flak in public.

Your faith and reliance on benchmarks is laughable and pitiable.
Sticks and stones may break my bones, but benchmarks never hurt me.

Greg
-- 
Join the good guys. Don't fuck with the web.
    -- Abigail in <slrn7o89jc.ued.abigail@alexandra.delanet.com>


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

Date: 9 Jul 1999 19:23:40 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Pattern Matching Question
Message-Id: <7m5i7s$ctl$2@info2.uah.edu>

In article <Pine.OSF.3.96.990709131054.7268B-100000@krypton.mankato.msus.edu>,
	Mark Mykkanen <mykkam@krypton.mankato.msus.edu> writes:
: How do I match everything up to the last '/' in the line?

    $line =~ m<^(.*)/>;

Greg
-- 
If you don't have anything good to say... say it often!
    -- Ed the Sock


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

Date: Fri, 09 Jul 1999 16:17:38 -0400
From: nick <nick@auger.net>
Subject: Perl & mySQL - Please Help!
Message-Id: <378658E2.527096BC@auger.net>

Can anyone give me some examples on adding a value to a mySQL database,
then getting that value?  Please help!  Any examples would be great!

Nick
nick@auger.net



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

Date: Fri, 09 Jul 1999 19:15:48 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Perl - problem with 'open'
Message-Id: <37858d97.40076403@news.nikoma.de>

On Thu, 8 Jul 1999 20:10:33 GMT, John.Borwick@sas.com (John Borwick)
wrote:

>	print "HA HA HA IT DIDN'T WORK" if ($? ne 0);

ITYM $? != 0. (Been programming too many shell scripts recently? test,
aka [, uses e.g. -lt for numbers and < for strings; with Perl, it's
the other way around.)

Or maybe even print "..." if $?;

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: 09 Jul 1999 15:07:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Random Numbers
Message-Id: <x73dyxsktx.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <378638DB.1C12D9C2@mail.cor.epa.gov> on Fri, 09 Jul 1999 
  LR> 11:00:59 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
  LR> ...
  >> Math::TrulyRandom may not be random anyway, merely chaotic.
  >> I haven't seen an adequate analysis of it.

  LR> Hello!  There are no random-number algorithms, by definition.  Special 
  LR> hardware (such as a radioactive-decay detector) is required.  See Knuth, 
  LR> Vol. 2, Ch. 3, 'Random Numbers' and especially the rubric:

  LR> "Anyone who considers arithmetical methods of producing random digits 
  LR> is, of course, in a state of sin.  John von Neumann (1951)"

how would you classify /dev/rand which is based on data in the kernel? i
don't know exactly how it creates the numbers, but it is not predictive
as it is influenced by random input like kernel interrupts.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 9 Jul 1999 12:52:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random Numbers
Message-Id: <MPG.11eff2c45562a45a989c87@nntp.hpl.hp.com>

In article <x73dyxsktx.fsf@home.sysarch.com> on 09 Jul 1999 15:07:54 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
> 
>   LR> In article <378638DB.1C12D9C2@mail.cor.epa.gov> on Fri, 09 Jul 1999 
>   LR> 11:00:59 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
>   LR> ...
>   >> Math::TrulyRandom may not be random anyway, merely chaotic.
>   >> I haven't seen an adequate analysis of it.
> 
>   LR> Hello!  There are no random-number algorithms, by definition.  Special 
>   LR> hardware (such as a radioactive-decay detector) is required.  See Knuth, 
>   LR> Vol. 2, Ch. 3, 'Random Numbers' and especially the rubric:
> 
>   LR> "Anyone who considers arithmetical methods of producing random digits 
>   LR> is, of course, in a state of sin.  John von Neumann (1951)"
> 
> how would you classify /dev/rand which is based on data in the kernel? i
> don't know exactly how it creates the numbers, but it is not predictive
> as it is influenced by random input like kernel interrupts.

I would classify it thus:

1.  Something I had forgotten about.

2.  Something system-specific.

3.  Sort of like special hardware ('/dev/...' :-).

4.  Not used by MATH::TrulyRandom, which uses setitimer(2) 11 times to 
interrupt a tight counting loop after each 16665 usec.  No wonder it is 
frightfully slow.

5.  Probably slow itself, if it relies on randomly occurring kernel 
interrupts. 

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


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

Date: 09 Jul 1999 14:58:16 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: Script will not work
Message-Id: <a1yagphcqf.fsf@cyclone.jprc.com>

Paul <pgrech@uoguelph.ca> writes:

> Can anyone tell me why this program will not work.  Is supposed to use
> modules and these are supposedly called from the
> perl5 library.  On my machine it says it does not recognize the command
> use.
> '
Are you sure your perl is actually perl5?
Try 
/usr/bin/perl -V

---Jason


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

Date: 09 Jul 1999 15:14:19 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Script will not work
Message-Id: <x7zp15r5ys.fsf@home.sysarch.com>

>>>>> "P" == Paul  <pgrech@uoguelph.ca> writes:

  P> Can anyone tell me why this program will not work.  Is supposed to use
  P> modules and these are supposedly called from the
  P> perl5 library.  On my machine it says it does not recognize the command
  P> use.
  P> '

update your perl. you are running the flea bitten camel carcass perl4.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 9 Jul 1999 19:24:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Self-referencing hash? Ick?
Message-Id: <7m5i94$7mh$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7btdlst16.fsf@home.sysarch.com>:
> not exactly an ulcer, more like amnesia. it just won't garbage collect a
> circular structure as each element has a ref count >= 1 even when the
> main code never refers to any element anymore. the rule is, if you are
> smart enough to create circular structures, you are smart enough to
> manually break the links before allowing perl to garbage collect
> it. there is a recipe about this in the cookbook too.

It does not help that this "umbrella" algorithm disables garbage
collections of things under the "umbrella" until "umbrella" is gone -
even if things are not in circular lists.

Newer Perls have weak refs, so one can make references from the
"umbrella" weak, and make the above algorithm more useful.

Ilya


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

Date: Fri, 09 Jul 1999 19:39:10 GMT
From: simchadov@my-deja.com
Subject: Sending Attachments with email
Message-Id: <7m5j4s$j1n$1@nnrp1.deja.com>

I want to write a Perl script that allows me to build and send an email
message with an attachment. Are there modules that do this sort of thing
or has anyone seen examples of ways to do this?

If you could cc me with an email- that would be great.

Thanks, Scott


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sat, 10 Jul 1999 00:53:07 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Sending Attachments with email
Message-Id: <7m6n8d$iaa1@news.cyber.net.pk>

<simchadov@my-deja.com> wrote in message news:7m5j4s$j1n$1@nnrp1.deja.com...
> I want to write a Perl script that allows me to build and send an email
> message with an attachment. Are there modules that do this sort of thing
> or has anyone seen examples of ways to do this?

check out MIME::Lite





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

Date: Fri, 09 Jul 1999 16:40:26 -0400
From: "Gary M. Greenberg" <garyg@gator.net>
Subject: Re: Sending Attachments with email
Message-Id: <37865E3A.CB98048@gator.net>

simchadov@my-deja.com wrote:
> 
> I want to write a Perl script that allows me to build and send an email
> message with an attachment. Are there modules that do this sort of thing
> or has anyone seen examples of ways to do this?
> 
Here's a perfect reason to subscribe to The Perl Journal; the newest
article contains code to do this with explanations.

> If you could cc me with an email- that would be great.
[posted && mailed]


-- 
Gary


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

Date: Fri, 09 Jul 1999 13:44:16 -0700
From: Raj <technology@workmail.com>
Subject: Variable
Message-Id: <37865F20.793C7264@workmail.com>

Hi,
If i click on a hyperlink on my CGI/Perl page, a flag value should be
written to flatfile.

I used a Hidden form field whose value i'd set in JavaScript function.
then I set this modified form field value to a $variable
and tried to write that $variable to a file.

The problem is the $variable is not getting updated after returned from
JavaScript fn. ? any help please.... TIA,

Raj





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

Date: 09 Jul 1999 12:06:04 -0700
From: Janet <jjchen@leland.stanford.edu>
Subject: Writing to file descriptor
Message-Id: <m37lo9skwz.fsf@dhilbert.Stanford.EDU>

Hi,

I know that you can open a file descriptor for input by using the "<=&"
prefix.  Is there a way to open it for output?  I encountered some code
that looks like

open(FH, "| $some_program") )
$ENV{'LOGPOPAUTH_FILENO'} = fileno(FH);

Then another program gets the file handle from the environment variable
using 
my $fileno = $ENV{'LOGPOPAUTH_FILENO'};

Now, is there a way to open the file for output?

TIA,
Janet
	


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

Date: 9 Jul 1999 19:30:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Writing to file descriptor
Message-Id: <7m5il2$ctl$4@info2.uah.edu>

In article <m37lo9skwz.fsf@dhilbert.stanford.edu>,
	Janet <jjchen@leland.stanford.edu> writes:
: I know that you can open a file descriptor for input by using the "<=&"
                                                                     ^^^
You mean <&=

: prefix.  Is there a way to open it for output?

If you don't mind using IO::Handle objects, you could

    $io = new IO::Handle;
    if ( $io->fdopen($ENV{LOGPOPAUTH_FILENO}, "w") ) {
        $io->print("Spoon!\n");
    }

Greg
-- 
Did you know that 42% of statistics are made up on the spot?


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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