[22765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4986 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 15 06:06:14 2003

Date: Thu, 15 May 2003 03:05:12 -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           Thu, 15 May 2003     Volume: 10 Number: 4986

Today's topics:
    Re: "ndbm store" error on Solaris  (Joe Smith)
    Re: <html> and reg. expressions <REMOVEsdnCAPS@comcast.net>
    Re: Can't locate sub.pl <pierre@couderc.cc>
    Re: CGI.pm  buffer overflow security?? (Joe Smith)
    Re: delete an element from an array? <wksmith@optonline.net>
        FAQ request, was Re: tools to make perl scripts an EXE  <REMOVEsdnCAPS@comcast.net>
    Re: GD Graphics ... something strange <simon.andrews@bbsrc.ac.uk>
    Re: gotta be a better way <spam@thecouch.homeip.net>
        Help: How do I Make Perl Remember? and Make a Subroutin (entropy123)
    Re: Help: How do I Make Perl Remember? and Make a Subro (Sam Holden)
    Re: is there a built in mathematical type "dot product" <REMOVEsdnCAPS@comcast.net>
    Re: measuring web resource loading time <pigmalion@bigfoot.com>
    Re: mysql DBI ? relaced by NULL (Mike Solomon)
    Re: mysql DBI ? relaced by NULL (Mike Solomon)
    Re: Negating phrases <bart.lateur@pandora.be>
    Re: Newbie question <jurgenex@hotmail.com>
    Re: Newbie question <wksmith@optonline.net>
        ordering an excel spreadsheet with perl (Rory)
    Re: Perlmonks Down? (Smitz)
    Re: putting renamed array elements into a table (Jay Tilton)
    Re: putting renamed array elements into a table <REMOVEsdnCAPS@comcast.net>
    Re: System not returning exit code that I expected <jurgenex@hotmail.com>
        To parse two text files and get a combined output... (Jim Carter)
    Re: To parse two text files and get a combined output.. <nothing@home.yet>
    Re: tools to make perl scripts an EXE executables?? <kalinabears@hdc.com.au>
    Re: tools to make perl scripts an EXE executables?? <jvandervloet@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 15 May 2003 04:58:10 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: "ndbm store" error on Solaris 
Message-Id: <C7Fwa.16663$io.343810@iad-read.news.verio.net>

In article <l2Lva.6$tA3.151@news.oracle.com>,
Shehzaad Nakhoda <dontspamme@dontspam.com> wrote:
>I've run into a problem with periodic errors with the following error
>message that cause my perl program to exit abnormally:
>
>ndbm store returned -1, errno 27, key
>"1052131392769|217.225.201.81|56:1052131056:156
>948" at <perl file path> line <perl file name>, <INFILE> line 204057.
>
>I'm using a dbm backed hash, which does grow to about 345MB file size (as
>seen by the 'du' command). Running repeatedly causes the exact same error
>with the same key. I should also mention that the hash file size shown by
>'ls' is quite humungous: 936187058176 (over 900 Gb). Disk space is plentiful
>and close to half full only.

>#define EFBIG   27      /* File too large                       */

The ndbm database interface has arbitrary limits that cause errors
of EFBIG or ENOSPC when too many keys hash to the same bucket.

solaris% man ndbm

     The sum of the sizes of a key/content pair must  not  exceed
     the internal block size (currently 1024 bytes). Moreover all
     key/content pairs that hash together must fit  on  a  single
     block.  dbm_store() will return an error in the event that a
     disk block fills with inseparable data.

solaris% perldoc AnyDBM_File

     DBM Comparisons

     Here's a partial table of features the different packages
     offer:

                              odbm    ndbm    sdbm    gdbm    bsd-db
                              ----    ----    ----    ----    ------
      Linkage comes w/ perl   yes     yes     yes     yes     yes
      Src comes w/ perl       no      no      yes     no      no
      Comes w/ many unix os   yes     yes     no      no      no
      Builds ok on !unix      ?       ?       yes     yes     ?
      Code Size               ?       ?       small   big     big
      Database Size           ?       ?       small   big?    ok
      Speed                   ?       ?       slow    ok      fast
      FTPable                 no      no      yes     yes     yes
      Easy to build          N/A     N/A      yes     yes     ok
      Size limits             1k      4k      1k      none    none
      Byte-order independent  no      no      no      no      yes
      Licensing restrictions  ?       ?       no      yes     no

I recommend switching to gdbm or Berkeley_DB instead of trying
to program around the limitations of ndbm.

	-Joe

P.S. I hit this problem years ago after dumping an ndbm database to
a flat file and attempting re-import it.  The failure depended on which
order keys were added first.
-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Wed, 14 May 2003 19:29:38 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: <html> and reg. expressions
Message-Id: <Xns937BD07D5337Csdn.comcast@216.166.71.239>

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

"berndt.sommer" <berndt.sommer@gmx.de> wrote in
news:b9tntr$lev$05$1@news.t-online.com: 

