[12511] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6111 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 23 17:07:25 1999

Date: Wed, 23 Jun 99 14:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 Jun 1999     Volume: 8 Number: 6111

Today's topics:
    Re: A foreach question (Larry Rosler)
        Capturing a Stop event from the Browser mattm@sunbelt.nawcad.navy.mil
    Re: deleting whitespace (Larry Rosler)
        Diff tools? (Lee Mulleady)
    Re: dynaloader bobnospam@xerxes.math.umn.edu
    Re: dynaloader francesc_guasch@my-deja.com
    Re: Having an external script modify %ENV? (Andrew Khazanov)
    Re: HTML Redirection (Jaime)
        Is there perl code equivalent of unix login program sabhay@aol.com
    Re: Modify @INC? (Dave Cross)
    Re: Module Path Problem <emschwar@rmi.net>
    Re: More fun with Hashes of Lists... <coers@evsx.com>
        newbie: Grab URL into PERL? <radmoose@bigfoot.spam.spam.spam.nospam.spam.com>
    Re: NT - Server Up time <uucon@my-deja.com>
    Re: Perl Alphanumeric Sort? (Larry Rosler)
    Re: Perl in Win32 <gorgonous@spiretech.com>
    Re: PerlScript vs JScript vs VBScript for WSH (Jan Dubois)
        problem with cgi script <urza@arn.netDONT_SPAM>
    Re: problem with cgi script <upsetter@ziplink.net>
    Re: simple <cassell@mail.cor.epa.gov>
        Upload multiple files by broswer <tanya@i-cable.com>
    Re: use strict question (Bart Lateur)
    Re: use strict question (H. Camphausen)
    Re: Using Boulderio in CGI.pm syurman@spatialfocus.com
    Re: Viral matters [completely off-topic] <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 23 Jun 1999 12:27:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A foreach question
Message-Id: <MPG.11dad5087325be79989c35@nntp.hpl.hp.com>

In article <7kra9n$2f6$1@aub.eurobell.net> on Wed, 23 Jun 1999 19:53:50 
+0100, Troy Knight <troyknight@troyknight.eurobell.co.uk> says...

[Answer placed after question, and irrelevent stuff stripped.]

> <photoguy@my-deja.com> wrote in message news:7kr8iv$ebn$1@nnrp1.deja.com...
> > I'm reading a text file into an array, then using foreach to loop
> > through the array looking for a specific pattern.  Once I find the
> > pattern I want to look at the next element in the array to check for 2
> > other patterns.  Sample below:
> >
> > open (FILENAME, "somefile");

Where is the test for failure?

> > @file_lines = FILENAME;

This is not what you mean.  Before posting, you should at least try the 
program and see what it does!

> > foreach $file_line (@file_lines)
> > {
> >   # check for first pattern
> >   # if matched, increment the element $file_line points to
> >
> >   # check for patterns in $file_line
> > }
> >
> > My question is if I increment the element that $file_line is pointing
> > to, will that effect the 'foreach' sequencing? (i.e. the next time
> > through the loop after incrementing $file_line to say 2), will foreach
> > return element 2 or 3 of @file_lines?

$file_line is not an integer index that can be incremented.  It is an 
alias for each element of the array in turn.

> The loop will carry on as normal!

Sure it will, because changing the value of $file_line doesn't affect 
the next iteration.  But it still won't do what he wants!

Here is something that works.  If he must process an array, he will need 
a state flag for remembering the previous match when iterating in the 
foreach loop.


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

while (<DATA>) {
    next unless /foo/;
    defined($_ = <DATA>) or die "Unexpected end-of-file\n";
    /baz/ and print "Matched baz in $_";
}
__END__
zilch
foobar
bashbazbam
zorp
barfoo
bashBAZbam
quux
foofuraw
second baz match
foo with no line following it


Output:

Matched baz in bashbazbam
Matched baz in second baz match
Unexpected end-of-file

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


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

