Re: Global scope

2009-04-23 Thread Vance E. Neff

Gunnar,

Thanks for your response!

That is what I started with but then I was getting the error:
xxx.pm: our variable $DataBaseType redeclared at xxx.pm line nn.

Well it turns out that error was caused by some other problem.  I did
not realize that our was not a function.  So you can't do something
like this:
our $variable = value1 if (something is true);
our $variable = value2 if (something else is true);

I fixed that and things seem to working as expected.

Thanks a lot!

Vance



Gunnar Hjalmarsson wrote:

Vance E. Neff wrote:

 I have a module options.pm defined as:
pre
package options;
use strict;
use base qw(Exporter);
our @EXPORT = qw(@BenefitsOptions %BenefitsOptions);
our @EXPORT_OK = qw();

our %BenefitsOptions =(
Dental=1,
Full=2,
Base=3,
Comm.=4,
END
);
@BenefitsOptions = ();

1;
/pre

and at the beginning of each of my CGI programs I have the line:
use options;

each program may access the variables defined in options.pm and may 
call other .pm modules that also need to have access to those same 
options.pm variables and those .pm modules might call another.pm 
modules that need to access those same variables defined in options.pm.


I read the perlmod, perlobj, Exporter, perltoot and frankly, I'm now 
more confused then ever.
I tried putting the variable declarations in a BEGIN block with no 
success.


I'm getting the error:
Global symbol xx requires explicit package name at module.pm line nn.


I for one get: Global symbol @BenefitsOptions requires explicit 
package name at options.pm line 14.


Besides that, you need to realize that when you say

use options;

in your script, you import the symbols into the package where that 
statement is placed, probably package main. The variables are indeed 
available also in other packages, but you need to either say


use options;

in each of those modules as well, or use the fully qualified name, e.g.

%options::BenefitsOptions


What is the best way to do this?


One way is to make use of the %ENV hash.

$ENV{BenefitsOptions} = {
Dental  = 1,
Full= 2,
Base= 3,
'Comm.' = 4,
};

Then you can say anywhere in your program:

foreach ( keys %{ $ENV{BenefitsOptions} } ) {
print $_ = $ENV{BenefitsOptions}-{$_}\n;
}





--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Need some explanation about these lines.

2009-04-23 Thread Raheel Hassan
Please see below, for some more questions.

On Tue, Apr 21, 2009 at 9:22 PM, Chas. Owens chas.ow...@gmail.com wrote:

 On Tue, Apr 21, 2009 at 12:37, Raheel Hassan raheel.has...@gmail.com
 wrote:
  Thanks a lot for your explanation. For adding support of CGI, SSL and
 MySQL
  in perl, what modules do i need to install. Please write down the
 commands
  for installing and uninstalling and also for checking that what modules
 are
  installed by default in perl as i have read the apache doccumentation
 where
  it is not mentioned clearly.
 snip

 CGI[1] is part of Core Perl, so you already have it.  SSL should be handled
 for you by Apache, but in case you need to make your own SSL connections
 you
 can use IO::Socket::SSL[2].  For MySQL you will need DBI[3] and
 DBD::mysql[4].

Can you please explain IO::Socket::SSL and DBD::mysql why we write in our
programs these lines..


 In general, if you need some code to do something you should look on
 CPAN[5].

 You can test whether a module is installed or not by saying

 perl -MModule::Name -le 'print ok'

I have written this command  * perl -DBD::Mysql -le*
and received this response *Recompile perl with -DDEBUGGING to use -D
switch (did you mean -d ?)
Unrecognized switch: -::Mysql  (-h will show valid options).
*



 If you get ok back then it is installed, if you get back an error then
 either it is not installed or you need to set PERL5LIB to point to where it
 is installed.

How i will set the PERL5LIB to point where it is installed.



 There are multiple methods of installing modules.  In order of my
 preference:

 * use a package manager:

apt-get install libdbi-perl