>  Hi there,
> 
> 1. with  s/<[^>]+>// I can replace all html tags to nothing. I
tried
> to do this with
> /<[.]+>/ but this does not work. I do not have any idea why.

A period has no special meaning within a character class (those
square brackets).  That second expression searches for a left angle
bracket, one or more periods, and a right angle bracket.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+wt90Y96i4h5M0egRAiljAKDdCFZn90tq5J4MyIfVjHSxplBg+gCdEj0S
2Tnl1X788NqrA/SjMV2SFEs=
=4mk/
-----END PGP SIGNATURE-----


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

Date: Thu, 15 May 2003 10:33:34 +0200
From: Pierre Couderc <pierre@couderc.cc>
Subject: Re: Can't locate sub.pl
Message-Id: <b9vjcv$2mav$1@biggoron.nerim.net>

Brian McCauley wrote:
> Pierre Couderc <pierre@couderc.cc> writes:
>>I have 2 files in /var/www/perl/ directory :
>>
>>sub.pl
>>------
>>
>>subroutine mysub{
>>...
>>}
>>
>>main.pl
>>-------
>>
>>require './sub.pl';
>>...
>>mysub();
> 
> 
> Do not do this!
> 

I am sorry that I am too new to perl to understand what is so "horrible"...

Pierre Couderc



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

Date: Thu, 15 May 2003 04:45:41 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: CGI.pm  buffer overflow security??
Message-Id: <VXEwa.16660$io.343810@iad-read.news.verio.net>

In article <6a8ba9f8.0305121359.4080d37f@posting.google.com>,
Kenjis Kaan <tivolinewbie@canada.com> wrote:
>As a user of the CGI.pm module, I am wondering if the module has any
>builtin check against incoming parameter data?

Yes.

>Does CGI.pm validate the data taht is coming up through 'SomeTextArea'
>or not? or do we have to do the validation ourselves?

If by validation you mean the significance of input data, that is
something you do yourself.  If you're talking about defending against
megabytes of garbage being thrown at the server, perl can absorb
up to the limit of swap space, and CGI.pm can be told to reject
giant posts.

>I am of course thinking of attacks such as buffer overflows.  TIA

Buffer overflows occur when fixed-length buffers are used for
strings and the programmer forgets to check the length.
Perl does not have that particular problem since strings are not
fixed and bounds checking is inherent.
	-Joe

-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Wed, 14 May 2003 22:55:47 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: delete an element from an array?
Message-Id: <TPzwa.5011$6L5.2166324@news4.srv.hcvlny.cv.net>


"Helgi Briem" <helgi@decode.is> wrote in message
news:3ec269b4.2942199739@news.cis.dfn.de...
> On Wed, 14 May 2003 10:46:26 -0500, Bing Du Test
> <bing-du@tamu.edu> wrote:
>
> >I know how to delete an element from a hash.  What about deleting
from
> >an array if I just know the element value rather than its position in
> >the array?  I've looked 'delete' up in perlfunc, but still have no
clear
> >clue.
>
> perldoc -f grep
>
> #!perl
> use warnings;
> use strict;
> my @array = qw/one two three/;
> my $exclude = 'two';
> @array = grep !/^$exclude$/,@array;
> print join "\n",@array;
> __END__
> --

It is not clear to me what the OP means by 'delete from an array'.  Your
interpretation is probably correct, but he may want to undefined the
value and leave the indices unchanged.






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

Date: Wed, 14 May 2003 19:24:52 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: FAQ request, was Re: tools to make perl scripts an EXE executables??
Message-Id: <Xns937BCFAEB8295sdn.comcast@216.166.71.239>

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

tivolinewbie@canada.com (Kenjis Kaan) wrote in
news:6a8ba9f8.0305140813.3c823ec@posting.google.com:

To the FAQ maintainers: 

    Can we please make this into a FAQ?  It gets asked about every
week.  There is a similar question in the current FAQ ("How can I
compile my Perl program into byte code or C?"), but nearly everyone
who asks this question phrases it in terms of a desired EXE file. 
Perhaps "EXE" could become part of the question.

Just a humble request, thanks.
- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+wt5RY96i4h5M0egRAsGVAJ4gqth/ohXc6HHGfqYbEsS3WCaU6wCeM+wW
Pao/gYD6dfOOTDkjgHPMoSU=
=Hjyp
-----END PGP SIGNATURE-----


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

Date: Thu, 15 May 2003 10:00:02 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: GD Graphics ... something strange
Message-Id: <3EC35712.4010806@bbsrc.ac.uk>



Steve wrote:
> I use GD to draw some graphs.  The background to the graph can be a variety
> of colors.  When the background is yellow, the graph line is black ...
> otherwise the line is white.
> 
> When I use Netscape the colors come out fine.  When I use Explorer however,
> the graph line is always black.  I did some trail and error and got it to
> work OK regardless of the browser, but I was wondering ... why would a cgi
> script care what browser I'm using?

It wouldn't. Your script is interacting with your webserver, not with 
the browser.

The test to try is to have your script generate the image offline and 
save it to a file.  If you then open that image in different browsers 
and it looks different then that's a bug in one of the browsers (nothing 
you can do about that!).  If it looks the same then its a bug in the 
logic of your script, or in the HTML which called it.  Trace back the 
variables you are using to determine colours and see what happens to 
them through the script.

