[16027] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3439 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 21 09:05:30 2000

Date: Wed, 21 Jun 2000 06:05:13 -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: <961592712-v9-i3439@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 21 Jun 2000     Volume: 9 Number: 3439

Today's topics:
    Re: [ Regexp ] Curious Behaviour of " last if /(match)/ (Tad McClellan)
        Consistently getting "(in cleanup) Can't call method "F <thunderbear@bigfoot.com>
    Re: Data Source Name <abe@ztreet.demon.nl>
        Environment variables <Andrew@constbank.spb.ru>
        Glob problem <Ave.Wrigley@itn.co.uk>
        Need Help <deqtran@hns.com>
    Re: Newbie question about subroutines... (Bart Lateur)
    Re: Newbie question about subroutines... <vhatz@ccf.auth.gr>
    Re: Perl Builder 2.0 for LINUX - Beta Available <gellyfish@gellyfish.com>
        Print in bold to file <igorleal@dcc.ufmg.br>
    Re: Print in bold to file <blah@nospam.com>
    Re: Proper Shopping Cart design.... (Bart Lateur)
        q: next pair key in a hash <zfido88@zr.ru>
        q: put hash into element of another hash <zfido88@zr.ru>
    Re: q: put hash into element of another hash <stephenk@cc.gatech.edu>
    Re: q: put hash into element of another hash (Tad McClellan)
        Setting locale failed. des3das@my-deja.com
        Should be simple, but... <jhall@jameshall.net>
    Re: Should be simple, but... <sweeheng@usa.net>
    Re: simple array question (Bart Lateur)
    Re: simple array question (Bart Lateur)
    Re: simple array question (Tad McClellan)
    Re: Simple brain picker <abe@ztreet.demon.nl>
    Re: Simple Question <tfm@sei.cmu.edu>
    Re: Simple Question (Tad McClellan)
    Re: Simple Question (Bart Lateur)
    Re: Suggestions for returning a range of values <abe@ztreet.demon.nl>
        system and exec 'holds' perl output omtslug@my-deja.com
    Re: system and exec 'holds' perl output <hakon.alstadheim@oslo.mail.telia.com>
    Re: Urgent help with non-blocking child process require nobull@mail.com
        Using a variable for subroutine calling. digit_jc@hotmail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Jun 2000 06:01:16 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: [ Regexp ] Curious Behaviour of " last if /(match)/ "
Message-Id: <slrn8l183s.uk.tadmc@maxim.metronet.com>

On 21 Jun 2000 08:29:45 +0100, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>On Tue, 20 Jun 2000 03:26:57 +0200 TheEx0rcist wrote:
>>>  Use my(). Don't use local().
>> 
>> The problem with my() is that you get warning messages with perl -w when you
>> use it inside loops ("my" variable masks earlier declaration in same scope).
>> 
>> For instance the following code produces the error message ::
>> --
>> my $a;
>> while(1) {
>>     my $a = ...
>> }
>> 
>
>No it doesnt.  The first 'my $a' is not in the same scope as the second.


And using local() to avoid a warning message is like turning
up the volume on the radio to "fix" the funny sound that
your car is making.

It does not "fix" anything. The car is still broken, you just
can't tell that it is still broken.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Jun 2000 14:53:43 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Consistently getting "(in cleanup) Can't call method "FETCH" ...
Message-Id: <3950BAD7.21A569B5@bigfoot.com>

I have written a small database loader with XML::Parser, GetOpt::Long,
Benchmark, DBI and DBD:Oracle under the ActiveState version of Perl 5.6
which works satisfactory, but consistently reports

	(in cleanup) Can't call method "FETCH" on an undefined value at
C:/Perl/site/lib/Win32/TieRegistry.pm line 1486 during global
destruction.

at the end of each execution.  

I have ->finish()ed all prepare/execute handles, and
commit/disconnected() the database handle, so I believe I have told
every part of DBI that the program is about to finish.  I do not believe
I am in any way working directly with the registry.

Is there a cure for this?

-- 
  Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Wed, 21 Jun 2000 14:19:20 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Data Source Name
Message-Id: <ihc1lsct8hbp7s16dspkbai65420hnlsfs@4ax.com>

On Tue, 20 Jun 2000 11:30:06 -0700, William Crites <wcrites@cis.ctc.edu>
wrote:

> Do you think it is possible to get names (DSN) from ODBC on NT Server? I
> want to have all name for records.
> Thanks

