[18918] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1113 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 11 18:15:44 2001

Date: Mon, 11 Jun 2001 15:15:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <992297722-v10-i1113@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 11 Jun 2001     Volume: 10 Number: 1113

Today's topics:
    Re: Sorting versions of a file, Help needed <andras@mortgagestats.com>
    Re: Sorting versions of a file, Help needed <pne-news-20010611@newton.digitalspace.net>
    Re: Sorting versions of a file, Help needed (Anno Siegel)
        Spurious "Ambiguous call resolved as ..." warning (Rolf Krahl)
        supressing error messages in NT <jhoerr@resnet.gatech.edu>
    Re: The FlakeyMind Thaddes FAQ (v0.1) (Topmind)
    Re: The meaning of $#, $/, and $* (OT Response) <tschmelter@statesman.com>
        The meaning of $#, $/, and $* <bf20761@binghamton.edu>
    Re: The meaning of $#, $/, and $* <todd@designsouth.net>
    Re: The meaning of $#, $/, and $* (Craig Berry)
    Re: The meaning of $#, $/, and $* (Anno Siegel)
    Re: The meaning of $#, $/, and $* (Craig Berry)
        Vars, vars, vars... <jblakey@frogboy.net>
    Re: Vars, vars, vars... <todd@designsouth.net>
    Re: Vars, vars, vars... (Anno Siegel)
    Re: Vars, vars, vars... <tschmelter@statesman.com>
    Re: Vars, vars, vars... <ren@tivoli.com>
    Re: Vars, vars, vars... (Tad McClellan)
        weighted average? <koen@wuchem.wustl.edu>
    Re: why it dies? nobull@mail.com
    Re: why it dies? <andras@mortgagestats.com>
    Re: why it dies? <dwilga-MUNGE@mtholyoke.edu>
        Yikes! What a waste of time WAS (Re: PERL on PC) <lmoran@wtsg.com>
    Re: Yikes! What a waste of time WAS (Re: PERL on PC) <pne-news-20010611@newton.digitalspace.net>
    Re: Yikes! What a waste of time WAS (Re: PERL on PC) (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 11 Jun 2001 14:35:46 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Sorting versions of a file, Help needed
Message-Id: <3B250F82.D8BA256B@mortgagestats.com>



"Godzilla!" wrote:

(snippage)

>
>
> > Use of a hash for programming should be your last choice
>
>

> (more snippage)
>
> Hash is dogfood for humans.
>

Your reasoning is most illogical!

First: How can anything be dogfood for humans? If it is for humans, it is not
dogfood. If it is dogfood, it cannot possibly be for humans.

Second: The contradiction  above notwithstanding, why would you recommend a
food item as a choice for programming, even if you are recommending it as a
last choice. Logically, if a hash is, as you claim, dogfood for humans, then
it should be no choice for programming at all.

I suggest that you reexamin your thought processes, pinpoint the gaping
errors therein and correct them before you post again.



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

Date: Mon, 11 Jun 2001 22:07:50 +0200
From: Philip Newton <pne-news-20010611@newton.digitalspace.net>
Subject: Re: Sorting versions of a file, Help needed
Message-Id: <av6aitc2cddkdkvs4dla2ad7ei4tjih8nm@4ax.com>

On Mon, 11 Jun 2001 10:27:49 -0400, Afshin Akbari
<afshina@newbridge.com> wrote:

> I have a file that contains two piece of info.
> 1) File name    2) version     (i.e. abc.pl     12.5)
> Note that a file could have versions from 12.1 to 12.16 or above.
> 
> I need to get the latest version of each file.

So, if I understand correctly, you want to sort the versions by the
number before the decimal point, and then by the number after the
decimal point, with 12.16 > 12.9 because 16 > 9, but 13.9 > 12.16
because 13 > 12, right?

> Problem: when I read them into a hash and print the hash "abc.pl  12.9"
> get to be the highest version. Which we all know it is not.