The only thing which will affect the output of your script are the 
parameters which are initally passed to it.  The browser which sent them 
is irrelevant (unless you are specifically checking for it).

Hope this helps

Simon.



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

Date: Wed, 14 May 2003 18:24:28 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: gotta be a better way
Message-Id: <zmzwa.55737$bV6.529173@weber.videotron.net>

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

rab wrote:
> I've had to resort to this:

Sounds like you need to learn about hashes :)

> 
> 
> --------------------------------------
> foreach (<AFILE>) {
> 
>     push(@aim,$_) if /aim/;
>     push(@ait3p,$_) if /ait3p/;
>     push(@bsc3270,$_) if /bsc3270/;
>     push(@cpmhs,$_) if /cpmhs/;
>     push(@dkap,$_) if /dkap/;
>     push(@ebim,$_) if /ebim/;
>     push(@frm,$_) if /frm/;
>     push(@msm,$_) if /msm/;

Instead you could do:

	foreach $item (qw(aim ait3p bsc3270 cpmhs dkap ebim frm msm)) {
		push (@{ $results{$item} }, $_) if /$item/;
	}

>     
> 
> } #end foreach my item
> 
> if(@aim){foreach (@aim){print "$_\n";}}
> if(@ait3p){foreach (@ait3p){print "$_\n";}}
> if(@bsc3270){foreach (@bsc3270){print "$_\n";}}
> if(@cpmhs){foreach (@cpmhs){print "$_\n";}}
> if(@dkap){foreach (@dkap){print "$_\n";}}
> if(@ebim){foreach (@ebim){print "$_\n";}}
> if(@frm){foreach (@frm){print "$_\n";}}
> if(@msm){foreach (@msm){print "$_\n";}}

Same concept as my above use of the %results hash:

foreach (keys %results) {
	foreach (@{ $results{$_} }) {
		print "$_\n";
	}
}

Or if you're just interested in viewing the data structure:

use Data::Dumper;
print Dumper \%results;

> -------------------------------------------------
> 
> but I shouldn't do it that manually.... I  **should** be able to
> complete all these repetitive tasks by using this (an array of the
> arrays) somehow:
> 
> my @types=(\@aim,\@ait3p,\@bsc3270,\@cpmhs,\@dkap,\@ebim,\@frm,\@msm);

Arrays aren't really suitable for what you're trying to do since you 
have a word "identifier" that corresponds to a value (or values). Hashes 
are made for this sort of thing.

> 
> but how!?  I keep getting ARRAY(OxNNNNNNNN) references.
> 
> some help?

Read perldoc perldata


Best of luck.


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+wsIfeS99pGMif6wRAqspAKDObzLaaJKoQGFffUEoi6ktGl6AagCgk6yc
QizNsl2aWLd8nxlEzfbu0fM=
=NpgI
-----END PGP SIGNATURE-----



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

Date: 14 May 2003 20:33:18 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help: How do I Make Perl Remember? and Make a Subroutine
Message-Id: <90cdce37.0305141933.708723d6@posting.google.com>

Hey all,

Slowly I struggle to build code in Perl. Thanks for all the past help
and I really need help with this nut.

This piece of code (~10+ hrs of my life) reads through %supah
(essentially %HoH) and connects nodes (atoms). My main goal is to turn
this into a ring detection subroutine. There are equations which tell
me if I have a ring or not, this guy needs to go in and find the atoms
which comprise the ring.

I mainly wrote this to get used to the HOH and use the logical
operators...

Trouble is, I've never written a subroutine - really, I've read
'Learning Perl' and the subroutine section mystified me.. and I think
I've performed the task so far in the most innefficient possible
manner...

So,

1. How do I make perl 'remember' each step? I really have trouble
manipulating the HOH and for some reason have trouble making arrays on
the fly whereas I can make a HOH on the fly with no
problem....Eventually I need to compare the connectivity of various
bonds arising from the atom. Another HOH? or something else..?

2. Any advice on how to turn this guy into an efficient subroutine?
The main thing the sub delivers, I guess is the next connection and
keeps going until a) it runs out of atoms or b) the two paths collide
and a ring is found... I'd rather have an unlimited number of possible
connections and create logical statements to check for overlap than
foreach $onehundred....

Thanks again for all the help!

entropy

$supha{}{} is basically a hash of hashes $supha{atom1}{atom2}=bond
order, so if exists perl knows there is a connection...

 foreach $first ( keys %supha ) { #takes key and assigns it a $first
     for $second ( keys %{ $supha{$first} } ) { #iterates through each
value
	 for $third ( keys %{ $supha{$second} } ) { #goes to atom connected
to second
	     if ($third ne $first) { #checks to see if third atom is first
	     for $four ( keys %{ $supha{$third} } ) {
		 if ($four ne $second) {
		     print "\nf: $first, s:$second t:$third, fo: $four\n";
		 }
		 }
	 }
	 }
     }
 }


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