Look at the 'DataSources()' method in Win32::ODBC;

perldoc Win32::ODBC

-- 
Good luck,
Abe


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

Date: Wed, 21 Jun 2000 16:23:46 +0400
From: "Andrew Matveev" <Andrew@constbank.spb.ru>
Subject: Environment variables
Message-Id: <8iqc1l$sdt$1@arcom.rcom.spb.su>

I try to convert my shell-script on Solaris 2.6 into Perl (5.005).
I read my .profile and set Env variables like this:
@array= <FILE>;
foreach (@array)
{                                                
    ($name, $value) = split(/=/,$_);             
       $ENV{"$name"} = "$value";                 
} 

After that I call some sql and sh scripts that rise errors
because some env variables look like this (without substitution)
 $USR_PATH/tmp ( should be   /USR1/tmp)
$HOME/tmp  (should be /u/home/tmp) and so on.

How can I get right effect?
Thanks






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

Date: Wed, 21 Jun 2000 12:19:14 GMT
From: Ave Wrigley <Ave.Wrigley@itn.co.uk>
Subject: Glob problem
Message-Id: <8iqbrn$18m$1@nnrp1.deja.com>

I am having a problem with glob and single quotes in directory names.
Here is what I have done:

> ls -l "foo'bar"
total 0
-rw-------   1 online   other          0 Jun 21 12:55 foo
> cat
$dir = "\"foo'bar\"";
print "$dir\n";
print `ls $dir`, "\n";
print glob( "$dir/*" ), "\n";
> perl !$
perl glob.pl
"foo'bar"
foo

Unmatched "

I am not sure why the shell seems to be able to copy with the way I
have handled the single quote in the directory name (by wrapping it in
double quotes) in the shell itself, and in backticks, but not in glob.
Anyone have any ideas?

Ave.

--
Ave Wrigley,             mailto:Ave.Wrigley@itn.co.uk
ITN Online,              http://www.itn.co.uk/
ITN, 200, Gray's Inn Rd, tel: +44-207-430-4719
London, WC1X 8XZ, U.K.   fax: +44-207-430-4788


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 21 Jun 2000 08:04:33 -0400
From: "Dean Q. Tran" <deqtran@hns.com>
Subject: Need Help
Message-Id: <3950AF51.153E7CE1@hns.com>

hi,

please help.

I have file contains following line:

// Welcome home
// date: Tuesday April 5, 2000; 07:44:52
//
$$library( "/user/cat/read.catalog",,,,,,, @Keep );
$$library( "/user/dog/misc.catalog",,,,,,, @Keep );
$$library( "/user/frog/bye.catalog",,,,,,, @Keep );

I like to read this above file and have the variables assigned as:
$file1="/user/cat/read.catalog";
$file2="/user/dog/misc.catalog";
$file3="/user/frog/bye.catalog";

Thanks.

Dean



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

Date: Wed, 21 Jun 2000 10:39:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie question about subroutines...
Message-Id: <395798db.5742134@news.skynet.be>

Vlasis Hatzistavrou wrote:

>    I'd like to know if there is a way in Perl to laucnh different
>subroutines running at the same time. If this is not possible, should I
>use different programs? If so, how can I get themn to run at the same
>time? I use Windows NT4.0.

It sounds like you want threads. Or "fork". The new ActiveState perl is
supposed to support multi-threading and fork() emulation, but I've not
used it yet.

-- 
	Bart.


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

Date: Wed, 21 Jun 2000 13:48:55 +0300
From: Vlasis Hatzistavrou <vhatz@ccf.auth.gr>
Subject: Re: Newbie question about subroutines...
Message-Id: <39509D97.E982270@ccf.auth.gr>

Hi,


What I meant was if there is a way to:

call sub 1
call sub 2
call sub 3

and all 3 subroutines running at the same time.

The regular way is call sub1, wait for it to finish and then the next one is
called.

I want to launch them together because I want to make a metasearch engine
andthe searches in the different engines must happen at the same time because
otherwise it would take a lot of time to wait for one engine to finish, then
launch the other etc.

Thanks for the input.

"Rob - Rock13.com" wrote:

>
> I'm rather new to Perl but one sub can call another if that's what you
> mean - I suppose it can call itself too. Other than that the sub will
> run when the program tells it to.
> --

--
Vlasis Hatzistavrou,
Library of Physics & Informatics
Aristotle University of Thessaloniki




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