It is if you treat the version as a floating point number, since 12.90 >
12.16 :-).

> I tried to split the digits to the left of " . " and right of " . "
> and the results is correct but it is really SLOW.

My first impulse would be a Schwartzian Transform (Gee, Randal, couldn't
your grandfather(?) have picked a different name?). I'll assume that
your file only contains information on one filename and its versions

    my @versions;
    my $name;
    while(<DATA>) {
        chomp;
        my $version;
        ($name, $version) = split;
        push @versions, $version;
    }

    my $highest = ( map  { $_->[0] }
                    sort { $b->[1] <=> $a->[1] || $b->[2] <=> $a->[2] }
                    map  { [ $_, split(/\./, $_, 2) ] }
                    @versions
                  )[0];

    print "Highest version for file '$name' is $highest.\n";
    # should be 14.11, since 14 > 12 and 11 > 8

    __END__
    abc.pl  12.10
    abc.pl  12.11
    abc.pl  12.12
    abc.pl  12.13
    abc.pl  12.14
    abc.pl  12.15
    abc.pl  12.16
    abc.pl  12.9
    abc.pl  12.8
    abc.pl  12.7
    abc.pl  12.6
    abc.pl  12.5
    abc.pl  12.4
    abc.pl  12.3
    abc.pl  12.2
    abc.pl  12.1
    abc.pl  14.8
    abc.pl  14.11

A GRT would also be possible; for that, replace the assignment to
$highest with

    my $highest = ( map  { substr($_, 2) }
                    sort
                    map  { pack('CC', split(/\./, $_, 2)) . $_ }
                    @versions
                  )[-1];

Note that here -1 is used as the index because an ascending sort is
done.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 11 Jun 2001 20:44:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sorting versions of a file, Help needed
Message-Id: <9g3ajv$oe9$1@mamenchi.zrz.TU-Berlin.DE>

According to Philip Newton  <nospam.newton@gmx.li>:
> On Mon, 11 Jun 2001 10:27:49 -0400, Afshin Akbari
> <afshina@newbridge.com> wrote:
> 
> > I have a file that contains two piece of info.
> > 1) File name    2) version     (i.e. abc.pl     12.5)
> > Note that a file could have versions from 12.1 to 12.16 or above.
> > 
> > I need to get the latest version of each file.
> 
> So, if I understand correctly, you want to sort the versions by the
> number before the decimal point, and then by the number after the
> decimal point, with 12.16 > 12.9 because 16 > 9, but 13.9 > 12.16
> because 13 > 12, right?
> 
> > Problem: when I read them into a hash and print the hash "abc.pl  12.9"
> > get to be the highest version. Which we all know it is not.
> 
> It is if you treat the version as a floating point number, since 12.90 >
> 12.16 :-).
> 
> > I tried to split the digits to the left of " . " and right of " . "
> > and the results is correct but it is really SLOW.
> 
> My first impulse would be a Schwartzian Transform (Gee, Randal, couldn't
> your grandfather(?) have picked a different name?). I'll assume that
> your file only contains information on one filename and its versions

But why sort at all?  All we want is a maximum, there's no need
to put all the elements in order.

[snip sort-based code]

What we do need is a comparison routine for versions.  Postponing
the details, let's assume that compare_versions( $v1, $v2) returns
a value < 0 if $v1 is smaller than $v2, and >= 0 otherwise, in the
intended sense of "smaller".  Then we could build a hash that holds
the highest version for each file in a single pass:

    my %high_version;
    while ( <DATA> ) {
        chomp;
        my ( $file, $version) = split;
        if ( exists $high_version{ $file} ) {
            $high_version{ $file} = $version if
                compare_versions( $high_version{ $file}, $version) < 0;
        } else {
            $high_version{ $file} = $version;
        }
    }