Date: 15 May 2003 08:11:07 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help: How do I Make Perl Remember? and Make a Subroutine
Message-Id: <slrnbc6isr.ets.sholden@flexal.cs.usyd.edu.au>

On 14 May 2003 20:33:18 -0700, entropy123 <email_entropy123@yahoo.com> wrote:
> Hey all,
> 
> Slowly I struggle to build code in Perl. Thanks for all the past help
> and I really need help with this nut.
> 
> This piece of code (~10+ hrs of my life) reads through %supah
> (essentially %HoH) and connects nodes (atoms). My main goal is to turn
> this into a ring detection subroutine. There are equations which tell
> me if I have a ring or not, this guy needs to go in and find the atoms
> which comprise the ring.

If a ring is just a cycle in the graph then the usual algorithm is
simply depth first search. A back edge indicates a cycle.

DFS is a pretty simple recursive algorithm, which can be found in 
any worth while algorithms book (it's simple enough to be in
inrtoduction books, and is a step in *lots* of other
graph algorithms and hence will be in more advanced books too).


> I mainly wrote this to get used to the HOH and use the logical
> operators...
> 
> Trouble is, I've never written a subroutine - really, I've read
> 'Learning Perl' and the subroutine section mystified me.. and I think
> I've performed the task so far in the most innefficient possible
> manner...
> 
> So,
> 
> 1. How do I make perl 'remember' each step? I really have trouble
> manipulating the HOH and for some reason have trouble making arrays on
> the fly whereas I can make a HOH on the fly with no
> problem....Eventually I need to compare the connectivity of various
> bonds arising from the atom. Another HOH? or something else..?

Usually you mark the existing HoH (adding extra key->value pairs)
or you use a HoH with keys being node (or edge) identifiers and
key-value pairs inside that (or a single hash if you only have one
value). Below I'll use two hashes instead of a HoH.

> 
> 2. Any advice on how to turn this guy into an efficient subroutine?
> The main thing the sub delivers, I guess is the next connection and
> keeps going until a) it runs out of atoms or b) the two paths collide
> and a ring is found... I'd rather have an unlimited number of possible
> connections and create logical statements to check for overlap than
> foreach $onehundred....

Use a standard DFS algorithm. 

> 
> Thanks again for all the help!
> 
> entropy
> 
> $supha{}{} is basically a hash of hashes $supha{atom1}{atom2}=bond
> order, so if exists perl knows there is a connection...
> 
>  foreach $first ( keys %supha ) { #takes key and assigns it a $first
>      for $second ( keys %{ $supha{$first} } ) { #iterates through each
> value
> 	 for $third ( keys %{ $supha{$second} } ) { #goes to atom connected
> to second
> 	     if ($third ne $first) { #checks to see if third atom is first
> 	     for $four ( keys %{ $supha{$third} } ) {
> 		 if ($four ne $second) {
> 		     print "\nf: $first, s:$second t:$third, fo: $four\n";
> 		 }
> 		 }
> 	 }
> 	 }
>      }
>  }

From that I assume that the 'edges' are directed. In that atom1 is bonded to
atom2 so you have $supha{atom1}{atom2} eq bond, but $supha{atom2}{atom1} won't
exist. If so then DFS is pretty simple. Something like (not tested, and
not optimised for readability - I'm tired and about to go home...) :

sub dfs {
        my $graph = shift;
        my $result;
        foreach $source (keys %$graph) {
                $result = dfs_visit($graph, $source, undef, {}, {}) || $result
                        unless defined $colour{$source};
        }
        return $result;
}

sub dfs_visit {
        my ($graph, $source, $parent, $colour, $parents) = @_;
        my $result;
        $colour{$source} = 'grey';
        $parents->{$source} = $parent;

        foreach $dest (keys %{$graph->{$source}}) {
                if ($colour{$dest} eq 'grey') {
                        $result = 1;
                        my $node = $source;
                        print "Cycle: $dest";
                        while ($node ne $dest) {
                                print " <- $node";
                                $node = $parents->{$node};
                        }
                        print " <- $dest\n";
                } elsif (!defined $colour{$dest}) {
                        $parents->{$dest} = $source;
                        $result = dfs_visit($graph, $dest, $source,
				$colour, $parents) || $result;
                }
        }
        $colour{$source} = 'black';
        return $result;
}


# H - O - H
my %graph1 = ( 'H1' => {'O'=>1}, 'H2' => {'O'=>1}, 'O' => {});

# H   H       H   H
# |   |       |   |
# C - C - C - C - C
#  \ /         \ /
#   C           C
#   |           |
#   H           H
my %graph2 = ( C1=>{H1=>1, C2=>1}, C2=>{H2=>1, C3=>1},
       	C3=>{H3=>1, C1=>1, C4=>1}, C4=>{C5=>1}, C5=>{H4=>1, C6=>1},
       	C6=>{H5=>1,C7=>1}, C7=>{H6=>1, C5=>1});

if (dfs(\%graph1)) {
        print "Graph 1 has a cycle\n";
}

if (dfs(\%graph2)) {
        print "Graph 2 has a cycle\n";
}


Well that's the idea at least, you will probably have to do something
according to the bond type. And of course the graph setup matters a lot,
changing the edges to go C1->C2->C3, C1->C3 and similar for the other
cycle will make the cycles disappear for example...

If the edges are undirected it will still work, it just needs tweaking to
not consider every edge a cycle.

Graph algorithms are the solution to *many* problems. There's a Graph
module on CPAN which provides a bunch of them :)