Date: Wed, 21 Jun 2000 11:40:22 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl Builder 2.0 for LINUX - Beta Available
Message-Id: <GQ145.505$My4.48742@news.dircon.co.uk>

On Tue, 20 Jun 2000 18:59:19 GMT, sty2999@my-deja.com Wrote:
> Hi,
> 
>> What are we saying here - that it *requires* 'wine' to install or run
> - well
>> then it isnt a linux application is it ?  I think they could do with
> a good
>> slashdotting over this ;-}
>>
> 
> Thanks for your feedback.
> 
> Yes, it requires Wine to run as it is compiled under Windows. However,
> it is specificially designed for Linux -- certainly not just enabling
> the Windows version using Wine.
> 
> Perhaps you could help me understand your objection to the use of Wine.
> 

Why should I install support for applications written for another OS
when I am installing an application which is purportedly for an OS I
already have?

> My understanding is that it runs maybe 10% slower than a native Linux
> application. Which does not seem a show stopper to me.
> 

Speed isnt an issue here particularly, memory might be though.

> Obviously it has a Windows look and feel...but then so do lots of
> native Linux apps, including for example, the Gnome desktop.
> 

I would disagree with that.  Gnome can be made to have window decoration
that is similar to Windows 95, it can also be made to have Window decoration
that is similar to MacOS or something else entirely but this is entirely
superficial.  The 'feel', the way that it works in use, is entirely different
IMO within the constraint that all windowing systems are going to be dealing
with largely the same kind of objects.  And of course people use other
window managers/desktop environments.

> I will freely admit that we have very little experience with
> Linux...have only been running it for a few months. However, we have
> had lots of requests for our product on that platform and this is the
> really the only practical way to do it.
> 

I think you are going to have to help me understand why this is the case.
What is wrong with porting your applications properly like everyone else
does ?

> Yes, the installation process and so forth is different than from other
> Linux apps, but as far as I can see, once the program is running it
> looks just like it would look if it were a native application.
> 

This appears to contradict what you say above with respect to Gnome.

> Corel has used Wine for its latest version of WordPerfect for Linux and
> has invested a lot in Wine...so my guess is that within the next year
> or so you will see more vendors using this strategy.
> 

Which is even sillier as there was a perfectly good version of WordPerfect
that didnt need to 'emulate' another OS.  And I dont see Netscape or Sun
doing this any time real soon now,  and quite frankly Oracle, Informix or
Sybase would laughed out of court if they tried to claim that you had to
use wine to run their products.  'wine' is a package that allows you to
run applications written for Windows on Linux - it isnt a platform for new
applications.


> It sounds as though that would make you unhappy...but if more
> applications are available on Linux, that makes it a more viable
> alternative to Windows...no?
> 

No.  *Better* applications might though.  Although of course some would
say that Linux isnt an alternative to windows because for that to be the 
case Windows would have to be able to do some of the things that Linux can.

Anyhow this has got nothing to do with Perl.  All I need is perl and vim.

/J\


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

Date: Wed, 21 Jun 2000 09:00:55 -0300
From: Igor Campos Leal <igorleal@dcc.ufmg.br>
Subject: Print in bold to file
Message-Id: <Pine.GSO.4.21.0006210855170.10978-100000@turmalina.dcc.ufmg.br>

	Hello all!!
	I have a question: Is there any way to write to file, a text file,
a bold text, like in HTML the command <B>???
	I'm with a work to do that some words need to be printed in bold.
	Somebody told me that there is a command like that \n, to a new
line, but I don't discovered which command it is!!!
	So, if someone knows anything about it, please reply me!!!
	[]'s

		/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
		\                                      /
		/           Igor Campos Leal           \
		\        Ciencia da Computacao         /
		/              DCC - UFMG              \
		\     e-mail:   igorleal@dcc.ufmg.br   /
		/	        igor@acesso.com.br     \
	        \             ICQ# 37936364            /
		/      				       \
		\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



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

Date: Wed, 21 Jun 2000 14:34:10 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Print in bold to file
Message-Id: <3950B642.1FE2437C@nospam.com>

Igor,

Igor Campos Leal wrote:
> I have a question: Is there any way to write to file, a text file,
> a bold text, like in HTML the command <B>??? I'm with a work to 
> do that some words need to be printed in bold. Somebody told me 
> that there is a command like that \n, to a new line, but I 
> don't discovered which command it is!!!

  A text file does not have any style format except, obviously, the end
of lines, otherwise it should not be a text file. ;)

  If you want to see bold text in your documents, you have to use a