For adding MySql support which modules do i need to add.Because at CPAN web
site when i searched DBD and DBI there are many modules available.



 * use cpan

   cpan DBI

 * compile from a tarball

   1. download a tarball from CPAN
   2. decompress tarball
   3. change directory into the extracted tarball

Is it manadaotry


   4. perl Makefile.PL

What is the function of makefile.pl


   5. make
   6. make test

 if all of the steps above succeed without errors

   7. make install

 1. http://perldoc.perl.org/CGI.html
 2. http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm
 3. http://search.cpan.org/dist/DBI/DBI.pm
 4. http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm
 5. http://search.cpan.org

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.



Re: Need some explanation about these lines.

2009-04-23 Thread Chas. Owens
On Thu, Apr 23, 2009 at 05:45, Raheel Hassan raheel.has...@gmail.com wrote:
snip
 Can you please explain IO::Socket::SSL and DBD::mysql why we write in our
 programs these lines..
snip

IO::Socket::SSL is a module that lets you easily open SSL sockets.
See http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm for more information.

DBD::mysql is the database driver that lets DBI connect to MySQL.
See http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm for more information.

snip
 perl -MModule::Name -le 'print ok'

 I have written this command   perl -DBD::Mysql -le
 and received this response Recompile perl with -DDEBUGGING to use -D switch
 (did you mean -d ?)
 Unrecognized switch: -::Mysql  (-h will show valid options).
 
snip

That is because you did not run the right command.  You should have said

perl -MDBD::mysql -le 'print ok'

The switch is -M and its argument is the module name.  You also misspelled
the module name.  It is DBD::mysql, not DBD::Mysql.

snip
 If you get ok back then it is installed, if you get back an error then
 either it is not installed or you need to set PERL5LIB to point to where it
 is installed.

 How i will set the PERL5LIB to point where it is installed.
snip

export PERL5LIB=/path/to/install/directory

It would probably be a good idea to put that in whatever you use as a startup
script for your shell (e.g. ~/.profile, ~/.bash_profile, ~/.bashrc, etc.)

snip
 There are multiple methods of installing modules.  In order of my
 preference:

 * use a package manager:

    apt-get install libdbi-perl

 For adding MySql support which modules do i need to add.Because at CPAN web
 site when i searched DBD and DBI there are many modules available.
snip

You need DBI, DBD::mysql, and any modules they depend on (I don't believe they
are dependent on any other modules, but I cannot am not certain).

snip
 * compile from a tarball

   1. download a tarball from CPAN
   2. decompress tarball
   3. change directory into the extracted tarball

 Is it manadaotry
snip

Is what mandatory?  Compiling from a tarball is one option.  You can
also install
from a package manager or by using the cpan commmand (which automates
these steps
and downloads the dependencies).

snip

   4. perl Makefile.PL

 What is the function of makefile.pl
snip

You must, simply must, begin paying attention to the casing of text.
The name of
the script is Makefile.PL not makefile.pl.  Makefile.PL is part of the
ExtUtils::MakeMaker (or a compatible) module.  It is a Perl program that knows
how to look at your system, determine if it is okay to install the module,
and write a custom Makefile for your machine.  If you are familiar
with compiling
open source packages, it is similar to the configure script.

See http://search.cpan.org/dist/ExtUtils-MakeMaker for more information.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Cant find module when installing from cpan

2009-04-23 Thread Meir Yanovich
Hello all
im using cygwin perl , and when i what to install new module
via cpan , im keep getting the wornning :
for example :
-
install HTML::SimpleLinkExtor
Warning: Cannot install HTML::SimpleLinkExtor, don't know what it is.
Try the command

i /HTML::SimpleLinkExtor/

to find objects with matching identifiers.
-

even if i do :

i /HTML::SimpleLinkExtor/
it still dont find it
but when i try to do it in other pc in the same network
it does work
what can it be ?


Re: Need some explanation about these lines.

