[11394] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4995 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 16:17:47 1999

Date: Fri, 26 Feb 99 13:12:46 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4995

Today's topics:
        problem while running cgi perl scripts in windows limor@smlink.com
    Re: problem while running cgi perl scripts in windows <Allan@due.net>
    Re: problem while running cgi perl scripts in windows limor@smlink.com
    Re: problem while running cgi perl scripts in windows jeremygurney@hotmail.com
    Re: Problem with oraperl in a web-browser <schoedema@my-dejanews.com>
    Re: Problems with automating ftp <rick.delaney@home.com>
        Problems with version perl5.005_55 <backes@rhrk.uni-kl.de>
    Re: Problems with Win32::OLE and MSWord in Office 97 gdmiller@wave.home.com
        Putting variabelnames in variabelnames <chbeer@hotmail.com>
    Re: Putting variabelnames in variabelnames <jeffp@crusoe.net>
    Re: Putting variabelnames in variabelnames <tchrist@mox.perl.com>
    Re: Putting variabelnames in variabelnames (Andrew M. Langmead)
        pwd under DOS?! (Babak Hadji-Hosseini)
    Re: pwd under DOS?! <paladin@uvic.ca>
    Re: pwd under DOS?! ran@netgate.net
    Re: pwd under DOS?! (Henri Periat)
    Re: Q on diff of array vs hash <Philip.Newton@datenrevision.de>
        Q on GMT offset <tavi367@ibm.net>
    Re: Q on GMT offset (I R A Aggie)
    Re: Q on GMT offset (Larry Rosler)
        Q on TZ <walter@tscinternet.com>
        Q: Perl shell? <landes@NO.SPAM.unt.edu>
    Re: Q: Perl shell? <rick.delaney@home.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 22 Feb 1999 09:43:27 GMT
From: limor@smlink.com
Subject: problem while running cgi perl scripts in windows
Message-Id: <7ar8ru$ksa$1@nnrp1.dejanews.com>

I have a problem which I am sure someone here knows the answer for it.

When I am trying to run a cgi perl script from a dox box windows under
windows 98 I get the output as HTML text file to the screen in the dos
box window.
When I am running the same script from the web browser I get the same
result.

How do I redirect the output to the web browser?


Limor.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 23 Feb 1999 12:48:14 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: problem while running cgi perl scripts in windows
Message-Id: <7aup8v$66e$1@camel0.mindspring.com>

limor@smlink.com wrote in message <7atn2l$obd$1@nnrp1.dejanews.com>...
:In article <7arh76$r79$1@nnrp1.dejanews.com>,
:  jeremygurney@hotmail.com wrote:
:> In article <7ar8ru$ksa$1@nnrp1.dejanews.com>,
:>   limor@smlink.com wrote:
:> > I have a problem which I am sure someone here knows the answer for it.
:> > When I am trying to run a cgi perl script from a dox box windows under
:> > windows 98 I get the output as HTML text file to the screen in the dos
:> > box window.
:> > When I am running the same script from the web browser I get the same
:> > result.
:> > How do I redirect the output to the web browser?
:> > Limor.
:> I'm not quite clear from what you've posted as to what the problem is,
:> 1) If you browser is showing your HTML coding and not the page then check
:> you've got the top of your doc as > Content-type: text/html
:> < (the blank line is needed).
:> 2) If you want to run that cgi script on your PC properly then you'll
need to
:> run a web server on your PC (much easier than it sounds) Check out Apache
or
:> Xitami - both free and easy to set up.
:> Regards,
:> Jeremy Gurney

:I forgot to mention 2 important things:
:
:1. I have a web server - IIS
:2. I downloaded perl for win32 from active state and I am using version
:   5.005_02.
:I will try to be more specific and explain my problem again.
:
:I write perl scripts for quite a long time and now I want to use the CGI
:feature.
:I have some examples of cgi perl scripts in my perl directory and I tried
:to run them from several places
:
:1. From the explorer
:2. From a command line ( through dos box window )
:3. From a web browser
:
:In all cases when I run the script a dox box window is opened and the
output
:of the script is shown as an HTML text file on the screen of the dos box
:window.
:
:From what I read so far I know that in UNIX environment it works fine and
in
:windows I have to do some configuration in order that it will work.
:
:Can someone tell me in step by step instruction what I have to do or what
:is the configuration that is needed in WIN98 in order to redirect the
output
:to the web browser.
:
:I would like to mention again that my computer is connected to NT server
and
:the web server is called IIS.
:I am using 2 web browser NETSCAPE and EXPLORER.
:
:I hope the problem is clear now.


