[18033] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 193 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 1 14:10:48 2001

Date: Thu, 1 Feb 2001 11:10:23 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981054622-v10-i193@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 1 Feb 2001     Volume: 10 Number: 193

Today's topics:
        how to split *gz file <yhu@mail.nih.gov>
        Installing Storable Module on SGI Machine <david@habanero.chem.usu.edu>
        Integrating Perl into Javascript curious@ems.att.com
        Just a quick question re: temp files? <rob.cooper@djstore.co.uk>
        pass http_referer info <wo_ah_ho@yahoo.com>
        Pipes/IPC ++ for Unix(Perl) laupstad@my-deja.com
        please help me <bini@gmx.at>
    Re: please help me <mellouet.ronan@wanadoo.fr>
    Re: please help me (Craig Berry)
        popup_menu question <g-preston1@ti.com>
    Re: question about sort <mjcarman@home.com>
    Re: question about sort <mjcarman@home.com>
    Re: RegExp: Find anything except... <vezerid@ac.anatolia.edu.gr>
    Re: Relaying denied error nobull@mail.com
        removing characters from string <davidwaters@bigfoot.com>
    Re: removing characters from string (Rafael Garcia-Suarez)
    Re: removing characters from string <bcaligari@my-deja.com>
    Re: removing characters from string (Craig Berry)
        searching text files using NEAR (proximity) timur@lbri.lionbioscience.com
    Re: secure form nobull@mail.com
    Re: Should this code work? mexicanmeatballs@my-deja.com
    Re: sorting IP addresses <comdog@panix.com>
    Re: sorting through a hash of arrays <mjcarman@home.com>
        Thank you!- Re: sort: how do I ignore a specific word? <fundthis.see@fsck>
    Re: Using global var in subroutine <steve@teamITS.com>
        v. 5.6.0 + CGI.pm: eval fails to trap errors <kj0@mailcity.com>
    Re: v. 5.6.0 + CGI.pm: eval fails to trap errors <joe+usenet@sunstarsys.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 01 Feb 2001 11:51:28 -0500
From: Ying Hu <yhu@mail.nih.gov>
Subject: how to split *gz file
Message-Id: <3A799410.D29F62@mail.nih.gov>

I want to split *.gz file into more *.gz files. For example,
split big.gz into small1.gz, small2.gz, small3.gz, small4.gz ...
thanks
Ying



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

Date: Thu, 01 Feb 2001 11:02:09 -0700
From: david farrelly <david@habanero.chem.usu.edu>
Subject: Installing Storable Module on SGI Machine
Message-Id: <3A79A4A1.72A6ED15@habanero.chem.usu.edu>

I'm a fairly new Perl user. I recently  installed
Storable successfully on my DEC alpha machine, but am unable to do so on
an SGI
Origin 200. The problem seems to be that the Storable.c file won't
compile. I'm appending the error messages from the make instruction.

I would appreciate any comments.

Thanks,

David Farrelly

*******************************************************************

make
        cc -n32 -mips3 -c  -DBSD_TYPES -D_BSD_SIGNALS -D_BSD_TIME -DL
ANGUAGE_C -woff 1009 -O2 -OPT:Olimit=0     -DVERSION=\"1.006\"  -DXS_
VERSION=\"1.006\"  -I/usr/share/lib/perl5/irix-n32/5.003/CORE  Storab
le.c
"Storable.c", line 1012: error(1133): expression must be a modifiable
 lvalue
                HeVAL(he) = &PL_sv_undef;
                ^

"Storable.c", line 1016: error(1133): expression must be a modifiable
 lvalue
                HeVAL(he) = &PL_sv_undef;
                ^

"Storable.c", line 1237: error(1515): a value of type "int" cannot be
 assigned
          to an entity of type "GV *"
        gv = gv_fetchmethod_autoload(pkg, method, FALSE);
           ^

"Storable.c", line 1788: error(1140): a value of type "int" cannot be
 used to
          initialize an entity of type "SV *"
                        SV *key = hv_iterkeysv(he);
                                  ^

"Storable.c", line 1798: error(1140): a value of type "int" cannot be
 used to
          initialize an entity of type "HE *"
                        HE *he  = hv_fetch_ent(hv, key, 0, 0);
                                  ^

"Storable.c", line 1799: error(1140): a value of type "int" cannot be
 used to
          initialize an entity of type "SV *"
                        SV *val = HeVAL(he);
                                  ^