2009-04-23 Thread Raheel Hassan
Thanks for your reply, please look below for more queries.

On Thu, Apr 23, 2009 at 12:27 PM, Chas. Owens chas.ow...@gmail.com wrote:

 On Thu, Apr 23, 2009 at 05:45, Raheel Hassan raheel.has...@gmail.com
 wrote:
 snip
  Can you please explain IO::Socket::SSL and DBD::mysql why we write in our
  programs these lines..
 snip

 IO::Socket::SSL is a module that lets you easily open SSL sockets.
 See http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm for more information.

 DBD::mysql is the database driver that lets DBI connect to MySQL.
 See http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm for more
 information.


Ok got it


 snip
  perl -MModule::Name -le 'print ok'
 
  I have written this command   perl -DBD::Mysql -le
  and received this response Recompile perl with -DDEBUGGING to use -D
 switch
  (did you mean -d ?)
  Unrecognized switch: -::Mysql  (-h will show valid options).
  
 snip

 That is because you did not run the right command.  You should have said

 perl -MDBD::mysql -le 'print ok'

 The switch is -M and its argument is the module name.  You also misspelled
 the module name.  It is DBD::mysql, not DBD::Mysql.


Thanks yes it works now. One more think when i tried to check any other
modules like,
1-perl -MCrypt::SSLeay -le 'print ok' or
2-perl -MMIME-Base64 -le 'print ok' or
3-perl -MIO::Socket::SSL -le 'print ok'


It prompts this error. Can you please explain how can i read and understand
this problem and what changes do i need to make to remove this error.
*Can't locate Crypt/SSLeay.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.*


*Can't locate IO/Socket/SSL.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.*



 snip
  If you get ok back then it is installed, if you get back an error then
  either it is not installed or you need to set PERL5LIB to point to where
 it
  is installed.
 
  How i will set the PERL5LIB to point where it is installed.
 snip

 export PERL5LIB=/path/to/install/directory

 It would probably be a good idea to put that in whatever you use as a
 startup
 script for your shell (e.g. ~/.profile, ~/.bash_profile, ~/.bashrc, etc.)


Please explain this more, when i installed the perl i did not set any path
so perl installed on the default location and for executing the perl scripts
i use this (#!/usr/bin/perl) line first. Do you want that i will change my
first line? and i could not find PERL5LIB where is this folder?



 snip
  There are multiple methods of installing modules.  In order of my
  preference:
 
  * use a package manager:
 
 apt-get install libdbi-perl
 
  For adding MySql support which modules do i need to add.Because at CPAN
 web
  site when i searched DBD and DBI there are many modules available.
 snip

 You need DBI, DBD::mysql, and any modules they depend on (I don't believe
 they
 are dependent on any other modules, but I cannot am not certain).


Ok got it


 snip
  * compile from a tarball
 
1. download a tarball from CPAN
2. decompress tarball
3. change directory into the extracted tarball
 
  Is it manadaotry
 snip

 Is what mandatory?  Compiling from a tarball is one option.  You can
 also install
 from a package manager or by using the cpan commmand (which automates these
 steps and downloads the dependencies).

 snip
 
4. perl Makefile.PL
 
  What is the function of makefile.pl
 snip

 You must, simply must, begin paying attention to the casing of text.
 The name of
 the script is Makefile.PL not makefile.pl.  Makefile.PL is part of the
 ExtUtils::MakeMaker (or a compatible) module.  It is a Perl program that
 knows
 how to look at your system, determine if it is okay to install the module,
 and write a custom Makefile for your machine.  If you are familiar
 with compiling
 open source packages, it is similar to the configure script.

 See http://search.cpan.org/dist/ExtUtils-MakeMaker for more information.

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.



Re: Cant find module when installing from cpan

2009-04-23 Thread Chas. Owens
On Thu, Apr 23, 2009 at 07:09, Meir Yanovich meiry...@gmail.com wrote:
 Hello all
 im using cygwin perl , and when i what to install new module
 via cpan , im keep getting the wornning :
 for example :
 -
 install HTML::SimpleLinkExtor
 Warning: Cannot install HTML::SimpleLinkExtor, don't know what it is.
 Try the command

 i /HTML::SimpleLinkExtor/

 to find objects with matching identifiers.
 -

 even if i do :

 i /HTML::SimpleLinkExtor/
 it still dont find it
 but when i try to do it in other pc in the same network
 it does work
 what can it be ?


It sounds like you have a bad list of CPAN mirrors.  Type

perl -MCPAN -e shell

then at the prompt you get type

o conf urllist

This will list the places your version of CPAN is looking
for the module in.  You might also try

o conf urllist = http://cpan.glines.org/CPAN/ http://cpan.mirrorgeek.com

which will set the list of mirrors to the same ones I use.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Need some explanation about these lines.

2009-04-23 Thread Chas. Owens
On Thu, Apr 23, 2009 at 09:07, Raheel Hassan raheel.has...@gmail.com wrote:
snip
 Thanks yes it works now. One more think when i tried to check any other
 modules like,
 1-perl -MCrypt::SSLeay -le 'print ok' or
 2-perl -MMIME-Base64 -le 'print ok' or
 3-perl -MIO::Socket::SSL -le 'print ok'


 It prompts this error. Can you please explain how can i read and understand
 this problem and what changes do i need to make to remove this error.
 Can't locate Crypt/SSLeay.pm in @INC (@INC contains: /etc/perl
 /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5
 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
 /usr/local/lib/site_perl .).
 BEGIN failed--compilation aborted.