Well, it is clearer, unfortunately part of what's clearer is that this is
most likely a server related issue and you will probably need to pursue this
in the appropriate newsgroup.

My best guess would be:
comp.infosystems.www.servers.ms-windows

HTH

AmD

--
$email{'Allan M. Due'} = 'Allan@Due.net';
--random quote --
If I don't document something, it's usually either for a good reason,
or a bad reason.  In this case it's a good reason.  :-)
   Larry Wall in <1992Jan17.005405.16806@netlabs.com>





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

Date: Tue, 23 Feb 1999 07:58:16 GMT
From: limor@smlink.com
Subject: Re: problem while running cgi perl scripts in windows
Message-Id: <7atn2l$obd$1@nnrp1.dejanews.com>

In article <7arh76$r79$1@nnrp1.dejanews.com>,
  jeremygurney@hotmail.com wrote:
> In article <7ar8ru$ksa$1@nnrp1.dejanews.com>,
>   limor@smlink.com wrote:
> > I have a problem which I am sure someone here knows the answer for it.
> >
> > When I am trying to run a cgi perl script from a dox box windows under
> > windows 98 I get the output as HTML text file to the screen in the dos
> > box window.
> > When I am running the same script from the web browser I get the same
> > result.
> >
> > How do I redirect the output to the web browser?
> >
> > Limor.
>
> I'm not quite clear from what you've posted as to what the problem is,
>
> 1) If you browser is showing your HTML coding and not the page then check
> you've got the top of your doc as > Content-type: text/html
>
> < (the blank line is needed).
>
> 2) If you want to run that cgi script on your PC properly then you'll need to
> run a web server on your PC (much easier than it sounds) Check out Apache or
> Xitami - both free and easy to set up.
>
> Regards,
>
> Jeremy Gurney
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

I forgot to mention 2 important things:

1. I have a web server - IIS
2. I downloaded perl for win32 from active state and I am using version
   5.005_02.

I will try to be more specific and explain my problem again.

I write perl scripts for quite a long time and now I want to use the CGI
feature.
I have some examples of cgi perl scripts in my perl directory and I tried
to run them from several places

1. From the explorer
2. From a command line ( through dos box window )
3. From a web browser

In all cases when I run the script a dox box window is opened and the output
of the script is shown as an HTML text file on the screen of the dos box
window.

>From what I read so far I know that in UNIX environment it works fine and in
windows I have to do some configuration in order that it will work.

Can someone tell me in step by step instruction what I have to do or what
is the configuration that is needed in WIN98 in order to redirect the output
to the web browser.

I would like to mention again that my computer is connected to NT server and
the web server is called IIS.
I am using 2 web browser NETSCAPE and EXPLORER.

I hope the problem is clear now.



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 22 Feb 1999 12:06:00 GMT
From: jeremygurney@hotmail.com
Subject: Re: problem while running cgi perl scripts in windows
Message-Id: <7arh76$r79$1@nnrp1.dejanews.com>

In article <7ar8ru$ksa$1@nnrp1.dejanews.com>,
  limor@smlink.com wrote:
> I have a problem which I am sure someone here knows the answer for it.
>
> When I am trying to run a cgi perl script from a dox box windows under
> windows 98 I get the output as HTML text file to the screen in the dos
> box window.
> When I am running the same script from the web browser I get the same
> result.
>
> How do I redirect the output to the web browser?
>
> Limor.

I'm not quite clear from what you've posted as to what the problem is,

1) If you browser is showing your HTML coding and not the page then check
you've got the top of your doc as > Content-type: text/html

< (the blank line is needed).

2) If you want to run that cgi script on your PC properly then you'll need to
run a web server on your PC (much easier than it sounds) Check out Apache or
Xitami - both free and easy to set up.

Regards,

Jeremy Gurney

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 22 Feb 1999 08:16:15 GMT
From: Peter Schoenenberger <schoedema@my-dejanews.com>
Subject: Re: Problem with oraperl in a web-browser
Message-Id: <7ar3oa$fub$1@nnrp1.dejanews.com>