-- 
Sam Holden



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

Date: Wed, 14 May 2003 20:07:00 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: is there a built in mathematical type "dot product" function for arrays in perl? How about composition of Hashes?
Message-Id: <Xns937BD6D308349sdn.comcast@216.166.71.239>

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

mlaks2000@yahoo.com (Mitchell Laks) wrote in
news:ab3b13db.0305140431.1ed9b00e@posting.google.com:

> Dear Perl Gurus,
> is there a built in mathematical "dot product" of arrays in perl
(ie
> component wise "combination", for each array element) or do we
simply
> write the obvious loop?

Here's a general-purpose function to do what you want, so you don't
have to write the loop (read: invent the wheel) each time.

=item pairwise

 @c = pairwise {code} @a, @b;

Applies C<{code}> to each pair of elements of C<@a>, C<@b> in turn.
Returns a list of the results of that evaluation.  The pairs are
assigned to C<$a> and C<$b> before invoking the code.  Note that
C<$a>
and C<$b> are lvalue aliases into the input arrays.

Examples:

    @a = (1, 2, 3); @b = (2, 4, 6);
    @c = pairwise {$a + $b} @a, @b;   # returns (3, 6, 9)
    @d = pairwise {$a * $b} @a, @b;   # returns (2, 8, 18)

=cut

#--->     @c = pairwise {code} @a, @b;
#
# Change History:
#     06/27/2002  EJR  First version
#     02/23/2003  EJR  Several improvements; thanks to Benjamin
Goldberg
sub pairwise(&\@\@)
{
    my $op = shift;
    local (*A, *B) = @_;    # syms for caller's input arrays

    # Localise $a, $b
    my ($caller_a, $caller_b) = do
    {
        my $pkg = caller();
        no strict 'refs';
        \*{$pkg.'::a'}, \*{$pkg.'::b'};
    };

    my $limit = $#A > $#B? $#A : $#B;    # loop iteration limit

    local(*$caller_a, *$caller_b);
    map    # This map expression is also the return value.
    {
        # assign to $a, $b as refs to caller's array elements
        (*$caller_a, *$caller_b) = \($A[$_], $B[$_]);
        $op->();    # perform the transformation
    }  0 .. $limit;
}


- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+wugqY96i4h5M0egRAsHDAKDEl1xBJbgYnGi0ZZV/R7vlHFSlggCdGTKL
8RVda3wiHJDjGNZTBk+trXI=
=zLch
-----END PGP SIGNATURE-----


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

Date: Thu, 15 May 2003 09:32:18 +0100
From: pigmalion <pigmalion@bigfoot.com>
Subject: Re: measuring web resource loading time
Message-Id: <22k6cvcpufp43rikikhiaa21d7kqu8mrmu@4ax.com>

On 14 May 2003 06:17:19 -0700, jrolandumuc@yahoo.com (JR) wrote:

>perldoc -f time

Many thanks both of you.


--
www.pigmalion.info
www.pigmalion.info/perl/


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

Date: 15 May 2003 01:40:54 -0700
From: mike_solomon@lineone.net (Mike Solomon)
Subject: Re: mysql DBI ? relaced by NULL
Message-Id: <56568be5.0305150040.2c913f7a@posting.google.com>

wrm@rrscfi1.irngtx.tel.gte.com (William R. Mattil) wrote in message news:<b9tt6v$8h$1@news.gte.com>...
> In article <56568be5.0305130336.14772d10@posting.google.com>,
> Mike Solomon <mike_solomon@lineone.net> wrote:
> >I am using DBI and mysqlPP to insert into a database
> >If my data includes '?' they get replaced with NULL
> >I have tried prefixing ? with \ but that makes no difference
> >Any help to resolve this would be much appreciated
> 
> Mike,
> 
> I am not familar with mysqlPP but ....... with mysql the insert of
> a ? character works just fine. Though I did make some very minor changes
> to your code. Nothing having to do with the insert though.
> 
> mysql> select * from test_table;
> +---------+----------+--------------+
> | Mike ?  | MIKE ? T | ???-???-???? |
> +---------+----------+--------------+
> 
> Regards
> 
> Bill

I think it is probably a mysqlPP specific problem

I have tried using both the quote method and place holders but neither
method fixes the problem.

In fact using the place holder method with question marks in the text
causes an sql error as it interprets the ? as an addittional place
holders

Regards


Mike


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

Date: 15 May 2003 02:27:34 -0700
From: mike_solomon@lineone.net (Mike Solomon)
Subject: Re: mysql DBI ? relaced by NULL
Message-Id: <56568be5.0305150127.b656484@posting.google.com>