"Storable.c", line 3511: error(1020): identifier "HEf_SVKEY" is undef
ined
        sv_magic(tv, sv, 'p', (char *)key, HEf_SVKEY);
                                           ^

7 errors detected in the compilation of "Storable.c".
*** Error code 2 (bu21)





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

Date: Thu, 01 Feb 2001 17:41:06 GMT
From: curious@ems.att.com
Subject: Integrating Perl into Javascript
Message-Id: <95c73g$vum$1@nnrp1.deja.com>

Hello...

My first question...Is it possible?

Scenario:

Here at work we have the following situation:

1.  A software system creates a form for user input.

2.  I have created a form to dynamically change choices in a list box.

3.  Those listboxes can and will change their data over time [store data
in a text file.

4.  I want to possibly use perl to open the txt file on the web server,
populate variables when the form loads up, use javascript to import the
data stored in perl variables, then use javascript with populate the
listboxes with the data from the text file.

I know how to do this with .asp, but unfortunately the whole web server
that I am trying to implement this on is a Netscape Server on a Solaris
system.

All I want to do is import data from a file [dynamically] into my
Javascript...

Is this possible or should I just get used to the fact that I will have
to "hard-code" the data [from the text file] and continously update it?
I would like the server to do the updating, not me....

Thanks in advance for your help.

George


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 1 Feb 2001 15:47:48 -0000
From: Robert Cooper <rob.cooper@djstore.co.uk>
Subject: Just a quick question re: temp files?
Message-Id: <54B8C3DBC2EDD311A63700A0CC5E47710ADFEB@SERVER>

Hi All,

Apologies for just dropping into the group and posting - but I'm in need
of an answer to a quick question which the scripts authors aren't
prepared to discuss (grrr...)

Basically, I'm wondering why the "main" shopping script for our site
generates its output to a temporary file, then sends that file out to
the client?

(Perl 5 NT btw)

Ire... Client requests a page,
Page is generated by the script and output to a temporary file (which is
our session number - as set in the users cookie) (using the select
method)
The last thing the script does is revert to STDOUT and then punts that
page out to the client.

Now the only reason I can imagine that it does this, is in order to
speed up the output of the page???

I'm really trying to find out WHY this method is employed (in this
script only), so that I can disable the ever growing temporary file
generation!

Any help gratefully received!

Rob
DJ Store HelpDesk

P.S. You find the site's page in question at www.djstore.co.uk (simply
click on any product or category)





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

Date: Thu, 1 Feb 2001 13:10:03 -0500
From: "Jason Wong" <wo_ah_ho@yahoo.com>
Subject: pass http_referer info
Message-Id: <95c8og$dht$1@bcrkh13.ca.nortel.com>

Here's the case

a.html    b.html    c.cgi

where b.html is the form

how can i get the a.html url and pass it to c.cgi (the easier the better)

Jason W.




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

Date: Thu, 01 Feb 2001 15:57:45 GMT
From: laupstad@my-deja.com
Subject: Pipes/IPC ++ for Unix(Perl)
Message-Id: <95c11i$pqs$1@nnrp1.deja.com>

Hi all, I'm having a problem here and was hoping someone could help me. This
is the setup: I have 2 Sun machines, running Solaris. They are connected to
each other back2back. On the first machine I wan't to run a perl script as a
cron job which gets some information from the other machine (statistics). So
far so good, the problem is that, the command my perl script has to perform
on the "remote" machine is performed inside a special shell. Typical, on the
remote machine I run tcsh, and to start up the command I need to start
another shell (very special-company-made-shell...) Then I have to write my
command inside that shell to get the output. Breifly: 1) Perl script on my
local machine starts up (cron) 2) Logs into the remote machine 3) Starts the
new custom-made shell 4) Enters the command in that shell 5) Printout of this
is stored in a file on my local machine.

Now the challenge: This must be done only with the core package of perl,
meaning no packages (Expect would be nice here I guess.....) Best regards
K.M. Laupstad



Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 1 Feb 2001 16:51:09 +0100
From: "Sabine Lackner" <bini@gmx.at>
Subject: please help me
Message-Id: <3a798569$0$26348@SSP1NO25.highway.telekom.at>

i have a little problem
i want to write a script, that searches through a webfolder and shows each
picture thats in it on a website
i have this so far:

push(@dateien, <*.gif>);
push(@dateien, <*.jpg>);


foreach $datei (@dateien) {

        print "<IMG SRC=$datei>\n";

}