The problem was, that the environment variable LD_LIBRARY_PATH is ignored if
the script is running with set-uid (this is the case if the script is running
from the web-server). I've found a comment from Dave Moellenhoff in a README-
file of the former administrator. Dave Moellenhoeff wrote:

Can't find libclntsh.so at run time:
Dave Moellenhoff <dmoellen@clarify.com>:  libclntsh.so is the shared
library composed of all the other Oracle libs you used to have to
statically link.  Oracle didn't start providing it until 7.2 and later.
libclntsh.so should be in $ORACLE_HOME/lib.  If it's missing, try
running $ORACLE_HOME/rdbms/lib/genclntsh.sh and it should create it.
Also: Never copy libclntsh.so to a different machine or Oracle version.
If DBD::Oracle was built on a machine with a different path to libclntsh.so
then you'll need to set set an environment variable, typically
LD_LIBRARY_PATH, to include the directory containing libclntsh.so.
_BUT_: LD_LIBRARY_PATH is typically ignored if the script is running set-uid
(which is common in some httpd/CGI configurations).  In this case
either rebuild with LD_RUN_PATH set to include the path to libclntsh
or create a symbolic link so that libclntsh is available via the same
path as it was when the module was built. (On Solaris the command
"ldd -s Oracle.so" can be used to see how the linker is searching for it.)

Many thanks to all, who helped to solve my problem!
Peter

In article <36D03493.2EB03D2D@his.com>,
  Chris Morrow <morrowc@his.com> wrote:
> When you changed the Oracle_Home might you also have to
> "recompile/reinstall" oraperl/DBD::Oracle? During the
> installation/compilation there are some parts that are either referenced
> or pulled from the Oracle_Home.  The shared objects you are not able to
> reference could be required at runtime and Perl is looking in the
> "wrong" place for them?
>
> -Chris
>
> Peter Schoenenberger wrote:
> >
> > That's a good thought, but I have already set the following variable in the
> > Perl-Script:
> >
> > $ENV{ORACLE_HOME}="/opt/app/oracle/product/7.3.4";
> >
> > Are there any other variables which must been set?
> >
> > The script _IS_ running on a unix-shell using 'perl <scriptname>' but is not
> > running from the WWW Server as a CGI (errorlog see below).
> >
> > Peter
> >
> > In article <36CCD8DE.32300FB@his.com>,
> >   Chris Morrow <morrowc@his.com> wrote:
> > > 1) Your script is running from the WWW Server...as a CGI.
> > > 2) you might have set the ORACLE_HOME in the CGI script and now since
> > > you have upgraded (and removed the old version) the ORACLE_HOME is
> > > different???
> > >
> > > Just a thought and a comment.
> > >
> > > This seems to most likely NOT be a problem with Apache, it seems like
> > > your code might need a quick fix (change ORACLE_HOME to be correct?)
> > >
> > > -Chris
> > >
> > > schoedema@my-dejanews.com wrote:
> > > >
> > > > I have the following configuration:
> > > > Solaris 2.5, Apache 1.2.5, Netscape 4.04 under Solaris.
> > > > I have a Perl script, that connects to an oracle-DB via CGI and Oraperl
> > from a
> > > > browser (IE4 or Netscape 4). Under Oracle V.7.3.2 everything works fine.
> > > > After upgrading the DB to V.7.3.4 the script didn't work properly
anymore.
> > The
> > > > Apache error-log produces the follwing message:
> > > >
> > > > ---------- install_driver(Oracle) failed: Can't load
> > > > '/usr/local/lib/perl5/site_perl/sun4-
solaris/auto/DBD/Oracle/Oracle.so' for
> > > > module DBD::Oracle: ld.so.1: /usr/local/bin/perl: fatal:
libclntsh.so.1.0:
> > > > can't open file: errno=2 at
> > > > /usr/local/lib/perl5/sun4-solaris/5.00403/DynaLoader.pm line 155.
> > > >
> > > >  at (eval 1) line 2
> > > >
> > > >   DBI::install_driver('DBI', 'Oracle') called at
> > > > /usr/local/lib/perl5/site_perl/Oraperl.pm line 57  require Oraperl.pm
called
> > > > at /usr/local/www/cgi-bin/digidat/list_msanl line 21  main::BEGIN()
called
> > at
> > > > /usr/local/lib/perl5/site_perl/Oraperl.pm line 0  eval {...} called at
> > > > /usr/local/lib/perl5/site_perl/Oraperl.pm line 0 BEGIN failed--
compilation
> > > > aborted at /usr/local/www/cgi-bin/digidat/list_msanl line 21.
-----------
> > > >
> > > > If I create a softlink from the old oraclehome to new oraclehome the
script
> > > > is running without a problem even from the webbrowser. Obviously there
seems
> > > > to be a problem with the path-tracking within the Apache server.
> > > >
> > > > I'm grateful for any suggestions concerning my problem.
> > > >
> > > > -----------== Posted via Deja News, The Discussion Network ==----------
> > > > http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
> > >
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sun, 21 Feb 1999 21:37:38 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Problems with automating ftp
Message-Id: <36D07E8C.D38026A1@home.com>