Date: Wed, 23 Jun 1999 19:02:36 GMT
From: mattm@sunbelt.nawcad.navy.mil
Subject: Capturing a Stop event from the Browser
Message-Id: <7krb04$fd5$1@nnrp1.deja.com>

Is there any way for my cgi (Perl) script to capture when the user
clicks the stop button?  Currently when the user clicks the stop button,
the Perl script keeps running, as well as the child processes it
created.  We have a Netscape Enterprise server running on a Sun
Utlrasparc running solaris.  I would like to be able to kill the process
after the user clicks the stop button, but I'm not sure how...  Any help
would be appreciated.  Thanks.

Matt Menard


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 23 Jun 1999 12:04:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: deleting whitespace
Message-Id: <MPG.11dacf91634a4fdf989c34@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <6N9c3.19580$5a.24993@news20.bellglobal.com> on Wed, 23 Jun 
1999 18:34:42 GMT, Marc Bissonnette <dragnet@internalysis.com> says...
> In article <P9Ub3.3018$I72.384814@nnrp1.ptd.net>, tfiedler@ptd.net says...
> >
> >how do i delete whitespace or for what its worth any junk on a line?
> 
> $line =~ s/ //;

That deletes the first space character only.

Why not let perlre and the FAQ answer the question, as three other 
people have already suggested? 

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


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

Date: Wed, 23 Jun 1999 20:05:32 GMT
From: lemull@unx.sas.com (Lee Mulleady)
Subject: Diff tools?
Message-Id: <37711fdb.689542984@newshost.unx.sas.com>

Does anyone know of a utility that can be used in Perl to compare two
files and identify differences between the two (a "diff" tool) ?  The
one other requirement is that it will run in either a UNIX or NT
environment.

TIA,

Lee Mulleady

lemull@unx.sas.com



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

Date: Wed, 23 Jun 1999 14:31:07 CDT
From: bobnospam@xerxes.math.umn.edu
Subject: Re: dynaloader
Message-Id: <1999Jun23.143107@xerxes.math.umn.edu>

In article <Pine.GSO.4.02A.9906230830220.1698-100000@user2.teleport.com>, Tom Phoenix <rootbeer@redcat.com> writes:
|> On Wed, 23 Jun 1999 francesc_guasch@my-deja.com wrote:
|> 
|> > I'm trying to install a module and it complains this way:
|> > install_driver(mysql) failed: Can't load
|> > '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: File not
|> > found at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
|> 
|> Are you using the standard installation sequence of 'perl Makefile.PL',
|> 'make', 'make test', 'make install'? After which of those commands does
|> this message show up?

Here is my analog, after make and make install of DBI and 
Msql-Mysql-modules-1.2200:

++++++++++
perl: can't resolve symbol 'msqlErrMsg'
install_driver(mSQL) failed: Can't load '/usr/local/lib/perl5/site_perl/5.005/i686-
linux/auto/DBD/mSQL/mSQL.so' for module DBD::mSQL: Unable to resolve symbol at /usr
/local/lib/perl5/5.00503/i686-linux/DynaLoader.pm line 169.

 at (eval 1) line 3

 at ./csctest.pl line 19
++++++++++

Looking at line 169, it complains about the error actually being traceable to
"the initialisation C code of the extension XS file."  Que?  The installation
_seemed_ to go smoothly, on linux 2.0.36 with Perl 5.00503.

Thanks for your time.

Chris
bob at math dot umn dot edu


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

Date: Wed, 23 Jun 1999 19:45:58 GMT
From: francesc_guasch@my-deja.com
Subject: Re: dynaloader
Message-Id: <7krdhj$ggv$1@nnrp1.deja.com>

In article
<Pine.GSO.4.02A.9906230830220.1698-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Wed, 23 Jun 1999 francesc_guasch@my-deja.com wrote:
>
> > I'm trying to install a module and it complains this way:
> > install_driver(mysql) failed: Can't load
> > '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: File
not
> > found at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
>
> Are you using the standard installation sequence of