formatted text viewer, just such as an HTML browser, that read a little
bit more complicated file than a simple text one, interpreting tags,
commands, macros or other things in order to display to you a bold text.

  There are a lot of programs of this kind, according to your OS you can
find your preferred.  Of course, maybe HTML browser could be a portable
and an easy solution.


	Best regards,
		Marco


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

Date: Wed, 21 Jun 2000 10:39:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Proper Shopping Cart design....
Message-Id: <395899c6.5976663@news.skynet.be>

eriks78@my-deja.com wrote:

>1) text file cart on server.

or in a dB.

>   cookie on client.
>   random number generator assigns unique id to cookie and to cart.
>   you modify your cart some how, it pulls the id out of the client
>     cookie and changes the corresponding text file.

>   i see file locking problems possible here.

Eh... how many browsers you expect to access the same showpping cart
file at the same time?

flock() should easily fix this problem.

Theoretically, file corruption IS possible if the server crashes while
writing to the file, or something else goes wrong while writing.

>2) text file cart on server.
>   same as above, but puts the cart number in as a hidden variable
>      into an html form and passes it around page to page.

And 3: put the session ID in the URL, in the URL following the URL of
your script:


http://your.server/your/path/to/script.cgi/sessionID/whatever/follows/next

In case you're wondering: "http://your.server/your/path/to/script.cgi"
is the URL of the script, and you'll see
"/sessionID/whatever/follows/next" appear in the environment variable
PATH_INFO ($ENV{PATH_INFO} in Perl).

-- 
	Bart.


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

Date: Wed, 21 Jun 2000 16:26:59 +0400
From: "Roman Chumakov" <zfido88@zr.ru>
Subject: q: next pair key in a hash
Message-Id: <8iqca6$stn$1@news.sovam.com>

A little trouble.

I have a big hash: $hash.

I have a key for this hash to retrieve: $key
its value is:
$keyvalue = $hash{$key}

But how can I know previous key in a $hash, that is previos $key?
And also, how to get next key?

it's like.... i have a book .. I know a page... I need to get next or prev
page.

Thx!
Roman




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

Date: Wed, 21 Jun 2000 14:12:45 +0400
From: "Roman Chumakov" <zfido88@zr.ru>
Subject: q: put hash into element of another hash
Message-Id: <8iq4eh$n6f$1@news.sovam.com>

How can I put one hash into element of another hash?

Like this:
my %h;
my %matrix;
$h{'id1'}= 'val1'; ..... ; $h{'idN'}= 'valN';

$matrix{'h'} = %h;
(how to make this works?)
I need to put whole hash %h into element 'h' of hash %matrix

Is there built-in functions for doing it? Or I need to make my own function
to do it?

Is any assumptions?

Thx,
Roman



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

Date: Wed, 21 Jun 2000 07:06:18 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: q: put hash into element of another hash
Message-Id: <3950A1A9.36252184@cc.gatech.edu>

Roman Chumakov wrote:

> How can I put one hash into element of another hash?
>
> Like this:
> my %h;
> my %matrix;
> $h{'id1'}= 'val1'; ..... ; $h{'idN'}= 'valN';
>
> $matrix{'h'} = %h;
> (how to make this works?)
> I need to put whole hash %h into element 'h' of hash %matrix
>
> Is there built-in functions for doing it? Or I need to make my own function
> to do it?
>
> Is any assumptions?
>
> Thx,
> Roman

Use a hash reference:
$matrix{'h'} = \%h;

Read perlref for details.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Wed, 21 Jun 2000 06:05:42 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: q: put hash into element of another hash
Message-Id: <slrn8l18c6.uk.tadmc@maxim.metronet.com>

On Wed, 21 Jun 2000 14:12:45 +0400, Roman Chumakov <zfido88@zr.ru> wrote:
>How can I put one hash into element of another hash?


You cannot put a hash into a hash element.

You can put a _reference_ to a hash in a hash element.


>Like this:
>my %h;
>my %matrix;
>$h{'id1'}= 'val1'; ..... ; $h{'idN'}= 'valN';
>
>$matrix{'h'} = %h;
>(how to make this works?)


   $matrix{'h'} = \%h;


>Is there built-in functions for doing it? Or I need to make my own function
>to do it?

   perldoc perlreftut

   perldoc perlref

   perldoc perllol

   perldoc perldsc


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Jun 2000 10:12:16 GMT
From: des3das@my-deja.com
Subject: Setting locale failed.
Message-Id: <8iq4dq$sa2$1@nnrp1.deja.com>

 I got this message when I tried to use perl.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "(null)"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").