[posted & mailed]

Nitin Gupta wrote:
> 
> The connection is initiated and the logon works but all the script is 
> able to do is create a file with the same name but zero contents!
> Any ideas?
> 
> #!/usr/bin/perl
> 
> use Net::FTP;
> print "Initiating connect......\n";
> $ftp = Net::FTP->new("my.server.com");

Let this nifty module do the debugging for you.

    $ftp = Net::FTP->new("my.server.com", Debug => 1);

perldoc Net::FTP;

You're probably getting disconnected before the transfer is finished.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 23 Feb 1999 14:57:50 +0100
From: Joachim Backes <backes@rhrk.uni-kl.de>
Subject: Problems with version perl5.005_55
Message-Id: <36D2B3DE.25DC64FE@rhrk.uni-kl.de>

A) Whereto can I send Perl bug reports? <perlbug@perl.com> was not successful

B) I installed perl5.005_55. Two problems arose:

1. After installation, I had problems to use my previuosly installed CPAN software.
   Only after re-installing the CPAN software, I got rid from this problem.

2. After perl5.005_55 installation, I was no more able to install the CPAN
   software TermReadKey-2.12. Reason: "perl Makefile.PL" complained about the
   fact

        Sorry, but MakeMaker 3.5 or better is needed to build this package.

   (looks after $ExtUtils::MakeMaker::Version).

   I found out that the Problem was the fact that no more $ExtUtils::MakeMaker::Version
   exists (like in version 5.005_02, /usr/local/lib/perl5/5.00502/ExtUtils/MakeMaker.pm).
   /usr/local/lib/perl5/5.00555/ExtUtils/MakeMaker.pm uses only $VERSION, but not
   $Version.

My config:

Summary of my perl5 (revision 5.0 version 5 subversion 55) configuration:
  Platform:
    osname=irix, osvers=6.4, archname=IP27-irix
    uname='irix64 origin 6.4 02121744 ip27 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    use64bits=undef usemultiplicity=undef
  Compiler:
    cc='cc -n32', optimize='-O3', gccversion=
    cppflags='-D_BSD_TYPES -D_BSD_TIME -OPT:Olimit=0:space=ON -I/usr/local/include -DLANGUAGE_C'
    ccflags ='-D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1184 -OPT:Olimit=0:space=ON -I/usr/local/incl
ude -DLANGUAGE_C'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc -n32', ldflags =' -L/usr/local/lib32 -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib32 /lib32 /lib /usr/lib
    libs=-lm -lc
    libc=/usr/lib32/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-n32 -shared -L/usr/local/lib32 -L/usr/local/lib'

--
Joachim Backes        | Univ. of Kaiserslautern
Computer Center, Supercomputing Division     | Phone: +49-631-205-2438
D-67653 Kaiserslautern, PO Box 3049, Germany | Fax:   +49-631-205-3056
---------------------------------------------+------------------------
WWW: http://sgi400.rhrk.uni-kl.de/home/mitarbeiter/backes.html





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

Date: Mon, 22 Feb 1999 19:33:11 GMT
From: gdmiller@wave.home.com
Subject: Re: Problems with Win32::OLE and MSWord in Office 97
Message-Id: <7asbdn$jcg$1@nnrp1.dejanews.com>

Hi Jan,

I did all the things you mentioned and still experience the problem. It seems
it only gives me a problem with documents that contain subdocuments. I added
the -w flag and it crashes with the following error only if Visible is set to
0. If Visible is set to 1 it works great. Winword crashes and gives the
following message:

