Runtime exception driving me crazy 
Author Message
 Runtime exception driving me crazy

Hi,

I am migrating a Perl process from one machine to another. The new machine
is a very high end dual Pentium system with 512 MB of RAM (clone machine).
The Perl code has not changed but I am receiving a Runtime exception when
comparing two arrays.

The code looks like this:

sub listSubtraction {



    local($a);
    local($b);


        $exist = 0;


              if (uc($b) eq uc($a))

                   $exist = 1;
              }
        }

        if (!$exist)


       }
    }


Quote:
}

The process runs for several minutes comparing the arrays before stopping.
Any ideas?

Thanks,
Dave Stiff



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy
Quote:

> Hi,

> I am migrating a Perl process from one machine to another. The new machine
> is a very high end dual Pentium system with 512 MB of RAM (clone machine).
> The Perl code has not changed but I am receiving a Runtime exception when
> comparing two arrays.

> The code looks like this:

O(n^2) function snipped

Quote:
> The process runs for several minutes comparing the arrays before stopping.
> Any ideas?

No wonder it runs for several minutes, with an O(n^2) algorithm.
Read perlfaq4 on "How do I compute the difference of two arrays?  How do
I
     compute the intersection of two arrays?"
Try that code.

- Alex

PS of what order is a hash lookup?



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy


...

Quote:
> PS of what order is a hash lookup?

O(1)

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



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy

<URL::">


{}
{} ...
{}
{} > PS of what order is a hash lookup?
{}
{} O(1)

O (1) expected. O (N) worst case.

Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'

  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy

<URL::">
$$ Hi,
$$
$$ I am migrating a Perl process from one machine to another. The new machine
$$ is a very high end dual Pentium system with 512 MB of RAM (clone machine).

Not used to much, are you? 2 Pentium CPUs and 512Mb RAM are far, far away
from what I would call "high end". Not that the hardware is relevant.

$$ The Perl code has not changed but I am receiving a Runtime exception when
$$ comparing two arrays.

A runtime exception? Is this a Java implementation of Perl?

$$ The code looks like this:
$$
$$ sub listSubtraction {
$$


$$     local($a);
$$     local($b);

local? local? Eeeeeew. Why?


$$         $exist = 0;

$$               if (uc($b) eq uc($a))
$$                    $exist = 1;
$$               }
$$         }
$$         if (!$exist)

$$        }
$$     }

$$ }
$$
$$ The process runs for several minutes comparing the arrays before stopping.

Several minutes should give you a hint that your algorithm isn't anywhere
close efficient. Read the FAQ for a much, much, much faster solution.

$$ Any ideas?

Well, what does "stopping" mean? Is that the same a "runtime exception"?
Does the program abort? Do you get an error message? Could you be less
vague in what's happening?

Abigail
--

0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'

  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy
[poster cc'd in e-mail]



Quote:
>Hi,

>I am migrating a Perl process from one machine to another. The new machine
>is a very high end dual Pentium system with 512 MB of RAM (clone machine).
>The Perl code has not changed but I am receiving a Runtime exception when
>comparing two arrays.

There's nothing here that would trigger a "runtime exception"--whatever
that is.  It doesn't sound like a Perl error at all.

Quote:
>The code looks like this:

Let's look at your code for a moment though.

What an odd combination.  You're using references (a Perl 5-ism) and local
(usually a Perl 4 holdover).  That just looks so...weird together.

Quote:
> [rest of code deleted]

Why not express this all a little more concisely?  You want everything in
the first list, that's not in the second (case insensitively), returned?
OK, how about (comments added just for following along):

sub listdiff {

        my(%tmphash);
        # Build a hash of all of the elements in the first array.

                # Not any data will do.  We need to store the element
                # because the original code returns the element
                # not-lc'd so we can't just get it out of the hash key...
                $tmphash{lc($_)}=$_;
        }
        # Pass the second array...

                # Remove elements that already exist in the hash
                # from previously.  If they're not there--that's OK.
                delete $tmphash{lc($_)}
        }
        return(values %tmphash);

Quote:
}

No messy flags, only 1 temporary structure, and it's much more perlish.

This will run quite a bit faster, too.  (Its O(n) instead of O(n^2)).



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy
After doing some more testing and debugging I have determined that this is
not code related. I can comment out any code and it will still continue to
give me the Runtime Exception error. I am using Perl 5 under NT 4 SP5.

If anyone has any insight into what could be causing this I would appreciate
it. Environment settings? Perl version? NT?

Thanks,
Dave Stiff


Quote:
> Hi,

> I am migrating a Perl process from one machine to another. The new machine
> is a very high end dual Pentium system with 512 MB of RAM (clone machine).
> The Perl code has not changed but I am receiving a Runtime exception when
> comparing two arrays.

> The code looks like this:

> sub listSubtraction {



>     local($a);
>     local($b);


>         $exist = 0;


>               if (uc($b) eq uc($a))

>                    $exist = 1;
>               }
>         }

>         if (!$exist)


>        }
>     }


> }

> The process runs for several minutes comparing the arrays before stopping.
> Any ideas?

> Thanks,
> Dave Stiff



Wed, 18 Jun 1902 08:00:00 GMT  
 Runtime exception driving me crazy

Quote:

> After doing some more testing and debugging I have determined that this is
> not code related. I can comment out any code and it will still continue to
> give me the Runtime Exception error.

What, specifically, is giving you an exception? Is this a Perl error,
or an OS error? I don't think I could get Perl to do this if I tried.

It sounds like there's a problem in your system's bowels, but without
more info I can't really tell. Have you tried reinstalling Perl to stave
off DLL rot?

Scott

http://autoperl.skwc.com Automating Windows With Perl



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. E-mailing with perl is driving me crazy!

2. DBI is driving me crazy!

3. This is driving me crazy!!

4. reg exp is driving me crazy

5. TCL is Driving me crazy

6. Runtime exception with Win32::ODBC

7. gdwin32 doesn't appear to work (Runtime Exception)

8. EventLog Gets Runtime Exception Error

9. HELP! Runtime Exception Error

10. Error : Runtime exception with Win32::ODBC

11. runtime exception in activestate perl when using modules

12. Error : Runtime exception with win32Api...

 

 
Powered by phpBB® Forum Software