Can someone tell me how I can correct it. I've tried FAQ's but I can't
find any reference to it.

Cheers

Duncan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 21 Jun 2000 12:21:48 GMT
From: James Hall <jhall@jameshall.net>
Subject: Should be simple, but...
Message-Id: <3950B3DA.3DA6A560@jameshall.net>

And it probably IS simple, however, it seems to be missing me. Here is
the problem:
I want the user to add items from a selection to an array. No problem.
What I can't figure out how to do is NOT add the item if it already
exists in the array-
EXAMPLE:

@array = qw(red white blue);

#The user selects 'green' and 'red' to enter into the array;
$green = param('green'); #where the form element 'green' has the value
'green'
$red = param('red'); #ditto
push(@array, $green);
push(@array, $red);

#Now the array has the following value
@array = qw(red white blue green red);

How do I keep an item from being added if it already exists, such as
'red' in this example? Thanks in advance, I've searched 3 O'Reilly
books, and several web searches to no avail...
James Hall



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

Date: Wed, 21 Jun 2000 20:55:21 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Should be simple, but...
Message-Id: <8iqdk1$ilh$1@mawar.singnet.com.sg>


James Hall <jhall@jameshall.net> wrote in message
news:3950B3DA.3DA6A560@jameshall.net...
> And it probably IS simple, however, it seems to be missing me. Here is
> the problem:
> I want the user to add items from a selection to an array. No problem.
> What I can't figure out how to do is NOT add the item if it already
> exists in the array-
> EXAMPLE:
>
> @array = qw(red white blue);

Use a hash instead. Suppose @array has a list of colours. Then:
  my %hash = map {$_ => 1} @array;

> #The user selects 'green' and 'red' to enter into the array;
> $green = param('green'); #where the form element 'green' has the value
> 'green'
> $red = param('red'); #ditto
> push(@array, $green);
> push(@array, $red);

Subsequently, instead of push(), just insert it into the hash by:
  $hash{$green} = 1;
  $hash{$red}   = 1;

> #Now the array has the following value
> @array = qw(red white blue green red);

If you still want the result in an array, do
  @array = keys %hash;

Hope that helps!

Swee Heng





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

Date: Wed, 21 Jun 2000 10:23:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: simple array question
Message-Id: <39559603.5014377@news.skynet.be>

Phil Sutcliffe wrote:

>> Friends don't let friends use symrefs.
>
>You have made it blatently obvious that you are no friend of mine, so why
>can't I use them!

Oh come one.

First of all, WHY do you want symrefs? There is NOTHING you can do with
a variable that you can't do with a hash element. Speedwise, there very
close, so that isn't an issue either. And look at MJD's 3 articles of
why this is a bad idea.

	http://www.plover.com/~mjd/perl/varvarname.html
	http://www.plover.com/~mjd/perl/varvarname2.html
	http://www.plover.com/~mjd/perl/varvarname3.html