For compare_version different approaches are possible, but the
most straightforward seems indeed to be a split on the dot, and
comparison of the resulting integers:

    sub compare_versions {
        my ( $first_high, $first_low) = split /\./, shift;
        my ( $second_high, $second_low) = split /\./, shift;
        $first_high <=> $second_high || $first_low <=> $second_low;
    }

Anno


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

Date: 11 Jun 2001 21:11:43 GMT
From: rolf.krahl@gmx.net (Rolf Krahl)
Subject: Spurious "Ambiguous call resolved as ..." warning
Message-Id: <9g3c6f$ovv$3@rotkraut.de>

I get a spurious "Ambiguous call resolved as CORE::system(), qualify
as such or use &" warning when i use one of my self written modules.
I boiled it down to the following situation:

| nuomi-> cat /tmp/Dummy.pm 
| package Dummy;
| 
| use strict;
| use Sys::Hostname;
| use vars qw($host);
| 
| $host = hostname;
| 
| 1;
| nuomi-> perl -w -e 'use lib "/tmp"; use Dummy; system "date"'
| Ambiguous call resolved as CORE::system(), qualify as such or \
|       use & at -e line 1.
| Mon Jun 11 22:51:14 CEST 2001

(I am still using Perl 5.00503)


I think, i already found the cause:

Sys::Hostname requires syscall.ph in main context, which in turn (on
my Linux box) requires _h2ph_pre.ph which contains the pretty line

| unless (defined &system) { sub system() { "posix" } }

(I still did not understand, why the problem does only shows up, when
Sys::Hostname is used by a modul, but not when its used by the main
program itself.)


Well, fine, does anybody got an idea, how i can avoid this warning
without having to qualify all calls to system as CORE::system in my
programs?

-- 
		   Rolf Krahl <rolf.krahl@gmx.net>


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

Date: Mon, 11 Jun 2001 15:52:10 -0400
From: "John Hoerr" <jhoerr@resnet.gatech.edu>
Subject: supressing error messages in NT
Message-Id: <9g37ru$55u$1@iocextnews.bls.com>

i can't find any documentation on suppressing error messages ala $output =
`cmd 2>/dev/null`;  for a win32 environment.   Any thoughts on a good way to
do this?

thanks,
john




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

Date: Mon, 11 Jun 2001 19:20:50 GMT
From: topmind@technologist.com (Topmind)
Subject: Re: The FlakeyMind Thaddes FAQ (v0.1)
Message-Id: <MPG.158ebbe6cf3186999899cf@news.earthlink.net>

> Topmind wrote:
> > 
> > 
> > > So if U R fed up with a stupid manager: go and convince him!
> > 
> > They don't have the attention span. They get their info
> > from airline mags. If the airline mag says so.....
> > 
> > >  Go away from here, U won't find your demons here.
> > 
> > BS and distortion and hype == enemy
> > 
> > -T-
> 
> You _are_ paranoid.  GET LOST!
> 


I might be paranoid, but you are obviously 
highly irritable.

Perhaps we can make a mutual deal to get
treatment.

-t-


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

Date: Mon, 11 Jun 2001 19:32:44 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: The meaning of $#, $/, and $* (OT Response)
Message-Id: <3B251CD7.4CA6236A@statesman.com>

Todd Smith wrote:

> "Zhihui Zhang" <bf20761@binghamton.edu> wrote in message
> news:Pine.GSO.BU-L4.10.10106111456390.23275-100000@bingsun2...
> >
> > I have looked up two books on perl and could not find the explanation of
> > $#, $/, and $*. Can anyone explain this to me? Are they still in use?
> >
>
> perldoc perlvar

Come on, be helpful:

"$#, $/, and $*" is what you say in a comic strip when you're hit on the head
with a hammer. (Mnemonic: The character "#" is sometimes called the "pound"
sign, and "pound" is one thing you do with a hammer, "/" means your height has
been "slashed" by being pounded, and "*" is what you look like afterward...)

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951



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