snip

This error says that perl looked in
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
and the current directory
for the module and could not find it.  This means that either
you do not have that module installed or it is installed in
a directory perl does not know to look in.  You can use the
environment variable PERL5LIB to tell perl about other directories
to look in.


 snip
  If you get ok back then it is installed, if you get back an error
  then
  either it is not installed or you need to set PERL5LIB to point to
  where it
  is installed.
 
  How i will set the PERL5LIB to point where it is installed.
 snip

 export PERL5LIB=/path/to/install/directory

 It would probably be a good idea to put that in whatever you use as a
 startup
 script for your shell (e.g. ~/.profile, ~/.bash_profile, ~/.bashrc, etc.)

 Please explain this more, when i installed the perl i did not set any path
 so perl installed on the default location and for executing the perl scripts
 i use this (#!/usr/bin/perl) line first. Do you want that i will change my
 first line? and i could not find PERL5LIB where is this folder?

PERL5LIB is an environment variable.  It holds a list of places to look
for modules in the same way PATH holds a list of places to look for
executable files.  It is only necessary if you install modules in a
non-standard location.  For instance, I install modules in my home
directory to avoid having to become root and to make uninstalling
them easier, so I set PERL5LIB like this in my ~/.bash_profile:

export PERL5LIB=~/perl/lib/perl5/site_perl

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: An image of a swiss-army chainsaw

2009-04-23 Thread Jay Savage
On Mon, Apr 20, 2009 at 6:14 PM, Robert Citek robert.ci...@gmail.com wrote:
 Hello all,

 I am giving a presentation soon and will be talking a bit about perl.
 I'd like to include an image about perl that describes it as the Swiss
 army chainsaw.  Ideally, I'd like to have a red chainsaw with the
 white Swiss cross.  Unfortunately, my Googling for images hasn't turn
 anything up.  The closest I could find is this:

 http://www.horstmann.com/bigj/help/compiler/tutorial.html

 I could use Gimp to cut and paste a white cross on the chainsaw.  But
 was wondering if anyone has an image or knows of one that I can use.

 Regards,
 - Robert


Hi Robert,

I've never found that art, either, but I've gotten a lot of mileage
out of the Wenger Giant:

http://www.campist.com/archives/wenger-giant-swiss-army-knife.html

HTH,

-- j

--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/