Unless your aim is to write unmaintainable code... job security? (Yes, I
just finished reading <http://www.mindprod.com/unmain.html>)
	

Programmers insisting so hard on using symrefs, like you do, ought to be
fired, IMO. Honestly.

-- 
	Bart.


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

Date: Wed, 21 Jun 2000 10:25:53 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: simple array question
Message-Id: <395697fb.5517985@news.skynet.be>

Phil Sutcliffe wrote:

>I have achieved the desired result using eval.
>
>eval "(" . join(",",@names) . ") = \@fields;";
>
>I would still like to know if this can be done using references.

You can put them in a hash.

	@data{@names} = @fields;

-- 
	Bart.


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

Date: Wed, 21 Jun 2000 05:49:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: simple array question
Message-Id: <slrn8l17df.r6.tadmc@maxim.metronet.com>

On Wed, 21 Jun 2000 09:20:39 +1000, Phil Sutcliffe <ils@gil.com.au> wrote:
>"Tad McClellan" <tadmc@metronet.com> wrote in message
>news:slrn8kuu0u.gc2.tadmc@magna.metronet.com...
>>
>> What did I say that is "blatently" unfriendly?
>>
>
>Perhaps I'm over sensitive, 


Perhaps.


>but I don't take too kindly to being patronised


You had already been told about how "Symbolic references" are
bad, and given a way of doing it without them.

But you were back insisting that we tell you how to use them.

So I reiterated that using symrefs is bad...


>and smart comments like
>
>>You don't wear a seat belt in the car either, do you?


 ... like not wearing a seat belt.

Maybe I should have said "you like living dangerously?" instead.

Sorry if you took offense, but if shocking you is what it takes
to get you to eschew symrefs, then it would be worth it.

(and symrefs are disallowed under "use strict" which every
 Perl program should have. "use strict" is Perl's "seat belts"
)


The "friends don't let friends use symrefs" analogy is very
applicable here.

When a drunk friend asks for his car keys, a true friend will
not give them to him.

The drunk (I am NOT insinuating that you are a drunk!) will
likely get mad that we won't give him the keys, but withholding 
them is The Right Thing To Do.

The "use a hash instead of symrefs" advice is analogous to 
"take a cab instead of driving drunk".

But if the drunk knows where the keys are (in the "Symbolic
references" section in perlref.pod) he can go get the keys
himself and drive away anyway.


Symbolic references are evil. Don't expect us to help you be evil.


>In my orginal post I greatly simplified my example in the hope I would get a
>simple answer (which as yet, is still not forthcoming). 


   perldoc perlref


>The fact that it
>will not be a trivial matter to change the code is because my need is much
>more complex then I have described here (and in fact, would take great
>lengths to describe here). I sincerely apologise for not making myself clear
>about exactly why it would be "non-trivial" to change to a hash in my
>previous post.


We cannot suggest workarounds if we do not know the situation.


>My original question still remains.
>
>>Consider this.
>>
>>@fields=("GBH","QLD","1234");
>>
>>@names=("\$company","\$state","\$postcode");
>>
>>Is there a way to get "GBH" into variable $company without using loops.


{ local $" = ',';
   eval "(@names) = (@fields)";
}


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Jun 2000 14:58:30 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Simple brain picker
Message-Id: <cre1lss9a676eq7jbfvlal1tcbsh1bsemg@4ax.com>

On Wed, 21 Jun 2000 04:46:24 GMT, Igor Mack <sushi38@my-deja.com> wrote:

> What is the most proper way of doing this:
> 
> $first_five = substr($serialno, 3, 3);
> $version = substr($first_five, 0, 1) . "." . substr($first_five, 1, 2) ;

	$version = join '.', (unpack "A3A1A2", $serialno)[1,2];

It leaves out the strange varname :-)

-- 
Good luck,
Abe


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

Date: Wed, 21 Jun 2000 07:21:28 -0400
From: Ted Marz <tfm@sei.cmu.edu>
Subject: Re: Simple Question
Message-Id: <3950A538.23762A3B@sei.cmu.edu>

IF your scripts are in the appropriate place
(cgi-bin directory of your web directory)

AND your scripts have the execute attribute set
(chmod 755 <scriptname>)

THEN you have done the appropriate stuff for your scripts to work.

That being said, what is happening is that the web server doesn't
understand what kind of file you are asking for on your ISPs server. 
That is, it hasn't got a MIME time associated with it, so it thinks it
is plain text, and serves the file, rather than executing the file and
serving the output.

On the default install of Apache (I know, you aren't using Apache), the
default CGI extension is .cgi, not .pl  If someone hasn't "corrected"
the configuration files of the server, if you try and serve up a .pl
file, you get exactly the behavior mentioned.

So, do two things:
  1) mail the webmaster of your ISP and find out what their recognized
CGI file extension is.
  2) Until you get the reply, try it as a .cgi file (just rename it)

Ted

mxusstmm wrote:
> 
> Sorry about the double post, My clock was set back.
> Didn;t want to get lost in the crowd of yesterday.
> 
> Just picked up PERL so help would be appriciated with this question.
> I just finished PC magazine's PERL 5.0 CGI Web Pages book.
> 
> Here's my problem:
> 
> I uploaded my PERL scripts to my ISP.
> I followed all of thier directions regaring cgi file location and the
> #!usr/bin/perl line, but...
> 
> When I use the GET method to call the pl file, I just see the whole script
> in the browser like unformatted text.When I use POST from a form, my browser
> wants to download.
> 
> I've tried to duplicate the error on my server, by turing off access to
> PERL, but I just get 404 errors.
> Can't seem to duplicate whats going on online.
> 
> I'm running O'Reily's WebSite server on an NT box to test the stuff, but my
> ISP uses ZEUS on Sun boxes.
> 
> Has anyone had this set of problems happen to them?
> Is this my problem or my ISP?


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