Date: Mon, 11 Jun 2001 15:00:17 -0400
From: Zhihui Zhang <bf20761@binghamton.edu>
Subject: The meaning of $#, $/, and $*
Message-Id: <Pine.GSO.BU-L4.10.10106111456390.23275-100000@bingsun2>


I have looked up two books on perl and could not find the explanation of
$#, $/, and $*. Can anyone explain this to me? Are they still in use?

Thanks,

-Zhihui



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

Date: Mon, 11 Jun 2001 19:03:33 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: The meaning of $#, $/, and $*
Message-Id: <9C8V6.138157$I5.35053256@news1.rdc1.tn.home.com>


"Zhihui Zhang" <bf20761@binghamton.edu> wrote in message
news:Pine.GSO.BU-L4.10.10106111456390.23275-100000@bingsun2...
>
> I have looked up two books on perl and could not find the explanation of
> $#, $/, and $*. Can anyone explain this to me? Are they still in use?
>

perldoc perlvar




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

Date: Mon, 11 Jun 2001 20:44:08 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: The meaning of $#, $/, and $*
Message-Id: <tiabcoeq147r24@corp.supernews.com>

Zhihui Zhang (bf20761@binghamton.edu) wrote:
: I have looked up two books on perl and could not find the explanation of
: $#, $/, and $*. Can anyone explain this to me? Are they still in use?

They're all documented in perlvar.  $# is deprecated; it controls default
formatting of floating-point values for output.  $/ is the input record
separator and is very commonly used.  $* sets multi-line matching mode;
it's deprecated, its functions supplanted by the /m and /s regex
modifiers.

By the way, I've been agitating for a couple of years to repurpose $# to
hold the current index value within a foreach construct, but don't seem to
be making much headway.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: 11 Jun 2001 20:50:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: The meaning of $#, $/, and $*
Message-Id: <9g3aur$oe9$2@mamenchi.zrz.TU-Berlin.DE>

According to Craig Berry <cberry@cinenet.net>:
 
> By the way, I've been agitating for a couple of years to repurpose $# to
> hold the current index value within a foreach construct, but don't seem to
> be making much headway.

If you hadn't mentioned it, I would have.  I am much in favor of the
resurrection of $# in this form.

Did someone say "patch"? :)

Anno


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

Date: Mon, 11 Jun 2001 21:27:40 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: The meaning of $#, $/, and $*
Message-Id: <tiaduc6f92l0b8@corp.supernews.com>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
: According to Craig Berry <cberry@cinenet.net>:
: > By the way, I've been agitating for a couple of years to repurpose $# to
: > hold the current index value within a foreach construct, but don't seem to
: > be making much headway.
: 
: If you hadn't mentioned it, I would have.  I am much in favor of the
: resurrection of $# in this form.
: 
: Did someone say "patch"? :)

I took a look at the perl internals, then staggered off for a shot of
tequila.  Much as I'd love to attain the level of initiation required to
offer a patch, I have too many other things to deal with.  Hence my low-
key advocacy; it would hardly be fair for me to demand action from those
who can do this, but I'm hoping if I (and others) suggest it often enough,
one of the Great Old Ones may decide to implement the idea.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Mon, 11 Jun 2001 15:19:13 -0400
From: Jason Blakey <jblakey@frogboy.net>
Subject: Vars, vars, vars...
Message-Id: <MO8V6.248142$Z2.2855419@nnrp1.uunet.ca>

Hi,

  i'm using "do" to load some variables from a configuration file...  and i 
want to "use strict" in the calling program (my new SM kick).  So, in my 
calling program, i've tried  "our", "my", and "local" declarations for 
those variables from the configuration file, but no luck...

Global symbol "$SSH" requires explicit package name at unix line 19.


Do i need to disable someting in the strict module?  Or what?

Thanks.
jason 


-- 