Win32::OLE(0.1005) error 0x800706ba: "The RPC server is unavailable" in
METHOD/PROPERTYGET "" at view_update.bat line 104 Can't call method
"PrintOut" on an undefined value at view_update.bat line 104.

Would you know how to make it so the save changes dialog box does not come up?

Your help is greatly appreciated

Dale


In article <36d1fa22.12895963@news3.ibm.net>,
  jan.dubois@ibm.net (Jan Dubois) wrote:
> [mailed & posted]
>
> gdmiller@wave.home.com wrote:
>
> >Hi all, if you can help with this it will be greatly appreciated.
>
> I'll add some general comments too, although they are most probably not
> relevant to your problem. I think your problem might be the order of
> destruction of objects. This would most easily be fixed by making all
> variables lexicals and removing the explicit undef-ing.
>
> Please run your program under "perl -w", which will give you much better
> Win32::OLE error messages!
>
> >eval {$ex = Win32::OLE->GetActiveObject('Word.Application')}; die "Word not
> >installed" if $@; unless (defined $ex) {  $ex =
> >Win32::OLE->new('Word.Application', sub {$_[0]->Quit;}) or die "Oops, cannot
> >start Word"; }
>
> You could write this as:
>
>     $ex = Win32::OLE->new('Word.Application', 'Quit')
>         or die "Oops, cannot start Word";
> >
> >foreach $file (@files) {
> >    $dirname=dirname($file);
> >    $file = $snapview."\\$file";
> >    $file =~ s(\\)(\\\\)g;
> >    $finalloc = $pdffileloc.$dirname;
> >    $basename=basename($file,".doc");
> >    $ex->SetProperty('Visible',0);
> >    $ex->SetProperty('DisplayAlerts',0);
>
> The SetProperty() method is only necessary for properties that take values.
> Hash reference syntax is more readable otherwise:
>
>     $ex->{Visible} = 0;
>     $ex->{DisplayAlerts} = 0;
>
> In this case I would recommend to use the with() function. You have to
> explicitly request it with:
>
>     use Win32::OLE qw(with);
>
> and then write here:
>
>     with($ex, Visible => 0, DisplayAlerts => 0);
>
> You should also move these global settings out of the loop; you only have to
> do them once.
>
> >    $ex->SetProperty('wdAlertLevel',0);
> >    $ex->SetProperty('wdSaveOptions', 0);
>
> I'm pretty sure the two lines above don't do what you think they do. I
> believe they are errors, because the Application object doesn't have
> wdAlertLevel and wdSaveOptions properties. BTW, the wdXXXX constants are not
> strings but integer constants. Read the Win32::OLE::Const documentation to
> find out how to import and use them!
>
> >    $doc = $ex->Documents->Open($file);
> >    $subdocs = $doc->Subdocuments;
> >    $subdocs->SetProperty('Expanded',1);
>
>      my $doc = $ex->Documents->Open($file);
>      my $subdocs = $doc->Subdocuments;
>      $subdocs->{Expanded} = 1;
>
> >    $ex->SetProperty('ActivePrinter', "\\\\ott100\\HPOTT004PS on NE00");
> >    $ex->ActiveDocument->PrintOut(0,
> >				  0,
> >				  "",
> >				  "$pstempfileloc$basename.ps");
> >#    $ex->Quit();
> >    undef $doc;
>
> Don't undef $Doc here. Word might not like it that you are still hanging on
> to a reference to the Subdocuments collection. Either undef $subdocs first,
> or make the variables lexicals, as I have done above and let Perl handle the
> destruction.
>
>  #   undef $doc;
>
> >    copy ("$pstempfileloc$basename.ps","$distillerin$basename.ps") or die
> >"Cannot copy file\n";
> >    while( -e "$distillerin$basename.ps"){}
> >    mkpath ([$finalloc]);
> >    copy ("$distillerout$basename.pdf", "$finalloc\\$basename.pdf") or die
> >"Cannot copy file\n";
> >}
> >undef $ex;
>
> Instead of the "undef $ex;" here I would prefer a "my $ex;" at the top.
>
> -Jan
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 22 Feb 1999 15:00:19 +0100
From: Christian Beer <chbeer@hotmail.com>
Subject: Putting variabelnames in variabelnames
Message-Id: <36D162F3.CC09145A@hotmail.com>