Date: Wed, 21 Jun 2000 06:08:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple Question
Message-Id: <slrn8l18hl.uk.tadmc@maxim.metronet.com>

On Tue, 20 Jun 2000 04:36:55 -0700, mxusstmm <mxusstmm@xoommail.com> wrote:
>Just picked up PERL so help would be appriciated with this question.
>I just finished PC magazine's PERL 5.0 CGI Web Pages book.
>
>Here's my problem:
>
>I uploaded my PERL scripts to my ISP.

>When I use the GET method to call the pl file, I just see the whole script
>in the browser like unformatted text.When I use POST from a form, my browser
>wants to download.


You do not have a Perl question.

You have a server-setup question.

You will have better luck asking in a newsgroup that has
something to do with servers, such as:

      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Jun 2000 12:24:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Simple Question
Message-Id: <3950b2ec.304833@news.skynet.be>

mxusstmm wrote:

>I uploaded my PERL scripts to my ISP.
>I followed all of thier directions regaring cgi file location and the
>#!usr/bin/perl line, but...
>
>When I use the GET method to call the pl file, I just see the whole script
>in the browser like unformatted text.

It looks like a permissions problem. Does your cript have "x" permission
fopr everybody? Or otherwise, your server may not recognize the ".pl" as
a valid extension for CGI scripts. Try ".cgi". 

For the complete checklist, see the Idiot's Guide to Solving Perl CGI
Problems,
<ftp://ftp.cs.uu.nl/mirror/CPAN/doc/FAQs/cgi/idiots-guide.html>

And the CGI links list at <www.perl.com> is nice, too.

-- 
	Bart.


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

Date: Wed, 21 Jun 2000 13:20:23 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Suggestions for returning a range of values
Message-Id: <iu81ls8h4gmcuh8rg2hu1ft69005inc0ua@4ax.com>

On Tue, 20 Jun 2000 17:33:23 GMT, chadbour@wwa.com (James Weisberg)
wrote:

> Hello,
Hi,
> 
 ...
>    $ fetch object1,object2... 05012000-05072000,06012000-06072000 
> 
>    would, for example, fetch records for the first week in May 2000 and 
> the first week in June 2000. What I would like is a function which splits 
> that argument above and creates an array with an element for each unique 
> date. In this case there would be 14 date elements in the array for the 
> two-week period given. 
>    The code to generate the date sequences will get a bit tricky for
> crossing month/year boundaries, like 12151999-01152000, but that is 
> something I can handle myself.

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

#create a list of dates, from a list of ranges MMDDYYYY-MMDDYYYY
use Time::Local;

sub range_list {
	my(@ranges) = @_;
	my @list;
	
	foreach my $range (@ranges) {
		push @list, $range and next unless $range =~ /-/;
		
		my($fdate, $ldate) = split /-/, $range;
		
		my ($m, $d, $y) = unpack "A2A2A4", $fdate;
		my $fts = timelocal(0, 0, 0, $d, $m-1, $y);

		($m, $d, $y) = unpack "A2A2A4", $ldate;
		my $lts = timelocal(0, 0, 0, $d, $m-1, $y);
			
		for (my $cts = $fts; $cts <= $lts; $cts += 24*60*60) {
			my @cdate = localtime $cts;
			push @list, sprintf "%02d%02d%04d", 
				$cdate[4]+1, $cdate[3], $cdate[5]+1900;
		}
	}
	
	return @list;
}

my @r_list = range_list(
	'12151999-01152000', 
	'05012000-05072000', 
	'06212000');

print "List:\n", map "\t$_\n" => @r_list;

__END__
		
-- 
Good luck,
Abe


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

Date: Wed, 21 Jun 2000 10:04:44 GMT
From: omtslug@my-deja.com
Subject: system and exec 'holds' perl output
Message-Id: <8iq3vn$s5m$1@nnrp1.deja.com>

Hi!!
I have some strange problems with my perl cgi-bin script.
In the end in the script after generating the html reply I
execute a bash script but when doing this the webbrowser times out
not viewing my result...
The page shows up when the script is done (can be a very long time)

If anyone have some ideas please post.
I just added the autoflush of stdout but it didn't help.

If I skip the last exec the result comes immidiately but doing it
'holds' the browser until the bash script is finished.
(same result with system)

Thanks in advance
 Stefan