I tried using cpan and manually

> 'perl Makefile.PL',
> 'make', 'make test', 'make install'? After which of those commands
does
> this message show up?

make test


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 23 Jun 1999 19:46:20 GMT
From: akhazano@oacis.com (Andrew Khazanov)
Subject: Re: Having an external script modify %ENV?
Message-Id: <37743986.69506154@news.isp.net>

On 22 Jun 1999 20:09:11 -0700, in comp.lang.perl.misc you wrote:

>Andrew Khazanov <akhazano@oacis.com> writes:
>
>> Exactly.  I want a _shell_ script called by Perl to modify _Perl's_
>> environment.
>
>Another approach is to modify the shell script to, rather than setting the
>variables, print out the variable settings

I didn't want to do that because these scripts will still be used by
hand, and there are quite a few of them.  What I think I'll end up
doing is a bit different -- I'll just create a ksh process that I'll
be able to interact with (using IPC::Open2), and feed it commands.
This way I can call those scripts using the '.', and the environment
variables will persist.  I just hope I won't run into problems with
buffering (but a simple example I've tried works more or less okay).

>Whether that's easier depends on the situation.



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

Date: Tue, 22 Jun 1999 08:32:42 +0300
From: boo@foo.bar (Jaime)
Subject: Re: HTML Redirection
Message-Id: <boo-2206990832420001@meg.weizmann.ac.il>

In article <7kmlbp$q06$1@nnrp1.deja.com>, bandhunt@my-deja.com wrote:

> I was hoping someone could tell me how to
> redirect HTML using Perl/CGI.

from perldoc CGI:

print $q->header(-Refresh=>'10; URL=http://www.capricorn.com'); 

--
 Dr Jaime Prilusky                | lsprilus@weizmann.weizmann.ac.il
 Head Bioinformatics Unit         | lsprilus@bioinformatics.weizmann.ac.il
 Dep. of Biological Services      |
 Weizmann Institute of Science    | fax: 972-8-9344113
 76100 Rehovot - Israel           | tel: 972-8-9343456

 info URL http://bioinformatics.weizmann.ac.il/jaime_prilusky.html


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

Date: Wed, 23 Jun 1999 20:07:29 GMT
From: sabhay@aol.com
Subject: Is there perl code equivalent of unix login program
Message-Id: <7krepn$h3k$1@nnrp1.deja.com>

Hello,

has anyone written login program in perl (equvalent of unix login) ?

AS



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 23 Jun 1999 19:07:40 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Modify @INC?
Message-Id: <37713056.2233785@news.demon.co.uk>

On Wed, 23 Jun 1999 18:03:40 +0200, Marco Anstett
<marco.anstett@okay.net> wrote:

>Hello,
>
>I trying to add new directory to @INC while booting my Linux. To do so I
>wrote a sort script. When finished, this script prints out the data in
>@INC. At this time all directories are in @INC. But when I login an
>write the following line perl -e 'print @INC;', the directry I added is
>gone.
>
>What must I do to keep the new directory permanent in @INC.

You could set the environment variable PERL5LIB to the extra
directories.

hth,

Dave....
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: 23 Jun 1999 13:33:09 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Module Path Problem
Message-Id: <xkf7loun24q.fsf@valdemar.col.hp.com>

Craig Ciquera <craig@mathworks.com> writes:
> The beginning of your script should look like:
> 
> #!/usr/local/bin/perl
> 
> BEGIN {
>                push(@INC,<SOME_DIR>);
> }
> 
> where <SOME_DIR>  is the actual name of a directory.

Better it should be:

#!/path/to/perl -w
use strict;
use lib "SOME_DIR";
use mymodule;

We have FAQs for a reason, doncha know.

-=Eric


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

Date: Wed, 23 Jun 1999 14:19:00 -0500
From: John Coers <coers@evsx.com>
Subject: Re: More fun with Hashes of Lists...
Message-Id: <37713324.D254599@evsx.com>

Mitch wrote:
> 
> If I have a hash of a list like:
> 
> $foo{coke} where the coke array contains, sucks bites rules.  How can
> I easily append an element to the end of the coke array?  I know I can
> add an element like $foo{coke}[3] = "dominates";  However, can I add
> dominates to coke in a form like I just mentioned without knowing what
> size the array is?  Or do I need to get the array's size?  If so, how?
> 
> Thanks, mitch

push @{ $foo{coke} },'dominates';


-- 
**********************************************************************
*  John Coers                               EVSX, Inc.               *
*  coers@evsx.com                           11612 FM 2244            *
*  voice: (512) 421 - 2165                  Suite 200                *
*  fax:   (512) 263 - 0795                  Austin, Texas 78733      *
**********************************************************************


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

Date: Wed, 23 Jun 1999 20:05:48 GMT
From: "R. Moose" <radmoose@bigfoot.spam.spam.spam.nospam.spam.com>
Subject: newbie: Grab URL into PERL?
Message-Id: <w6bc3.412$_P.3767679@nnrp2.ni.net>

Please forgive me if this post is in the wrong area or seems a bit
trivial....

My problem is:

I want to grab the calling URL and parse it inside of PERL.

For example, the page at http://www.xxx.yyy/books/bn/perl/index.shtml calls
a PERL script.  The script should be able to get the entire URL in and then
parse it into separate, um, subdirectories and variables like...

    MainURL = http://www.xxx.yyy/books/bn/perl/index.shtml
    FirstDir = books
    SecondDir = bn
    ThirdDir = perl
    PageName = index.shtml
    WebSite = www.xxx.yyy

This is needed so I can setup a "site map" like:

    YOU ARE HERE >> BOOKS >> BN >> PERL

I need it to handle multiple levels of subdirectories and covert the lower
case text to upper case.  But the main part that has me stuck is getting the
full URL into the PERL script.

Can anyone suggest some books or a webpage that would assist me in doing the
above task?   I am not looking for "Learn PERL in 21 seconds", but I do
learn best from example.

Thank you for your assistance.

R. Moose




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

Date: Wed, 23 Jun 1999 19:06:37 GMT
From: Ryan Corder <uucon@my-deja.com>
Subject: Re: NT - Server Up time
Message-Id: <7krb7k$fgr$1@nnrp1.deja.com>

In article <377114DE.E3866AED@netscape.com>,
  dave keefer <davidk@netscape.com> wrote:
> c:\net server statistics
>
> i think.
>
> mirak63@yahoo.com wrote:
>
> > Hello,
> >
> > Is there a way in Perl to be able to determine the time
> > and date that an NT server came up?
> >
> > Thanks,
> > Karim Wall
>
>

That would be c:\net statistics server

Ryan


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 23 Jun 1999 11:59:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Alphanumeric Sort?
Message-Id: <MPG.11dace5468f7485c989c33@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7kr6hq$df8$1@nnrp1.deja.com> on Wed, 23 Jun 1999 17:46:38 
GMT, doug_johnston@my-deja.com <doug_johnston@my-deja.com> says...
> I'm looking to do a sort on an array that
> contains data somewhat like this -
> @letter_nums = ("A4","A2","A1","A3");
> 
> I use the following code to sort it into a temp
> array for later processing -
> @temp1 = sort by_values (@letter_nums);
> 
> sub by_values
> {
>     ($a cmp $b)
> }
> 
> It's a little more complex than that, but
> basically it works whenever I want to sort only
> numbers or letters, but when sorting this, it
> doesn't seem to work.  I would expect @temp1 to
> contain ("A1","A2","A3","A4") after the sort, but
> it ends up being just the same as it was when it
> went in.  This just doesn't make sense to me so
> I'm hoping someonw else out there has experienced
> this and can help me.  Thanks

Short answer:  I don't believe you!

Long answer:  This works exactly as expected.  Can you provide a small 
program in which it doesn't?  Here is my program in which it does work:

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

my @letter_nums = ("A4","A2","A1","A3");

my @temp1 = sort by_values (@letter_nums);

print "@temp1\n";

sub by_values
{
    ($a cmp $b)
}
__END__

Output:

A1 A2 A3 A4

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


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

Date: Wed, 23 Jun 1999 20:34:24 GMT
From: Isaac <gorgonous@spiretech.com>
Subject: Re: Perl in Win32
Message-Id: <3771442A.CA2BDA20@spiretech.com>

Spud wrote:
> For some reason when I try to execute my perl programs in Windows a black
> DOS-like screen comes up for a second and then dissappears. I'm running
> ActivePerl 517. Help, please!

Win32 Perl is run from DOS. When you run your script, it brings up a DOS shell
and executes the script. When it's done, it closes the window.

My suggestion is that you run scripts from a DOS window instead of through run
or whatever it is that you're using. That way it won't just close immidiately.

-- 
"Not everything that can be counted counts,
and not everything that counts can be counted."
- Albert Einstein

http://www.spiretech.com/~gorgonous/aboutme/


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

Date: Wed, 23 Jun 1999 21:04:46 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: PerlScript vs JScript vs VBScript for WSH
Message-Id: <37732d37.4763920@news3.ibm.net>

[mailed & posted]

"Sangjin Han" <truejaws@bbs.para.co.kr> wrote:

>I read a sample wsh vbscript for printing Environment variables.
>
>-------------------------------------
>' VB Script
>Set WShShell = WScript.CreateObject("WScript.Shell")
>
>For Each strTemp In WShShell.Environment
> WScript.Echo strTemp
>Next
>-------------------------------------
>
>And I could write an equivalent WSH-JScript source easily.
>-------------------------------------
>// Java Script
>WShell = WScript.CreateObject("WScript.Shell");
>
>Envs = new Enumerator( WShell.Environment );
>for( Envs.moveFirst(); !Envs.atEnd(); Envs.moveNext())
>{
> WScript.Echo( Envs.item() );
>}
>-------------------------------------
>
>But I could not write the PerlScript version.
>
>I hope the perl version does not use $ENV variable.

I have no idea why you don't want to use $ENV in the PerlScript version.
It is much faster than the additional object. It is only needed in VBS and
JS because *they* don't have $ENV.

But if you are only trying to compare identical code in different
languages, here it is:

#-----------------------------------------------------------------
my $WShShell = $WScript->CreateObject("WScript.Shell");
foreach my $strTemp (Win32::OLE::in($WShShell->Environment)) {
    $WScript->Echo($strTemp);
}
#-----------------------------------------------------------------

The only tricky thing is the call to Win32::OLE::in(). PerlScript always
loads the Win32::OLE module upon startup automatically, but doesn't import
any of the functions for you. Therefore I used the fully qualified name.

-Jan


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

Date: Wed, 23 Jun 99 20:03:32 GMT
From: "Urza" <urza@arn.netDONT_SPAM>
Subject: problem with cgi script
Message-Id: <37713cef@news.usenetnews.org>

I am having a small problem with a cgi message board i am writing i have
narrowed down the error but don't know why it isn't working.

the line is:

@threads=<*.mes>;

It works fine on my win98 machine and fine from the linux  prompt, but won't
work when invoked from the browser.  anyone know why???


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

Date: Wed, 23 Jun 1999 20:18:33 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: problem with cgi script
Message-Id: <tibc3.1110$7X1.286741@news.shore.net>

Urza <urza@arn.netDONT_SPAM> wrote:
: the line is:

: @threads=<*.mes>;

: It works fine on my win98 machine and fine from the linux  prompt, but won't
: work when invoked from the browser.  anyone know why???

You're probably not in the same working directory when you run your script
as a CGI. Either specify the full path or do a chdir prior to looking for
the messages.

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Wed, 23 Jun 1999 13:50:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: simple
Message-Id: <377148A2.15A87F5E@mail.cor.epa.gov>

Raj wrote:
> 
> when i use
> system("ls a* > file1");
>  in my CGI script it's listing the entire paths into the txtfile 'file1'
> 
> whereas when i run the same ls command at the unix prompt, i get only
> the filename listing into 'file1' , which is what i want.

Not that unusual.  Webservers don't have the same environment as
users, and that can include different versions of the standard
utilities (not to mention a total lack of access to some utilities,
for obvious reasons).
 
> What do i need to do in my system command then?

You could: 
[1] read the docs for your webserver and find out;
[2] ask the web admin politely and maybe she'll tell you;
or
[3] re-write this in Perl so you don't have to use a system()
call and an external program.  See the docs on opendir(),
readdir(), and closedir().  These give you a lot more
flexibility too.

HTH, 
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 21 Jun 1999 22:10:46 +0800
From: Tanya <tanya@i-cable.com>
Subject: Upload multiple files by broswer
Message-Id: <376E47E6.1462CDF4@i-cable.com>

is there any possible ways to upload multiple files by a broswer instead
of upload files one by one

THX



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

Date: Wed, 23 Jun 1999 19:26:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: use strict question
Message-Id: <37713471.1812085@news.skynet.be>

Mike Machado wrote:

>my $sub = "mysub";
>&$sub;
>
>sub mysub {
> print "hello this does not work while use strict is on\n";
>}
>
>How can I get this to work while still having 'use strict' on?

Why? 

You can replace it with:

	my $sub = \&mysub;
	&$sub;

which is a safer way of achieving this (and probably a bit faster, too).

Otherwise, try:

	{
	    no strict "refs";
	    &$sub;
	}	

The block limits the scope of the "no strict" pragma.

	Bart.


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

Date: 23 Jun 1999 20:14:42 GMT
From: h.camp@creagen.de (H. Camphausen)
Subject: Re: use strict question
Message-Id: <MPG.11db5e771e055d70989689@news.scm.de>

In article <377129F1.6D36D6E5@innercite.com>, mike@innercite.com says...

> I am trying to use a scalar as a subroutine name while I have use strict
> on and I keep getting the error:
> 
> Can't use string ("mysub") as a subroutine ref while "strict refs" in
> use at testing.pl line 5
> 
> Here is the code
> 
> 
> #!/usr/bin/perl
> use strict;
> 
> my $sub = "mysub";
> &$sub;
> 
> sub mysub {
> 
>  print "hello this does not work while use strict is on\n";
> 
> }
> 
> 
> How can I get this to work while still having 'use strict' on?
> 

Never.

You are using something called 'symbolic reference'. That is, you try to 
referr to your subroutine by name (&$subroutine_name).
Well, this _is_ possible, but: symbolic references only work on global 
variables (routines) in your package (script). You can't use them with 
vars and routines declared with 'my'. Because symbolic references _can_ 
cause trouble, strict won't allow them.

Try to use a socalled 'hard reference' instead:

1. No 'symbolism' here:

  sub my_function {...};
  $my_func = \&my_function;	# note the magic backslash.
  .					# note, that $func_ref still is 
  .					# a scalar, but does *not* contain
  .					# your function's name, but some kind 
  .					# of a pointer to your function.
  .					
  .
  $result = &$my_func;		# here we go, strict won't complain
 

2. If you need to use the name of your function, 
   use a hash before (plus a hard reference):

  sub my_function {...};
  %func_refs = ('my_function' => \&my_function);
  .				# here you can use anything as 
  .				# your 'symbolic' function-name
  .				# _but_ note the backslash again
  .
  .
  $my_func = 'my_function';	
  .				# $my_func is a scalar _and_ contains
  .				# no reference at all..
  .
  .
  # here we go again, strict won't complain, 'symbolism' is working fine:
  $result = &{$func_refs{$my_func}};



For details on references, see the perlref + perlfaq 7 pages in your 
Perldocs.

hth, Hartmut


-- 
-----------------------------------
CREAGEN Computerkram
Hartmut Camphausen
Kirchstrasse 8
35042 Marburg
Fon: 06424/923826
Fax: 06424/923827
Emil: h.camp@creagen.de
WWW: http://www.creagen.de/


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

Date: Wed, 23 Jun 1999 20:00:18 GMT
From: syurman@spatialfocus.com
Subject: Re: Using Boulderio in CGI.pm
Message-Id: <7krecb$gtm$1@nnrp1.deja.com>

I found an answer to my question elsewhere, and thought I'd post it in
case anyone else was interested in BoulderIO.  This is a wonderful
module available from Lincoln Stein, the author of CGI.pm, at
http://stein.cshl.org/.  Lincoln maintains a variety of useful tools,
all available there.  Well worth the visit.

My script had two problems:

* I needed to add 2 lines:

     use Boulder::Stream;
     $stream = new Boulder::Stream;

  These created the stream to handle the IO.

* I had permission problems.  Once diagnosed, easily solved with a visit
to the CGI-FAQ at comp.infosystems.www.authoring.cgi.

Cheers,

Sara


In article <7kh316$32f$1@nnrp1.deja.com>,
  syurman@spatialfocus.com wrote:
> I'd like to use Boulder.pm with input from CGI.pm.  Each works fine
> separately, but a call to new Boulder::Store gets ignored every time.
>
> My error_log file returns the following message:
> Can't call method "write_record" on an undefined value at
> /home/httpd/cgi-bin/form_test3.cgi line [whereever I tried to write
> the record].
>
> I'm hoping someone will have experience with this, or will know a
better
> place to post.  Sample code below.
>
> TIA,
>
> Sara
>
> *********************This works!******************************
> #!/usr/bin/perl
>
> use Stone;
> use Boulder::Store;
>
> my $stone = new Stone;
> $stone->insert(name=>'Sara');
> print br;
> my $store=new Boulder::Store("boulder",true);
> print "\$store=".$store."\n";
> $store->write_record($stone);
> exit(0);
>
> It prints the results nicely, and obediently writes out boulder.data
and
> boulder.index.
>
> **************This gives the hated error message*******************
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
> use Stone;
> use Boulder::Store;
>
> print header;
> print start_html('A Simple Example'),
>     h1('A Simple Example'),
>     start_form,
>     "What's your name? ",textfield('name'),
>     submit,
>     end_form,
>     hr;
>
> if (param()) {
>     my $stone=new Stone;
>     $stone->insert(name=>(param('name')));
>     print $stone->asTable;
>     my $store=new Boulder::Store("boulder",true);
>     print br;
>     print "\$store=".$store."\n";
>  $store->write_record($stone);
> }
> print end_html;
>
> $stone prints nicely, but the attempt to print $store gives only
> "$store =".  I was expecting something like HASH0x.....
> No boulder.data or boulder.index.  And the httpd log complains
> as noted above.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 23 Jun 1999 12:02:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Viral matters [completely off-topic]
Message-Id: <37712F3E.FECEEB9D@mail.cor.epa.gov>

Tom Christiansen wrote:
> 
> After the recent flourish of writings on the issue of viruses in the
> popular press and the frequently miswritten plural forms of virus seen
> on the net, I decided to do some research into the matter.  The result is
> 
>     http://language.perl.com/misc/virus.html

Nice page.
 
> Feel free to point others thither.  No, Unix has no viruses.  Neither
> does Perl.

I hereby nominate the subroutines in Matt's Scripts as examples 
of Perl viruses.  They certainly fit the clasical Latin original:
"slimy liquid, poison, offensive odour or taste".  They can't
exist except within Perl programs.  They're impossible to get
rid of [except in one's own scripts].  They seem to proliferate
at a terrifying rate.  Their very nature seems to induce their
replication.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 6111
**************************************

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