This email from jason blakey - jblakey@frogboy.net - http://www.frogboy.net
                 " The Luckiest Guy in the World "



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

Date: Mon, 11 Jun 2001 19:40:39 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: Vars, vars, vars...
Message-Id: <X89V6.138163$I5.35126886@news1.rdc1.tn.home.com>


"Jason Blakey" <jblakey@frogboy.net> wrote in message
news:MO8V6.248142$Z2.2855419@nnrp1.uunet.ca...
> Hi,
>
>   i'm using "do" to load some variables from a configuration file...  and
i
> want to "use strict" in the calling program (my new SM kick).  So, in my
> calling program, i've tried  "our", "my", and "local" declarations for
> those variables from the configuration file, but no luck...
>
> Global symbol "$SSH" requires explicit package name at unix line 19.
>
>
> Do i need to disable someting in the strict module?  Or what?
>

You should write a .pm file and 'use' it too, then your vars are :

use MyPMFile;

$MyPMFile::var1;
$MyPMFile::var2;




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

Date: 11 Jun 2001 19:54:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Vars, vars, vars...
Message-Id: <9g37lv$gca$4@mamenchi.zrz.TU-Berlin.DE>

According to Todd Smith <todd@designsouth.net>:
> 
> "Jason Blakey" <jblakey@frogboy.net> wrote in message
> news:MO8V6.248142$Z2.2855419@nnrp1.uunet.ca...
> > Hi,
> >
> >   i'm using "do" to load some variables from a configuration file...  and
> i
> > want to "use strict" in the calling program (my new SM kick).  So, in my
> > calling program, i've tried  "our", "my", and "local" declarations for
> > those variables from the configuration file, but no luck...
> >
> > Global symbol "$SSH" requires explicit package name at unix line 19.
> >
> >
> > Do i need to disable someting in the strict module?  Or what?
> >
> 
> You should write a .pm file and 'use' it too, then your vars are :
> 
> use MyPMFile;
> 
> $MyPMFile::var1;
> $MyPMFile::var2;

That is only true if he also has the (recommended) "package MyPMFile;"
early in his .pm file.  Otherwise, the name of the module file and
the package it defines its variables in are unrelated.

Anno


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

Date: Mon, 11 Jun 2001 20:01:44 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: Vars, vars, vars...
Message-Id: <3B2523A7.3D45967C@statesman.com>

Jason Blakey wrote:

> Hi,
>
>   i'm using "do" to load some variables from a configuration file...  and i
> want to "use strict" in the calling program (my new SM kick).  So, in my
> calling program, i've tried  "our", "my", and "local" declarations for
> those variables from the configuration file, but no luck...
>
> Global symbol "$SSH" requires explicit package name at unix line 19.
>
> Do i need to disable someting in the strict module?  Or what?

What.

"SM" in this case, means, "Smart and Maintainable". Always use strict. Use
"-w", too, while you're at it. Be aware of the scoping of these variables.
Check out:
  perldoc -f do
  perldoc -f our

Provide some code examples. For example, this works for me:

config.pl:
  use strict;
  our $var1 = 'A';
  our $var2 = 'B';

Output of perl -we 'use strict; our $var1; do "config.pl"; print
"var1=$var1\n";'
  var1=A

What problem are you having?

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951




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

Date: 11 Jun 2001 14:38:41 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Vars, vars, vars...
Message-Id: <m3r8wqn6wu.fsf@dhcp9-173.support.tivoli.com>

On Mon, 11 Jun 2001, jblakey@frogboy.net wrote:

> Hi,
> 
>   i'm using "do" to load some variables from a configuration file...
>   and i want to "use strict" in the calling program (my new SM
>   kick).  So, in my calling program, i've tried "our", "my", and
>   "local" declarations for those variables from the configuration
>   file, but no luck...
> 
> Global symbol "$SSH" requires explicit package name at unix line 19.
> 
> 
> Do i need to disable someting in the strict module?  Or what?