but my problem is, that i havent done this for a long while and cant
remember how to start and how to end.
could somebody please write to whole missing things for me?? would be very
great :-)

sL




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

Date: Thu, 1 Feb 2001 17:09:33 +0100
From: "mellouet ronan" <mellouet.ronan@wanadoo.fr>
Subject: Re: please help me
Message-Id: <95c1jp$qhg$1@wanadoo.fr>

Hi,
the end come when foreach has read all the line in @dateien and return
undef.
Sabine Lackner a écrit dans le message
<3a798569$0$26348@SSP1NO25.highway.telekom.at>...
>i have a little problem
>i want to write a script, that searches through a webfolder and shows each
>picture thats in it on a website
>i have this so far:
>
>push(@dateien, <*.gif>);
>push(@dateien, <*.jpg>);
>
>
>foreach $datei (@dateien) {
>
>        print "<IMG SRC=$datei>\n";
>
>}
>
>but my problem is, that i havent done this for a long while and cant
>remember how to start and how to end.
>could somebody please write to whole missing things for me?? would be very
>great :-)
>
>sL
>
>




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

Date: Thu, 01 Feb 2001 18:34:11 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: please help me
Message-Id: <t7jb13ogd4cr61@corp.supernews.com>

Sabine Lackner (bini@gmx.at) wrote:
: i have a little problem

With your subject line, to start with. :)  Please choose a subject that
describes your particular problem.

: i want to write a script, that searches through a webfolder and shows each
: picture thats in it on a website
: i have this so far:
: 
: push(@dateien, <*.gif>);
: push(@dateien, <*.jpg>);

You could write that as

  push @dateien, <*.gif>, <*.jpg>;

or even as a simple assingment to @dateien if the array is initially
empty.

: foreach $datei (@dateien) {
: 
:         print "<IMG SRC=$datei>\n";
: }
: 
: but my problem is, that i havent done this for a long while and cant
: remember how to start and how to end.

I'm not sure I understand what you mean by "how to start and end".  If you
need to generate http headers and the like, the CGI.pm module may prove
very helpful.  'perldoc CGI' for details.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Thu, 01 Feb 2001 12:21:59 -0600
From: Jerry Preston <g-preston1@ti.com>
Subject: popup_menu question
Message-Id: <3A79A947.42506232@ti.com>

ALl,

I am using a popup_menu to list a number of items.  I know that the
popup_menu will goto the first in the list of any single character
pressed.  Is there a way or another method that will allow you to type
in a number of characters to make your selection?


Thanks for YOUR help,

Jerry


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

Date: Thu, 01 Feb 2001 07:59:55 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: question about sort
Message-Id: <3A796BDB.4DF8BF4@home.com>

tigra@sky.deep.ru wrote:
> 
>  k9boy@my-deja.com wrote:
>> I intend to have a list with elements like so:
>>
>> a[0] = {
>> NAME => "Joe",
>> AGE => "25"
>> };
>>
>> Is it possible to use the perl's sort to sort the list by NAME, AGE,
>> etc?
[snip]
> sort {$array[$a]{'AGE'} <=> $array[$b]{'AGE'}} @array;
[snip]

Blech. Not even close. *Please* test code before you post, or at least
mark it plainly as untested. Do you know what $a and $b are inside a
sortsub? They aren't indices, as you seem to be thinking. They're
aliases for array elements. I strongly suggest spending some time going
over the sort manpage.

[Quoting myself from another branch of this thread]

@a = sort {$a->{NAME} cmp $b->{NAME} ||
           $a->{AGE}  <=> $b->{AGE}    } @a;

-mjc


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

Date: Thu, 01 Feb 2001 08:17:01 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: question about sort
Message-Id: <3A796FDD.8234B4CC@home.com>

Chris Stith wrote:
> 
> Michael Carman <mjcarman@home.com> wrote:
> 
>> @a = sort {$a->{NAME} cmp $b->{NAME} ||
>>            $a->{AGE}  <=> $b->{AGE}    } @a;
> 
> Much more simple than my original kludged response in another portion
> of the thread. It doesn't use references like mine does either, which
> can be a plus. (Yes, I'm aware it is an implicit reference to the
> user-supplied sort sub, but that's different from passing around
> explicit hard refs). If one did like the calling method I used for
> some reason, it wouldn't be hard to wrap around this, either.

My response was just a standard sortsub. There are fancier techniques
designed to speed up large, complicated sorts (Schwartzian Transform,
Guttman-Rosler Transform) but those are complete overkill here.