mike_solomon@lineone.net (Mike Solomon) wrote in message news:<56568be5.0305130336.14772d10@posting.google.com>...
> I am using DBI and mysqlPP to insert into a database
> 
> If my data includes '?' they get replaced with NULL
> 
> I have tried prefixing ? with \ but that makes no difference
> 
> Any help to resolve this would be much appreciated
> 

I updated mysqlPP from version 0.03 to 0.04 and this has fixed my problem

Regards

Mike Solomon


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

Date: Thu, 15 May 2003 09:49:51 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Negating phrases
Message-Id: <oko6cvs8180uro19hkqlhq0dnlg2jd9m80@4ax.com>

Allanon wrote:

>>     print unless /Name is (?:Billy|Fred)/;
>
>Yes, I guess that would work.. however, I wanted to handle the negation
>purely inside the regular expression.

Eh? That *is* inside the regular expression.

-- 
	Bart.


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

Date: Wed, 14 May 2003 22:05:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie question
Message-Id: <v4zwa.20789$Ur1.12747@nwrddc03.gnilink.net>

Paul van der Heu wrote:
> My question is how do I check on a part of a string while not
> taking case into account..

The same way you do it in any programming language: you transform the string
into a normal form and compare the normal form.

> In Arexx this:
>
> if SUBSTR(UPPER($name,4,3))= "SC8"

if ( uc(substr($name, 4, 3)) eq 'SC8') .....

Further details please see
- perldoc -f substr
- perldoc -f uc
- perldoc perlop         # for the eq

> Would change a three chracter part of $name starting at position 4 to
> uppercase and copmpare it to "SC8".

 > BTW I have Perl for dummies.. any other recommended reading?

Throw that bundle of junk away and get "Learning Perl" from O'Reilly.
For further references please see The Famous Manual: "perldoc -q book".
It has a ton of recommended books, for beginners as well as for advanced and
experts.

jue




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

Date: Wed, 14 May 2003 22:40:51 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Newbie question
Message-Id: <TBzwa.4861$6L5.2118176@news4.srv.hcvlny.cv.net>


"Paul van der Heu" <pvdh@xs4all.nl> wrote in message
news:Xns937BBEC2F6A45pvdhNL@194.134.35.159...
> I'm just starting out with perl, I have been kooking for
> something like Arexx on the Amiga and think that perl should
> do nicely.
>
> My question is how do I check on a part of a string while not
> taking case into account..
>
> In Arexx this:
>
> if SUBSTR(UPPER($name,4,3))= "SC8"
>
> Would change a three chracter part of $name starting at position 4 to
> uppercase and copmpare it to "SC8".
>
> I cannot figure the change to uppercase part .. the rest I have


If you only need a case insensitive comparison and do not need to change
the case of the substring, use a regular expression:

use strict;
use warnings;
my $str = 'aBcsC8ghij';
if ($str =~ /^...SC8/i){
    print "Substring 'SC8' was found in $str\n";
}

The substitution can be made, but it is somwhat more complex.