Hi everybody

I've really tried to read the faq page but I haven't found any help
there.
Is my english to bad ????
I've tried to accomplish something like this in perl:

 #!/user/bin/perl
 # let's say i have this variables
 $typ_r1 = "Room 1";$typ_r2 = "Room 2"; $type_r3 = "Room 3";

 $p_1_r1 = 200; $p_1_r2 = 200; $p_1_r3 = 200;
 $p_2_r1 = 500; $p_2_r2 = 200; $p_2_r3 = 200;
 $p_3_r1 = 256; $p_3_r2 = 200; $p_3_r3 = 200;
 $p_4_r1 = 369; $p_4_r2 = 200; $p_4_r3 = 200;
 $p_5_r1 = 789; $p_5_r2 = 200; $p_5_r3 = 200;
 $p_6_r1 = 103; $p_6_r2 = 200; $p_6_r3 = 200;
 $p_7_r1 = 874; $p_7_r2 = 200; $p_7_r3 = 200;
 $p_8_r1 = 365; $p_8_r2 = 200; $p_8_r3 = 200;

 # now I wont to print them out
 Content-Type: text/html


 print "<html><head><title>Whow it works</title></head><body><table>";

 # as a table i html
 # ...i would like to write some thing like this
 # that make it possible to use
 # $r and $d from the loops below.
 # I would like to use $r and $d
 # inside the variable names

 for ($r = 1; $r<3; $r = $r + 1)
 {
 # with $type_$r I mean $type_r1 to $type_r3
 print "<tr><td>$type_$r</td>\n";

    for ($d = 1; $d<8; $p = $d + 1)
    {
    # with $p_$d_$r I mean $p_1_r1 to $p_8_r3
     print "<td>$p_$d_$r</td>\n";
    }
 print "</tr>\n";
 }
 print "</table></body></html>\n";


I obvious make a very serious mistake above
I just cant figre it out how to put variabelnames in variabelnames

How should i do instead???

much obliged for any help
Christian Beer



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

Date: Mon, 22 Feb 1999 09:17:39 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Putting variabelnames in variabelnames
Message-Id: <Pine.GSO.3.96.990222091224.25986B-100000@crusoe.crusoe.net>

> I just cant figre it out how to put variabelnames in variabelnames

This statement usually indicates you want to use more complex data
structures.  I point you to these sources:
	perldsc - Perl Data Structures Cookbook
	perllol - Manipulating Lists of Lists in Perl

These can be reached by typing the following at your system's prompt:
	perldoc perldsc
and
	perldoc perllol

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



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

Date: 22 Feb 1999 07:32:40 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Putting variabelnames in variabelnames
Message-Id: <36d16a88@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Christian Beer <chbeer@hotmail.com> writes:
:I obvious make a very serious mistake above

You are.  You are assuming that you should put variable
names inside of variables.   You should't.  You should use
a hash.

:I just cant figre it out how to put variabelnames in variabelnames

I know that English is not your first language, and that I probably
can't speak yours half so well as you speak mine.  But your
meaning comes across anyway.

:How should i do instead???

=head2 How can I use a variable as a variable name?

Beginners often think they want to have a variable contain the name
of a variable.

    $fred    = 23;
    $varname = "fred";
    ++$$varname;         # $fred now 24

This works I<sometimes>, but it is a very bad idea for two reasons.

The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether.  Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.

Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.

The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes.  By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash.  The solution is to
use your own hash or a real reference instead.

    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables.  This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one.  Instead of
reading a string and expanding it to the actual contents of your program's
own variables:

    $str = 'this has a $fred and $barney in it';
    $str =~ s/(\$\w+)/$1/eeg;		  # need double eval

Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:

    $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

That's faster, cleaner, and safer than the previous approach.  Of course,
you don't need to use a dollar sign.  You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.

    $str = 'this has a %fred% and %barney% in it';
    $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes.  For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.

    $name = "fred";
    $$name{WIFE} = "wilma";     # set %fred

    $name = "barney";           
    $$name{WIFE} = "betty";	# set %barney

This is still a symbolic reference, and is still saddled with the
problems enumerated above.  It would be far better to write:

    $folks{"fred"}{WIFE}   = "wilma";
    $folks{"barney"}{WIFE} = "betty";