Maybe we can call yours the "Rubilator Sort." :) And even if you did
take the long way around, the important thing is that it worked. We'll
smooth the rough edges later.
 
> I really do need to brush up on a few things. I should have had this in
> mind myself.

Remember Larry's goal for Perl: "Simple things should be simple, and
hard things should be possible." Sorting should be simple, and it is.
When something that should be easy starts looking hard, you're probably
on the wrong path. That's when it's time to do a sanity check and look
at the docs.

In this case, the sort manpage has numerous examples, and there are two
FAQs with 'sort' in their title.

-mjc


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

Date: Thu, 01 Feb 2001 15:33:03 GMT
From: Costis Vezeridis <vezerid@ac.anatolia.edu.gr>
Subject: Re: RegExp: Find anything except...
Message-Id: <95bvjf$oei$1@nnrp1.deja.com>


> >I need this because the ? for the non-greedy search does not always
> >seem to work reliably.
>
> use PSI::ESP;
>
> How does it "not always seem to work reliably"?  Does it perhaps fail
> to match more than one line?  Did you write ".*?"?  Did you forget
/s?

I mean that sometimes the patterns using ? indeed act greedy. For
example, m/\(.+?\)/ would sometimes match with another closing
parenthesis and not the immediately following one. When I switched to
m/\([^\)]+?\)/, it would safely match only neighboring paren's.
--
Costis Vezeridis


Sent via Deja.com
http://www.deja.com/


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

Date: 01 Feb 2001 18:05:29 +0000
From: nobull@mail.com
Subject: Re: Relaying denied error
Message-Id: <u9r91iwa6u.fsf@wcl-l.bham.ac.uk>

dima81@yahoo.com writes:

> 550 ... Relaying denied

> What should I change in server?

Relaying settings in your SMTP server.

Nothing to do with Perl.

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


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

Date: Thu, 01 Feb 2001 15:57:03 GMT
From: David Waters <davidwaters@bigfoot.com>
Subject: removing characters from string
Message-Id: <95c109$pq6$1@nnrp1.deja.com>

How do you remove a listnof charcaters from a string
in one go?

$string = "abcdefghij" ;

e.g. remove a, c and e in one go


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 01 Feb 2001 16:16:58 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: removing characters from string
Message-Id: <slrn97j3e3.3i2.rgarciasuarez@rafael.kazibao.net>

David Waters wrote in comp.lang.perl.misc:
> How do you remove a listnof charcaters from a string
> in one go?
> 
> $string = "abcdefghij" ;
> 
> e.g. remove a, c and e in one go

I'm not sure of what you want, but perhaps the tr/// operator (described
in the perlop section of the docs) can do the job :

  $string =~ tr/ace//d;

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 01 Feb 2001 16:30:44 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: removing characters from string
Message-Id: <95c2vk$rno$1@nnrp1.deja.com>

In article <95c109$pq6$1@nnrp1.deja.com>,
  David Waters <davidwaters@bigfoot.com> wrote:
> How do you remove a listnof charcaters from a string
> in one go?
>
> $string = "abcdefghij" ;
>

using y/// or s///
check perl docs

typically you'd say:
$someString =~ y/abc//d;

Brendon
++++


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 01 Feb 2001 18:34:54 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: removing characters from string
Message-Id: <t7jb2e4u26os79@corp.supernews.com>

David Waters (davidwaters@bigfoot.com) wrote:
: How do you remove a listnof charcaters from a string
: in one go?
: 
: $string = "abcdefghij" ;
: 
: e.g. remove a, c and e in one go

$string =~ tr/ace//d;

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Thu, 01 Feb 2001 17:49:20 GMT
From: timur@lbri.lionbioscience.com
Subject: searching text files using NEAR (proximity)
Message-Id: <95c7is$f9$1@nnrp1.deja.com>

I was looking for Perl modules that can search text files using NEAR,
AND, OR, NOT. Support of regular expressions is a plus. There is no
need for sophisticated indexing algorithms, since files to be searched
are typically small. Example of usage:

search filename (cat OR dog) NEAR house

Thank you!

Timur Shtatland


Sent via Deja.com
http://www.deja.com/


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

Date: 01 Feb 2001 18:04:56 +0000
From: nobull@mail.com
Subject: Re: secure form
Message-Id: <u9snlywa7r.fsf@wcl-l.bham.ac.uk>

"Pier Paolo" <paolo@eurotime.it> writes:

