[24565] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6743 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 29 00:05:35 2004

Date: Mon, 28 Jun 2004 21:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Jun 2004     Volume: 10 Number: 6743

Today's topics:
    Re: How to use 2 DIFFERENT VERSIONS of the SAME MODULE  <noreply@gunnar.cc>
    Re: Non-unique columns via ODBC driver <il.fogg@bigpond.nospam.net.au>
        Setting environment variables from a Perl script (J. Romano)
    Re: Setting environment variables from a Perl script <1usa@llenroc.ude>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 29 Jun 2004 03:29:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to use 2 DIFFERENT VERSIONS of the SAME MODULE in the same perl program ?
Message-Id: <2kbv1cFi370U1@uni-berlin.de>

Yves Petinot wrote:
> Now my problem is that - obviously ??? - i cannot get perl to load
> the same module twice in a single interpreter.

Wouldn't something along this line be possible:

     my %oldINC = %INC;
     require '/path/to/old/version/module.pm';

     # read old format of the database

     %INC = %oldINC;
     require module.pm;   # load new version

     # save the database in the new format

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 29 Jun 2004 03:02:26 GMT
From: I & L Fogg <il.fogg@bigpond.nospam.net.au>
Subject: Re: Non-unique columns via ODBC driver
Message-Id: <6Z4Ec.69556$sj4.9317@news-server.bigpond.net.au>

Sorry, forgot to say that @cols does NOT contain the "Unused" column 
that the error message refers to.

I & L Fogg wrote:
> The error message is:
> 
> DBD::ODBC::db prepare failed: [Simba][Simba ODBC Driver]Non unique 
> column reference: Unused. (SQL-HY000)(DBD: st_prepare/SQLPrepare err=-1) 
> at ./dbcopy.pl line 346.
> 
> The code fragment that generates the message is:
> 
> my $select = q/SELECT / .
>                 join(',', @cols) .
>                 q/ FROM / .
>                 $src_dbh->quote_identifier($table);
> my $sel_sth = $src_dbh->prepare( $select );
> $sel_sth->execute();
> 
> Cheers, Iain
> 
> 
> ctcgag@hotmail.com wrote:
> 
>> I & L Fogg <il.fogg@bigpond.net.au> wrote:
>>
>>> I am trying to copy data from a proprietary ("semi"-relational) database
>>> to MySQL. Fortunately, the db vendor provides an ODBC driver, so getting
>>> the db schema and data is fairly straighforward using DBI and DBD::ODBC.
>>>
>>> I am encountering one problem that someone may be able to help me with.
>>>
>>> One of the tables in the db has several non-unique columns that are not
>>> actually used (there are 10-15 columns named "Unused").
>>>
>>> When I pull the table def using column_info, I can easily filter these
>>> out before creating an appropriate table definition in MySQL.
>>>
>>> The problem is that when I try to extract the data, the DBD::ODBC driver
>>>  barfs complaining about the non-unique columns (Unused). This happens
>>> even when I specifically exclude Unused from the SELECT clause. IWO, I
>>> use SELECT col_a, col_b FROM table; - not SELECT * FROM table;.
>>
>>
>>
>> What is the exact error that you get?
>>
>> Xho
>>
> 



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

Date: 28 Jun 2004 20:01:28 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Setting environment variables from a Perl script
Message-Id: <b893f5d4.0406281854.25a2c11d@posting.google.com>

Dear Perl community,

   In the past I have tried to find an answer to the question of how
to set environment variables in Perl scripts and make them last even
after the Perl script has finished.  I eventually found the response
mentioned in "perldoc -q environment", which basically says that it
can't be done (although there are work-arounds if you're willing to
use a few Unix tricks).

   However, I just recently discovered an easy way to do it. It works
like a charm in Unix.  (But unfortunately, it doesn't work so great on
Win32.)

   Basically, you write your script as normal, setting environment
variables, changing them, deleting them, and even changing
directories:

      $ENV{EDITOR} = "/usr/bin/vi";  # make vi default editor
      $ENV{PATH} .= ":/usr/bin/games";  # add games dir to path
      delete $ENV{PAGER};  # remove the pager environment variable
      chdir($ENV{HOME} . "/bin") or warn $!;  # change to my bin dir

But at the end of the script, add this line:

      exec $ENV{SHELL};

Run your script, and voila'!  The environment variable changes stick!

   I've found it's best to run your script with "exec" in front of it,
like so:

      exec perl script.pl

otherwise, you'll have to type an extra "exit" for every time you run
the script in order to fully exit the shell.

   Of course, this script assumes that your SHELL environment variable
exists and that it's set to your current shell.

   In DOS using ActiveState Perl, I've found that changing:

      exec $ENV{SHELL};

to:

      system 'cmd';

works better than changing it to:

      exec 'cmd';

(I have a hunch that ActivePerl implements the exec() call by
replacing it with system() and exit(), but I don't know for sure...)

   As far as I know, in DOS you can't run the exec command, so you'll
have to type an extra "exit" to close down the DOS terminal window. 
And deleting an evironment variable doesn't seem to work, either (at
least, not when I tried it).  No error is generated; it just doesn't
appear to work.

   So this approach doesn't fare so well in Win32 DOS, but it looks to
me that it works great in Unix.  This goes against what the perldoc
says, so if anybody knows a caveat about using this technique (on
Unix) that I don't see, please speak up.  But if there are no
problems, then I would think that this popular dilemma has been
solved.

   Happy Perling!

   -- Jean-Luc


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

Date: 29 Jun 2004 03:12:12 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Setting environment variables from a Perl script
Message-Id: <Xns9516EC0B3A600asu1cornelledu@132.236.56.8>

jl_post@hotmail.com (J. Romano) wrote in 
news:b893f5d4.0406281854.25a2c11d@posting.google.com:

> Dear Perl community,
> 
>    In the past I have tried to find an answer to the question of how
> to set environment variables in Perl scripts and make them last even
> after the Perl script has finished.  I eventually found the response
> mentioned in "perldoc -q environment", which basically says that it
> can't be done (although there are work-arounds if you're willing to
> use a few Unix tricks).

 ...

> But at the end of the script, add this line:
> 
>       exec $ENV{SHELL};
> 
> Run your script, and voila'!  The environment variable changes stick!

 ...

> This goes against what the perldoc says, so if anybody knows a 
> caveat about using this technique (on Unix) that I don't see, 
> please speak up.  But if there are no problems, then I would 
> think that this popular dilemma has been solved.
> 
>    Happy Perling!
> 
>    -- Jean-Luc

Jean-Luc:

This complete and utter nonsense: You have not changed the environment 
variables in the shell from which you started your program. Instead, you 
started a new shell with a new environment. That may be what you want but 
then it very well may not be. The answer to the FAQ stands.


-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6743
***************************************


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