And just use a multilevel hash to start with.

The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table.  This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.

In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table.  For example:

    @colors = qw(red blue green yellow orange purple violet);
    for my $name (@colors) {
        no strict 'refs';  # renege for the block
        *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
    } 

All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.

So, sometimes you might want to use symbolic references to directly
manipulate the symbol table.  This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
-- 
    It's there as a sop to former Ada programmers.  :-)
        --Larry Wall regarding 10_000_000 in <11556@jpl-devvax.JPL.NASA.GOV>


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

Date: Mon, 22 Feb 1999 17:41:19 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Putting variabelnames in variabelnames
Message-Id: <F7KH4w.76A@world.std.com>

Christian Beer <chbeer@hotmail.com> writes:

>Subject: Re: Putting variabelnames in variabelnames

What you describe is perl's feature it calls "symbolic
references". See the perlref man page for details.

for my $r ( 1 .. 3 ) {
 print '<tr><td>',${"type_r$r"},"</td>\n";
 for my $d ( 1 .. 8 ) {
    print '<td>', ${"p_${d}_r{$r}"}, "</td\n";
 }
}

But you would really be better off using multidimensional data
structures instead, as described in the perlref, perldsc, and perllol
man pages.

@type_r = map { "Room $_" } 1 .. 3;

@p = ( [  200,  200,  200 ],
       [  500,  200,  200 ],
       [  256,  200,  200 ],
       [  369,  200,  200 ],
       [  789,  200,  200 ],
       [  103,  200,  200 ],
       [  874,  200,  200 ],
       [  365,  200,  200 ],
);

for my $r ( 0 .. 2 ) {
 print "<tr><td>$type_r[$r]</td>\n";
 for my $d ( 0 .. 7 ) {
    print "<td>$p[$d][$r]</td>\n";
 }
}
-- 
Andrew Langmead


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

Date: Thu, 25 Feb 1999 20:26:13 GMT
From: bhadjiho@ix.urz.uni-heidelberg.de (Babak Hadji-Hosseini)
Subject: pwd under DOS?!
Message-Id: <36d5b150.3062754@news.urz.uni-heidelberg.de>

Hi folks!

I've gotta CGI-Script which I would like to run under my Win98-
Server, but it unfortunately uses the unix command pwd.

Any ideas?

  Babak


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

Date: Thu, 25 Feb 1999 12:57:20 -0800
From: Draco Paladin <paladin@uvic.ca>
To: Babak Hadji-Hosseini <bhadjiho@ix.urz.uni-heidelberg.de>
Subject: Re: pwd under DOS?!
Message-Id: <Pine.A41.4.05.9902251256380.64700-100000@unix3.UVic.CA>

On Thu, 25 Feb 1999, Babak Hadji-Hosseini wrote:

> I've gotta CGI-Script which I would like to run under my Win98-
> Server, but it unfortunately uses the unix command pwd.

The command in MS-DOS that is equlvelent to 'pwd' is 'cd'.

HTH
---------------------------------------------
Mother is the name for GOD on the lips and
hearts of all children.  - Eric Draven



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

Date: 26 Feb 1999 02:32:53 GMT
From: ran@netgate.net
Subject: Re: pwd under DOS?!
Message-Id: <7b514l$a55$2@remarQ.com>

In <36d5b150.3062754@news.urz.uni-heidelberg.de>, bhadjiho@ix.urz.uni-heidelberg.de (Babak Hadji-Hosseini) writes:
>Hi folks!
>
>I've gotta CGI-Script which I would like to run under my Win98-
>Server, but it unfortunately uses the unix command pwd.

There are ports of many such commands to various flavors of Windoze. 
The cygnus package of GNU ports worked very well for me under NT,  and 
98 might be 32bit-ish enough to support it.  If not,  there are even 
versions that were done years ago for DOS that you should be able to 
use.  Look on sites like Simtelnet,  if you can't find it where you 
usually go to download freeware/shareware.

Ran




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

Date: 26 Feb 1999 12:42:13 GMT
From: periat@ens.ascom.ch (Henri Periat)
Subject: Re: pwd under DOS?!
Message-Id: <7b64r5$bd7$1@ascomax.hasler.ascom.ch>

Hi everybody

This question got strange answers. This is a Perl news group, so give
Perl answers and Perl has almost always a answer:
Use the module 'Cwd';