> i need a form to send to my e-mail some info and a message of a client.
> This form have to be secure,therefore must be impossible to send html
> commands that can crash the server.

The server?  What server are you talking about?  HTML in e-mail will
be interpreted by the mail _client_ not the server.

If your script is sending text/plain mail then there's no issue.

If your script is sending text/html and the user is entering
text/plain in the form then you need to pass the user's message
through CGI::escapeHTML().

If your script is sending text/html and the user is entering
text/html in the form[1] then you need to filter the HTML in some way,
probably using HTML::Parser.

[1] AFAIK popular browsers don't support HTML input fields anyhow.

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


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

Date: Thu, 01 Feb 2001 14:19:40 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: Should this code work?
Message-Id: <95br9i$k30$1@nnrp1.deja.com>

In article <3a795a53.16738877@news.freeserve.net>,
  pawsindoors@hotmail.com (Steve) wrote:
> When I prime the variable $this_directory with the data
> 'target_directory' from within the routine, or even within another
> routine it all works. It only fails when it comes in as
> $form_data{'selected_directory'}, (even though this contains the
> correct data 'target_directory'.
Are you sure you're not getting any other chars in
$this_directory, such as line feeds etc.

> Godzilla! has suggested that the problem is in the read parse routine.
She would..

However you said that you had checked that $path_to_myfile is correct,
so either it's characters that don't show up or something else.

In what way does it fail?
What test data did you use?
I tried:-
bash$ cat /tmp/a/myfile.txt
Thu Feb  1 13:58:44 GMT 2001||
Thu Feb  1 13:58:48 GMT 2001||
Thu Feb  1 13:58:51 GMT 2001|String to match|
Thu Feb  1 13:58:54 GMT 2001||
bash$ ./test.pl
bash$ cat /tmp/a/myfile.txt
Thu Feb  1 13:58:44 GMT 2001||
Thu Feb  1 13:58:48 GMT 2001||
Thu Feb  1 13:58:54 GMT 2001||

Which appears to work, but I just set $this_directory to a fixed value,
I don't have the time to guess what the code you didn't show us is.
But what you did show us works (If that is what it's supposed to do).

--
Jon
perl -e '$|=($_)=(pop);A:$_=~s/.(.)(.*)/\r$2$1/;print;
select pop,pop,pop,.10;goto A' ' iname.com   JonBarker@'


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 01 Feb 2001 10:47:17 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: sorting IP addresses
Message-Id: <comdog-0DB402.10471701022001@news.panix.com>

In article <x78znqsn7l.fsf@home.sysarch.com>, Uri Guttman 
<uri@sysarch.com> wrote:


> yeah, but who tests code here and i don't have a list of IP addresses to
> sort. :)

don't have a list of IP addresses?  yeah - those things are so
secret. ;)

-- 
brian d foy <comdog@panix.com>



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

Date: Thu, 01 Feb 2001 08:36:08 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: sorting through a hash of arrays
Message-Id: <3A797458.AEC3352E@home.com>

[Your subject is "sorting through a hash of arrays" but your post makes
no mention of sorting. Try to pick a more accurate description next
time. :) ]

onarasim@my-deja.com wrote:
> 
> I have a text file which has a number of fields, delimited by tabs.
> Each of the fields has some data - all can be treated as strings.
> 
> Now, I am interested in ensuring that I keep only those records with
> unique values for (say) field 1. Uniqueness suggests that I need a
> hash

Good start.

>  the wrinkle is that I don't just want a list of unique field 1
> values, but instead, the complete record for those cases. Do I need
> some kind of array reference as the hash value here? Any suggestions on
> how I could proceed?

You haven't really given us a full description of what you want, so I've
assumed that the first field is an identifier, not part of the data, and
that fields 2 .. N are what you want to keep. This keeps a hash using
the first field as keys and the remaining fields as the values.

#!/usr/local/bin/perl5 -w
use strict;
my %keepers;