if ($str =~ s/^(...)(SC8)/$1\U$2/i){

Good Luck,
Bill







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

Date: 14 May 2003 19:14:46 -0700
From: rory@vivid-design.com.au (Rory)
Subject: ordering an excel spreadsheet with perl
Message-Id: <d9ba31e6.0305141814.1e269e3a@posting.google.com>

Hi

I would like to know how to order the information in an excel file
using perl, if this is possible. I am currently using
Spreadsheet::ParseExcel to retrieve the information from excel.

Any ideas/solutions appreciated.

Thanks
Rory


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

Date: 15 May 2003 00:56:59 -0700
From: el_smitz@hotmail.com (Smitz)
Subject: Re: Perlmonks Down?
Message-Id: <c1b502d4.0305142356.74b0e8bf@posting.google.com>

googleartist@yahoo.com (Artist) wrote in message news:<de3ad953.0304141447.14b034ba@posting.google.com>...
> Found
>  that perlmonks.org
>        perlmonks.com
>        perlmonk.thepen.com
>  all are down.
>  Can we do something about it??
> 
> artist..

Noo!!!!! What are we supposed to do all day? Work?!?! 
No cat related antics from katgirl, no CB spamming by
castaway [;-)], etc. How long can www.fark.com and 
www.somethingawful.com keep me entertained? Not long
enough :-(

Smitz


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

Date: Thu, 15 May 2003 03:52:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: putting renamed array elements into a table
Message-Id: <3ec3096e.153144252@news.erols.com>

lepore@brandeis.edu (bryan) wrote:

: i have an array, and using a loop i modified each element ($element_1,
: etc.) by doing ($element_1_alternate = 1+$element_1).  

Is that the real code or pseudocode?

$element_1 and $element_1_alternate are scalar variables, not array
elements.  

:   i can get the
: original elements into a table i made outside the loop, but not the
: modified ones.  the modified elements are in fact calculated
: correctly, but it looks like they only exist within the loop or
: something.
:
: i am stuck - it looks like it should work, but zeroes show up in the
: table instead.  i do get warnings about the modified elements being
: used only once, i presume from the table 

Why presume?  The warning should be telling you the program line
number where the variable is used.

: - so the loop isn't getting
: parsed or something.  i can imagine some complex things to try to fix
: this, but i figured i'd ask the group first.

Maybe it's a variable scoping issue.  Maybe you simply have a typo in
the variable name.  Maybe you're confusing a lexical variable with a
package variable.  Maybe you're doing something naughty with symbolic
references.

Group participants can imagine many things that might be the cause,
but they don't much enjoy blind guessing.

A short (less than 30 or so lines), complete program that exhibits the
problem would be tremendously helpful in guiding the investigation.



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

Date: Thu, 15 May 2003 05:04:26 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: putting renamed array elements into a table
Message-Id: <Xns937C3DCFDDB85sdn.comcast@216.166.71.239>

lepore@brandeis.edu (bryan) wrote in news:dc6e7ce5.0305141219.7528f011
@posting.google.com:

> i have an array, and using a loop i modified each element ($element_1,
> etc.) by doing ($element_1_alternate = 1+$element_1).  i can get the
> original elements into a table i made outside the loop, but not the
> modified ones.  the modified elements are in fact calculated
> correctly, but it looks like they only exist within the loop or
> something.
> 
> i am stuck - it looks like it should work, but zeroes show up in the
> table instead.  i do get warnings about the modified elements being
> used only once, i presume from the table - so the loop isn't getting
> parsed or something.  i can imagine some complex things to try to fix
> this, but i figured i'd ask the group first.


It's really really hard to say without seeing your code.

-- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;



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

Date: Wed, 14 May 2003 22:10:58 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: System not returning exit code that I expected
Message-Id: <S9zwa.20846$Ur1.1491@nwrddc03.gnilink.net>

Steve Canfield wrote:
> My understanding of the system() command is obviously insufficient.
> As I understood it, system() returns the exit code of the program it
> called.  However, when I call a program that exits with, say, 1, then
> system() returns 256.  For 2, system returns 512.  Etc.
>
> Why does system return numbers like this?  How can I find out the
> "real" exit codes?

What about Reading The Fine Manual?
"perldoc -f system", paragraph 3:

        The return value is the exit status of the program as returned
        by the "wait" call. To get the actual exit value [...]

jue




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

Date: 14 May 2003 19:28:07 -0700
From: carterave@yahoo.com (Jim Carter)
Subject: To parse two text files and get a combined output...
Message-Id: <9c2a26b6.0305141828.7e9c0aad@posting.google.com>

Hi experts,

I have a file (file1.txt) with the following text (with 21 lines):
-------------------------------------------
1. test1	C:\john\hello1.txt
                C:\john\hello2.txt

2. test2	C:\john\hello4.txt
   	C:\john\hello6.txt
             	C:\john\hello3.tx
                C:\john\hello10.txt

3. test3	C:\john\hello111.txt

4. test4	C:\john\hello123.txt

5. test5	C:\john\hello34.txt
                C:\john\hello27.txt

6. test20	C:\john\hello34.txt
                C:\john\hello4.txt
  	C:\john\hello36.txt
                C:\john\hello8.txt
    	C:\john\hello9.txt
                C:\john\hello10.txt
----------------------------------------------


Then, I have a second file (file2.txt).
---------------------------
test1		America	      
test2		Russia	
test3		Italy
test7		Germany
test10		France
test12		Canada
test20		Mexico
---------------------------


Now, I want to compare all 7 first fields (test1, test2,....test20)in
the second file with those in the first file and I want the below
output, extracted from both the files.
---------------------------------------------------------------------
1. test1	America			C:\john\hello1.txt
                			C:\john\hello2.txt

2. test2	Russia			C:\john\hello4.txt
                			C:\john\hello6.txt
                			C:\john\hello3.tx
                			C:\john\hello10.txt

3. test3	Italy			C:\john\hello111.txt

4. test7	Germany		        none

5. test10	France			none

6. test12	Canada			none

7. test20	Mexico			C:\john\hello34.txt
                 			C:\john\hello4.txt
               			 	C:\john\hello36.txt
               				 C:\john\hello8.txt
                			C:\john\hello9.txt
                			C:\john\hello10.txt
---------------------------------------------------------------------

Here, there can be more than one tab at the beginning of the lines (in
the first file), where the line doen't start with the first field
(like test 1, test2 etc).

I wrote the below script to compare and stuck somewhere in the middle:
----------------------------------
#! C:/perl/bin/perl 

chomp(@file1 = `cat C:\\file1.txt`);
chomp(@file1 = `cat C:\\file1.txt`);

foreach $line (@file2)
  {
      if(! grep /$word/, @file1)
       {
         print "@file1\n";
       }
  }
-------------------------------------------

I know this doen't work. And I am struggling to get the combined
output that I gave above.

Can someone pl. help me out?

Thanks,
Jim


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

Date: Thu, 15 May 2003 00:59:43 -0700
From: "Shane Mosely" <nothing@home.yet>
Subject: Re: To parse two text files and get a combined output...
Message-Id: <vc6i7br59q7da@corp.supernews.com>

"Jim Carter" <carterave@yahoo.com> wrote in message
news:9c2a26b6.0305141828.7e9c0aad@posting.google.com...
> Hi experts,
>
> I have a file (file1.txt) with the following text (with 21 lines):
> -------------------------------------------
> 1. test1 C:\john\hello1.txt
>                 C:\john\hello2.txt
>
> 2. test2 C:\john\hello4.txt
>    C:\john\hello6.txt
>              C:\john\hello3.tx
>                 C:\john\hello10.txt
>
> 3. test3 C:\john\hello111.txt
>
> 4. test4 C:\john\hello123.txt
>
> 5. test5 C:\john\hello34.txt
>                 C:\john\hello27.txt
>
> 6. test20 C:\john\hello34.txt
>                 C:\john\hello4.txt
>   C:\john\hello36.txt
>                 C:\john\hello8.txt
>     C:\john\hello9.txt
>                 C:\john\hello10.txt
> ----------------------------------------------
>
>
> Then, I have a second file (file2.txt).
> ---------------------------
> test1 America
> test2 Russia
> test3 Italy
> test7 Germany
> test10 France
> test12 Canada
> test20 Mexico
> ---------------------------
>
>
> Now, I want to compare all 7 first fields (test1, test2,....test20)in
> the second file with those in the first file and I want the below
> output, extracted from both the files.
> ---------------------------------------------------------------------
> 1. test1 America C:\john\hello1.txt
>                 C:\john\hello2.txt
>
> 2. test2 Russia C:\john\hello4.txt
>                 C:\john\hello6.txt
>                 C:\john\hello3.tx
>                 C:\john\hello10.txt
>
> 3. test3 Italy C:\john\hello111.txt
>
> 4. test7 Germany         none
>
> 5. test10 France none
>
> 6. test12 Canada none
>
> 7. test20 Mexico C:\john\hello34.txt
>                  C:\john\hello4.txt
>                C:\john\hello36.txt
>                C:\john\hello8.txt
>                 C:\john\hello9.txt
>                 C:\john\hello10.txt
> ---------------------------------------------------------------------
>
> Here, there can be more than one tab at the beginning of the lines (in
> the first file), where the line doen't start with the first field
> (like test 1, test2 etc).
>
> I wrote the below script to compare and stuck somewhere in the middle:
> ----------------------------------
> #! C:/perl/bin/perl
>
> chomp(@file1 = `cat C:\\file1.txt`);
> chomp(@file1 = `cat C:\\file1.txt`);
>
> foreach $line (@file2)
>   {
>       if(! grep /$word/, @file1)
>        {
>          print "@file1\n";
>        }
>   }
> -------------------------------------------
>
> I know this doen't work. And I am struggling to get the combined
> output that I gave above.
>
> Can someone pl. help me out?
>
> Thanks,
> Jim

If i understand you correctly you want a list of unique items. Just use
hashes or as some call them multidimensional arrays:
$hash{$test}=$test;




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

Date: Thu, 15 May 2003 12:24:41 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: tools to make perl scripts an EXE executables??
Message-Id: <3ec2fb78$0$13524@echo-01.iinet.net.au>


"Mike Solomon" <mike_solomon@lineone.net> wrote in message
news:3ec26d04_2@mk-nntp-2.news.uk.tiscali.com...

>
> Perl2exe handles modules as well
>

Other options include PerlApp from ActiveState (in their Perl Development
Kit) and the 'pp' utility that comes with PAR from cpan (for free).

Further to Eric's suggestion re FAQ, does PAR get mentioned in there yet ?
If not, then that should be changed, too.

Cheers,
Rob




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

Date: Thu, 15 May 2003 07:36:10 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: tools to make perl scripts an EXE executables??
Message-Id: <KrHwa.2972$1u5.283@afrodite.telenet-ops.be>

"Kenjis Kaan" <tivolinewbie@canada.com> wrote in message
news:6a8ba9f8.0305140813.3c823ec@posting.google.com...

> Hi gurus, could someone please tell me if there are tools available
> out there that can convert my perl program scripts into executable
> programs??  This is because we are having the problems of handing
> scripts over to be run on customer environments whereby the perl
> interpreter are not readily available and in fact not allowed to be
> installed.

perl2exe, to be found here:

http://www.indigostar.com/perl2exe.htm


> By the way what would happens if my programs relies on a lot of
> packages (*.pm) object oriented files which I wrote??  Would any PL ->
> EXE tool deal with this in a nice way?  TIA

'use' all of your modules explicitely, even those which are normally
inherent to some other modules (I'm speaking Perl/Tk here, mostly:
If you want to have a Text widget, which has a right button click menu
pop-up,
you have to "use Tk::Menu" explicitely to get this working in your .exe,
"use Tk::Text" would not be sufficient...).

J




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 4986
***************************************


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