Enjoy it
Henri



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

Date: Tue, 23 Feb 1999 10:18:09 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Q on diff of array vs hash
Message-Id: <36D27250.285BA003@datenrevision.de>

Larry Rosler wrote:
>
[lots of explanations]
> 
> In words of one sentence, table lookup via small non-negative integers
> is naturally done best with an array; other table lookups are naturally
> done best with a hash; substringing is cute, but slower than array
> lookup (if the array is pre-initialized).
> 
> Signed, 'another guru'.  :-)

What a good and helpful answer! You are a most helpful guru. May your
code ever compile without problems under -w and use strict.

Cheers,
Philip


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

Date: Wed, 24 Feb 1999 20:41:54 -0600
From: "Walter" <tavi367@ibm.net>
Subject: Q on GMT offset
Message-Id: <36d4b8a6@news1.us.ibm.net>

>From what I read, my TZ should read...

     CST6CDT

but when I run this ...

    use Time::Timezone;
    $offset = ( tz_local_offset() ) / 60 / 60;
    print $offset

I get this...

    -6

What gives?

Any idea?

Walter







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

Date: 25 Feb 1999 06:56:56 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Q on GMT offset
Message-Id: <slrn7d9t6j.i2q.fl_aggie@enso.coaps.fsu.edu>

On Wed, 24 Feb 1999 20:41:54 -0600, Walter <tavi367@ibm.net> wrote:
+ From what I read, my TZ should read...
+ 
+      CST6CDT
+ 
+ but when I run this ...
+ 
+     use Time::Timezone;
+     $offset = ( tz_local_offset() ) / 60 / 60;
+     print $offset
+ 
+ I get this...
+ 
+     -6
+ 
+ What gives?

Did you read the docs on Time::Timezone?

+ Any idea?

tz_local_offset() returns the offset in _seconds_. But you must have
known that, or why would you be dividing by 3600? anyway, what you
have there is the offset, in hours. Since it is a negative value,
that means your timezone is _behind_ GMT.

James


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

Date: Wed, 24 Feb 1999 23:45:21 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q on GMT offset
Message-Id: <MPG.113e9f7084eea786989686@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36d4b8a6@news1.us.ibm.net>, on Wed, 24 Feb 1999 20:41:54 -
0600 tavi367@ibm.net says...
> From what I read, my TZ should read...
>      CST6CDT
> but when I run this ...
> 
>     use Time::Timezone;
>     $offset = ( tz_local_offset() ) / 60 / 60;
>     print $offset
> 
> I get this...
>     -6
> What gives?

Since time immemorial :-), the Unix TZ environment variable has 
specified time as the offset of GMT relative to local time.  This may be 
because it was developed in the United States, where this offset is a 
small positive integer.

However, the rest of the world measures local time offsets relative to 
GMT (now UTC).  Thus, your current timezone, CST, is described 
conventionally as UTC-0600, and its offset in hours is -6.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 22 Feb 1999 21:37:11 -0600
From: "Walter" <walter@tscinternet.com>
Subject: Q on TZ
Message-Id: <36d2227d@news1.us.ibm.net>

It was my understanding that the format for time zone was...

      $ENV{TZ}: EST5EDT

But my ISP Sun box says...

     $ENV{TZ}: US/Eastern

Or is ther (as usual) more than one way to do it?

Walter





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

Date: 24 Feb 1999 17:25:45 GMT
From: "Paul A. Landes" <landes@NO.SPAM.unt.edu>
Subject: Q: Perl shell?
Message-Id: <7b1cmp$8bk@hermes.acs.unt.edu>

Has anyone heard of a PERL shell out there.   I mean like csh/sh/bash
except a perl shell.

Just wanted to make sure there was not one before I write one.

Reply back email please (change the AT to @).
Thanks in advance.


-- 
Paul Landes
landesATunt.edu


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

Date: Thu, 25 Feb 1999 04:03:07 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Q: Perl shell?
Message-Id: <36D4CD65.B0F5188C@home.com>

Paul A. Landes wrote:
> 
> Has anyone heard of a PERL shell out there.   I mean like csh/sh/bash
> except a perl shell.

This is a FAQ.  Right near the top of perlfaq3.

-- 
Rick Delaney
rick.delaney@home.com


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

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

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