There are several solutions, but my personal favorite is to use a hash
for all of your configuration variables.  Then you can do something
like:

=== config.pl ===
{
  timeout => 60,
  home    => "/home/blah",
}
=================

#!/usr/bin/perl
use warnings;
use strict;

my $cfg = do 'config.pl';

print "Home: $cfg->{home}\n";
__END__


or...

=== config.pl ===
our %cfg;
$cfg{timeout} = 60;
$cfg{home} = "/home/blah";
=================

#!/usr/bin/perl
use warnings;
use strict;

our %cfg;
do 'config.pl';

print "Home: $cfg{home}\n";
__END__



-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 11 Jun 2001 16:21:32 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Vars, vars, vars...
Message-Id: <slrn9iaa2c.d22.tadmc@tadmc26.august.net>

Jason Blakey <jblakey@frogboy.net> wrote:
>
>  i'm using "do" to load some variables from a configuration file...  and i 
>want to "use strict" in the calling program (my new SM kick).  So, in my 
>calling program, i've tried  "our", "my", and "local" declarations for 
>those variables from the configuration file, but no luck...
>
>Global symbol "$SSH" requires explicit package name at unix line 19.
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Do i need to disable someting in the strict module?  Or what?


You have already seen the usual ways of keeping strictures happy,
use a containing hash, our, use vars...

One alternative that often goes unmentioned is the one that is
mentioned by the diagnostic message itself  :-)

You can just use an explicit package name in your main:

   print $main::SSH;

or, shorten it to:

   print $::SSH;

if $SSH is only used a few times, then I would go with an explicit name
instead of a declaration.



"use strict" does NOT require that you declare variables before
you use them!

Many people are surprised by that true statement...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 11 Jun 2001 16:33:54 -0500
From: Koen van der Drift <koen@wuchem.wustl.edu>
Subject: weighted average?
Message-Id: <Pine.GSO.4.05.10106111626470.10070-100000@wuchem.wustl.edu>

Hi,

I'm pretty new to Perl, and I have looked at the FAQ at CPAN, but I
couldn't find anything about calculating a weighted average. The input
file looks something like this (where the '...' indicate one series of
data):

 ...
500.0	5
500.3	20
500.6	85
500.9	80
501.2	15
501.5	5
 ...

I assume I can just read in the 2 columns into 2 arrays until the
next '...', and then do the calculation myself, but maybe there is a
module around that does this for me. I understand of course the
algorithm to calculate the average, so that's not the problem.

any suggestions appreciated

thanks,

- Koen.



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

Date: 11 Jun 2001 19:15:04 +0100
From: nobull@mail.com
Subject: Re: why it dies?
Message-Id: <u9puca3mtz.fsf@wcl-l.bham.ac.uk>

"David Soming" <davsoming@lineone.net> writes:

>  die;                           #and die it does! -line 30

Huh?  You have an unconditional die in your code and you want to know
why your code dies!?!?  Err.... am I missing something here?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 11 Jun 2001 14:24:41 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: why it dies?
Message-Id: <3B250CE8.3BB6A6A6@mortgagestats.com>



David Soming wrote:

> Hi,
> Using my  form it correctly displays feedback (acknowledgment in browser)
> and sends webmaster email OK but dies with the following footer message:
>
> Software error:
> Died at /home/sites/site13/web/cgi-bin/feedback/feedback2000.pl line 30.
> For help, please send mail to the webmaster (admin), giving this error
> message and the time and date of the error.
>
> #!/usr/bin/perl -w
>
> use CGI qw(:standard);
> use CGI::Carp qw(fatalsToBrowser);#use the CGI::Carp module to get error
> messages sent to your browser
>
> $database = "message2000.txt";
>
> $firstname = param("firstname");
> $familyname = param("familyname");
> $email = param("email");
> $phone = param("phone");
> $fax = param("fax");
>
> $messagetype = param("messagetype");
> $message = param("message");
> $findus = param("findus");
> $searchkeywords = param("searchkeywords");
>
> $run = param("run");
>
> if ($run =~ /Submit/i){
>
>  &check_data;
>  &fill_empty_fields;
>  &store_data;
>  &send_email;
>  &display_feedback;
>  die;                           #and die it does! -line 30
>  }
>
> if ($run =~ /display/i){
>
>  &display_messagefile;
>  die;
>  }
> #<snip> sub check_data{  #routine below here
>
> I think the error message is standardised and comes from module CGI::Carp ?
> But anything obvious why it should fail?
> Thanks
> ---
> David Soming
> 'Just a head-banger- doing what I do best'
> ______________