while (<DATA>) {
    chomp;
    my @line = split;
    $keepers{$line[0]} = [@line[1 .. $#line]];
}

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

__DATA__
A	A1	A2
B	B1	B2
C	C1	C2
A	A3	A4

----Output----
A: A3 A4
B: B1 B2
C: C1 C2

Notice something here though: because the first field is your unique
key, the first and last data entries have collided, and the latter one
overwrote the first. You could get the opposite effect (keep only the
first one) by changing this line

    $keepers{$line[0]} = [@line[1 .. $#line]];

to this

    $keepers{$line[0]} ||= [@line[1 .. $#line]];

-mjc


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

Date: Thu, 1 Feb 2001 13:18:52 -0500
From: "Cyclops" <fundthis.see@fsck>
Subject: Thank you!- Re: sort: how do I ignore a specific word?
Message-Id: <3a79a635@news.isc.rit.edu>

Gwyn and Michael,

Thank you for your help! Your suggestions have definitely helped. Gwyn, I
will look into your suggestions of hashes and Gutman-Rossler/Schwartzian
Transform as a way to improve sorting speed (you can tell I'm not computer
science by my lack of knowledge about those two sorting algorithms).

-DavidJ

Michael Guenther <miguenther@lucent.com> wrote in message
news:95bh01$r8e@nntpa.cb.lucent.com...
> > No it won't. It'll barf with a syntax error.
> Sorry fast typing ...
>
> The take the complete part ( copy and paste) ;-)
> #######################
> @movies=("1999|Flints|zaaa|zolor","2000|The Blinds
> II|aaaa|color","1787|Aaaaa|bbbb|fff|","1998|zzz|gggg|jjj");
>
>
> @sorted = sort {nothe($a) cmp nothe($b)} @movies;
>
> foreach (@sorted) {
>    print $_."\n";
> }
>
> sub nothe{
>    $_[0]=~/\|(.*?)\|/;
>    $hlp = $1;
>    $hlp =~s/^The //;
>    return $hlp;
>
> }
> #################
>
>
>
> Michael
>
>




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

Date: Thu, 1 Feb 2001 09:32:51 -0600
From: "Steve Yates" <steve@teamITS.com>
Subject: Re: Using global var in subroutine
Message-Id: <t7j0d1krdt6gda@corp.supernews.com>

<dtbaker_dejanews@my-deja.com> wrote in message
news:95arjb$rd3$1@nnrp1.deja.com...
> take a close look at wherever $userCode is defined and make sure:
> - it is not inside another sub

    Sigh...isn't it amazing how you can look at code for hours and not see
the simple stuff?  The var IS set within a sub, and not declared beforehand.
The wild thing was that this program was used for a long time this way.  Did
older Perl versions make all vars global by chance?

    If I simply declare $userCode == "" at the beginning of the script that
will force it to be global right?

Thanks DT and Wyzelli!

Steve




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

Date: 1 Feb 2001 10:21:40 -0500
From: kj0 <kj0@mailcity.com>
Subject: v. 5.6.0 + CGI.pm: eval fails to trap errors
Message-Id: <95buu4$irr$1@panix3.panix.com>




The following snippet fails under v. 5.6.0 but not under v. 5.00404:
despite being wrapped around an eval, the die statement causes the
server to generate "Software error" message.  (The correct behavior
should be that the error is caught and handled exclusively by the
subsequent code; this is what happens under v. 5.00404.)

  #!/usr/local/bin/perl5.6.0 -w
  
  use strict;
  use CGI::Carp qw(fatalsToBrowser carpout);
  use CGI qw/:standard :html3/;
  $| = 1;
  
  eval {
    die "Error within eval\n";
  };
  
  my $error = $@;
  
  print header(-pragma => 'no-cache');
  print start_html ('-title'  => 'TEST PAGE');
  print hr;
  print strong "Caught error: $error\n";
  print end_html;


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

Date: 01 Feb 2001 10:40:42 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: v. 5.6.0 + CGI.pm: eval fails to trap errors
Message-Id: <m3snly76o5.fsf@mumonkan.sunstarsys.com>

kj0 <kj0@mailcity.com> writes:

> The following snippet fails under v. 5.6.0 but not under v. 5.00404:
> despite being wrapped around an eval, the die statement causes the
> server to generate "Software error" message.  

[...]

>   #!/usr/local/bin/perl5.6.0 -w
>   
>   use strict;
>   use CGI::Carp qw(fatalsToBrowser carpout);
>   use CGI qw/:standard :html3/;
>   $| = 1;
>   
>   eval {
>     die "Error within eval\n";
>   };
>   
>   my $error = $@;
>   
>   print header(-pragma => 'no-cache');
>   print start_html ('-title'  => 'TEST PAGE');
>   print hr;
>   print strong "Caught error: $error\n";
>   print end_html;


I tried running it from the command line and it worked
fine.  Did you try this?

Also, perhaps more version info is appropriate (OS, web
server, CGI.pm, etc.)

-- 
Joe Schaefer



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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