#excerpts
$forminfo = <STDIN>;
$forminfo =~ s/&/\n/g;

$kit = GetInputValueStr("is_Kit_str");
$sslabelfiles = GetInputValueBool("ss_Label_cb");
$ssuselabel = GetInputValueStr("ss_Label_str");

select((select(STDOUT), $| = 1)[0]);

if ( $buildseqfile ne "" ) {
  print "Content-type: text/html \n\n";
  print "<html><head>";
  print "<title>Confirm</title>";
  print "</head>";
  print "Thank you! Your input has been processed and the";
  print "build is started. Your build id is: ".$buildsetupfile;
  print "<p>Links to your setup file and log file:<br>";
  print "<a
href=/buildset/".$buildsetupfile.".sh>".$buildsetupfile.".sh<br>";
  print "<a
href=/buildset/".$buildsetupfile.".log>".$buildsetupfile.".log</p>";
  print "</body></html>";
}

#generating bash shell file here.
#and then

exec "/Cygnus/cygwin-b20/H-i586-
cygwin32/bin/bash.exe ".$buildsetupfile.".sh ".$buildsetupfile.".log
2>&1";

exit(0);




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 21 Jun 2000 07:25:17 -0300
From: Hakon Alstadheim <hakon.alstadheim@oslo.mail.telia.com>
Subject: Re: system and exec 'holds' perl output
Message-Id: <m0vgz31gc2.fsf@alstadhome.cyberglobe.net>

omtslug@my-deja.com writes:

> Hi!!
> I have some strange problems with my perl cgi-bin script.
> In the end in the script after generating the html reply I
> execute a bash script but when doing this the webbrowser times out
> not viewing my result...

Ok, here is how you might reaon about this problem:

Your webserver is obviously waiting, either for the CGI-apps STDOUT
to close, or for the CGI app to terminate. Try to do:

close(STDIN);close(STDERR);close(STDOUT);


and see if that helps. 


a) If it does, your know you're on the right
track. Then you should go back to the script and replace one or more
of the close statements with something like:

open(STDERR,">/writeable-dir/unique-file-name");

The last step can be rather complex to get right, search on deja for
tempfile or 'temporary file' or 'scratch file'.

b) If it does not, look up the functions 'fork' and exec. If you need
this, you most certainly will have to use it in conjunction with a).

 


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

Date: 20 Jun 2000 17:54:47 +0100
From: nobull@mail.com
Subject: Re: Urgent help with non-blocking child process required
Message-Id: <u9snu8xpgo.fsf@wcl-l.bham.ac.uk>

salim@cygnos.com crossposts wildly:
 
> Below is a complete code for two snippets (snippetA.pl and snippetB.pl) that
> summarize a problem i haven't been able to resolve. Your help and feedback
> is badly needed. As you could probably tell, sinppetA forks open a child
> process connecting to the child's STDIN. Subsequently, snippetA writes dummy
> data to snippetB's STDIN. My problem is that when this happens, snippetA
> waits until snippetB returns. What I want to be able to do is let A to
> continue to execute the loop (hence fork/execing two or more children)
> without waiting for any of them to return. so far I haven't had any luck
> doing that. Could you please have a look and let me know what is that I am
> doing wrong!

OK I haven't tested this but here's my theory...

When you open(FILEHANDLE) and FILEHANDLE is already open this does an
implicit close(FILEHANDLE).

When you close(FILEHANDLE) and FILEHANDLE is a pipe to/from a child
process this does an implicit waitpid().

Solution: use one filehandle per child.

BTW: What was your module-related question again?  I seem to have
missed it.

BTW2: Check to see if your news admin has been dead for the last five
years, comp.lang.perl does not exist.

BTW3: How have you managed to miss the message that putting "Urgent
help" in your subject line just angers people around here?

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


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

Date: Wed, 21 Jun 2000 11:17:10 GMT
From: digit_jc@hotmail.com
Subject: Using a variable for subroutine calling.
Message-Id: <8iq87d$uqq$1@nnrp1.deja.com>

Hi!

I know you can do this:

$var = "routine";

$answer = &$var();
print "$answer\n";

sub routine {
   return "Yo!";
}

But what if you are trying to call an object method?

$ref = new Module ();

$var = "routine";

This doesn't work:
$answer = $ref->$var();

sub routine {
   $ref = shift;
   return "Yo\n";
}

Obviously this is a poor example, but I hope you get my drift.
Can it be done? In that case, how?

Thanks in advance

Johan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


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