Well, you tell your program to die and it does. There is nothing out of the
ordinary here.

You are using die inappropriately, though. I think what you need here is either
exit at the end of your if blocks, or maybe you should be using elsif blocks
instead of the second, third, etc. if block. Do read up on the difference
between die and exit.



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

Date: Mon, 11 Jun 2001 18:53:16 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: why it dies?
Message-Id: <dwilga-MUNGE-0AB3EB.14530111062001@nap.mtholyoke.edu>

In article <tia14ba25b0c8a@corp.supernews.co.uk>,
 "David Soming" <davsoming@lineone.net> wrote:

> Hi,
> Using my  form it correctly displays feedback (acknowledgment in browser)
> and sends webmaster email OK but dies with the following footer message:
> 
[...]
>  &check_data;
>  &fill_empty_fields;
>  &store_data;
>  &send_email;
>  &display_feedback;
>  die;                           #and die it does! -line 30
>  }

If you want to end your script normally, use exit(), not die(). Die() is for 
abnormal termination, which is why you are getting the error message.

perldoc -f die
perldoc -f exit

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Mon, 11 Jun 2001 14:57:21 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Yikes! What a waste of time WAS (Re: PERL on PC)
Message-Id: <ro4aitsmumjj26fgk2cvhpo4cgi9mcv7lv@4ax.com>

--What dumb thread.

--PERL, Perl, perl.  Masters Degree.  Manure.  Catfish.  Misogyny.
Lizards.  Beastiality.  Accusations of multiple personalities.  WOW!
That thread had it all.

--Sadly CLP.Misc is known for this stuff.  And it is really not like
this.  There is GREAT info to be had if you wear your waders.  Why
these flame wars begin is odd.

--As for PERL, Perl, perl I *might* point out to the OP who misused
it:

Oh and FYI it's Perl not PERL and for some reason people are really
picky about it so please read the FAQ so you don't become flame-bait.

--More likely than not I wouldn't even mention it.  Not that there's
anything wrong with advocacy and proper usage.  I, me, Lou Moran,
wouldn't make a big deal out of it.  

--Anylou... my .02



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

Date: Mon, 11 Jun 2001 22:07:53 +0200
From: Philip Newton <pne-news-20010611@newton.digitalspace.net>
Subject: Re: Yikes! What a waste of time WAS (Re: PERL on PC)
Message-Id: <q98aitou0lc4rbg3d8024g8ptl168t48so@4ax.com>

On Mon, 11 Jun 2001 14:57:21 -0400, Lou Moran <lmoran@wtsg.com> wrote:

> There is GREAT info to be had if you wear your waders.

Yes. Good to stick around, develop a thick skin, and separate the wheat
from the chaff, and you'll find there's quite a bit of wheat.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Mon, 11 Jun 2001 16:43:39 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Yikes! What a waste of time WAS (Re: PERL on PC)
Message-Id: <slrn9iabbr.d22.tadmc@tadmc26.august.net>

Lou Moran <lmoran@wtsg.com> wrote:
>--What dumb thread.
>
>--PERL, Perl, perl.  

>That thread had it all.


The Subject mentioned Political Correctness, so what should we 
have expected?

:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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