Re: Constant Hash problem

2005-12-16 Thread John W. Krahn
Kevin Old wrote:
> On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
>>Kevin Old wrote:
>>
>>>I'm trying to define a constant hash and have the following:
>>>
>>>use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj 
>>>after);
>>>
>>>I do not get a hash from this.
>>You are defining STOPWORDS as a list.
> 
> What is the correct way to define STOPWORDS as a hash?

You can't because perl implements constants using subroutines and subroutines
can only return a list.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Constant Hash problem

2005-12-16 Thread Kevin Old
On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
> Kevin Old wrote:
> > Hello everyone,
>
> Hello,
>
> > I'm trying to define a constant hash and have the following:
> >
> > use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj 
> > after);
> >
> > I do not get a hash from this.
>
> You are defining STOPWORDS as a list.

What is the correct way to define STOPWORDS as a hash?

Thanks for your help,
Kevin
--
Kevin Old
[EMAIL PROTECTED]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: A question about modules

2005-12-16 Thread Robert
I simply use:

my $dbh = DBConn::db1();

It does the right connection (i.e. subroutine) from the DBConn package and I 
didn't use Exporter. I should also mention that DBConn is in the same folder 
and the calling script so maybe that makes a difference.

I am probably going to go back and do a proper module of it so I can get in 
the "habit" of doing so.

Robert

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> It is okay to do something like that. However, you should not use the 
> package
> declaration on the top. If you do that, you will have to use the Exporter 
> module
> to export your subroutine names to your script when you say "use DBConn;"
>
> Quoting Robert <[EMAIL PROTECTED]>:
>
>> I have broken out my DB connection calls into a small module. It isn't
>> anything fancy so it is basically:
>>
>> package DBConn
>>
>> use strict;
>> use warnings;
>>
>> sub { # connection info for db1 }
>>
>> sub { # connection info for db2 }
>>
>> sub { # connection info for db3 }
>>
>> 1;
>>
>> The question is do I go through the formal process of creating a module 
>> for
>> everything (I use Module::Starter) or is it okay to do something like the
>> above for very small modules?
>>
>> Robert
>>
>>
>>
>>
>> -- 
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>  
>>
>>
>
>
>
>
> 
> This mail sent through www.mywaterloo.ca 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Constant Hash problem

2005-12-16 Thread John W. Krahn
Kevin Old wrote:
> Hello everyone,

Hello,

> I'm trying to define a constant hash and have the following:
> 
> use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj 
> after);
> 
> I do not get a hash from this.

You are defining STOPWORDS as a list.

> This does work, however:
> 
> my %stopwords = map { lc $_ , 1 } qw(a about above across adj after);
> use constant STOPWORDS => \%stopwords;

You are defining STOPWORDS as a hash reference.

> I'm wondering what I'm doing wrong in the first definition.

use constant STOPWORDS => { map { lc $_ , 1 } qw(a about above across adj
after) };


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Subst string

2005-12-16 Thread Wiggins d'Anconia
MARG wrote:
> Hi,
> 
> I'm trying to subst the string:
> # Include conf/extra/httpd-ssl.conf
> 
> for
> Include conf/extra/httpd-ssl.conf
> 
> with the command:
> perl -pi~ -e 's/# Include conf/extra/httpd-ssl.conf/Include
> conf/extra/httpd-ssl.conf/' /usr/local/httpd/conf/httpd.conf
> 
> but i get an error.
> 
> I've used this before with success.
> 
> Is it because of the white space between "Include" and "conf" ?
>

No, it is because the search string contains the same delimiter as the
expression is using, aka the '/'. You need to either escape the /
characters or change your delimiter,

perl -pi~ -e 's{# Include conf/extra/httpd-ssl.conf}{Include
> conf/extra/httpd-ssl.conf}' /usr/local/httpd/conf/httpd.conf

For instance,

http://danconia.org

> Any help would be apreciated.
> 
> Warm Regards,
> MARG
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Subst string

2005-12-16 Thread MARG
Hi,

I'm trying to subst the string:
# Include conf/extra/httpd-ssl.conf

for
Include conf/extra/httpd-ssl.conf

with the command:
perl -pi~ -e 's/# Include conf/extra/httpd-ssl.conf/Include
conf/extra/httpd-ssl.conf/' /usr/local/httpd/conf/httpd.conf

but i get an error.

I've used this before with success.

Is it because of the white space between "Include" and "conf" ?

Any help would be apreciated.

Warm Regards,
MARG

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Constant Hash problem

2005-12-16 Thread Wiggins d'Anconia
Kevin Old wrote:
> Hello everyone,
> 
> I'm trying to define a constant hash and have the following:
> 
> use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj 
> after);
> 
> I do not get a hash from this.
> 
> This does work, however:
> 
> my %stopwords = map { lc $_ , 1 } qw(a about above across adj after);
> use constant STOPWORDS => \%stopwords;
> 
> I'm wondering what I'm doing wrong in the first definition.
>

The second is only "sort of" constant. It creates a constant reference
to the hash, however the hash itself should still be editable which is
not probably what you wanted.

The problem is that constants are defined at compile time rather than
run time. You might be able to accomplish both, using a BEGIN { }
wrapper around the first.

HTH,

http://danconia.org


> Any help is appreciated!
> 
> Kevin
> --
> Kevin Old
> [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Freeze CPAN module version for just one script on system?

2005-12-16 Thread Xavier Noria

On Dec 16, 2005, at 20:36, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:

Hmm... is there a way to do this using the CPAN shell while still  
having any
dependency outside certain marked namespaces satisfied from the  
server's
main Perl installation? ( Rather than having a local install of  
every single

dependency I only need to lock in a couple of unstable modules. )

I would prefer to use the CPAN interface the manage the module  
installation

since it will make upgrades less of a hassle.

Any ideas?


See the section "CPAN under $HOME" of "Life with CPAN":

http://sial.org/howto/perl/life-with-cpan/

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Constant Hash problem

2005-12-16 Thread Kevin Old
Hello everyone,

I'm trying to define a constant hash and have the following:

use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj after);

I do not get a hash from this.

This does work, however:

my %stopwords = map { lc $_ , 1 } qw(a about above across adj after);
use constant STOPWORDS => \%stopwords;

I'm wondering what I'm doing wrong in the first definition.

Any help is appreciated!

Kevin
--
Kevin Old
[EMAIL PROTECTED]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Freeze CPAN module version for just one script on system?

2005-12-16 Thread pbdgny
Hi,

On 12/16/05, Mohammed Shameer <[EMAIL PROTECTED]> wrote:
>
> Hi,
>   I would have done this.
> 1) download  the module source and dependencies and untar
> 2) perl Makefile.pl
> 3) Modify PERLPREFIX,SITEPREFIX,VENDORPREFIX in Makefile  to a local
> folder
> 4) while starting the application set  PERLLIB environment variable to
> include
>the  folder.


Hmm... is there a way to do this using the CPAN shell while still having any
dependency outside certain marked namespaces satisfied from the server's
main Perl installation? ( Rather than having a local install of every single
dependency I only need to lock in a couple of unstable modules. )

I would prefer to use the CPAN interface the manage the module installation
since it will make upgrades less of a hassle.

Any ideas?

Thanks,
David


Re: press key to external program

2005-12-16 Thread Chris Devers
On Fri, 16 Dec 2005, Ing. Branislav Gerzo wrote:

> I unpack some files in my script with external unpacker (unrar, unzip, 
> unarj, unace...). But some files are passworded, to continue in script 
> I have to press some key. It is some easy way how to do this ?

If you have to interact with a text-mode program, curses may help you.

http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q3.8.html
( ^ possibly outdated advice )

http://search.cpan.org/dist/Curses/
http://search.cpan.org/dist/Curses/gen/make.Curses.pm 


-- 
Chris Devers

ÑGÍôƒ
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: one odd question

2005-12-16 Thread vmalik
There is a VRML-Perl module. You can go to CPAN (http://www.cpan.org/), and look
for it.

Vishal


Quoting "Gomez, Juan" <[EMAIL PROTECTED]>:

> Hello guys!!
>  
> I have to ask you a very odd question
>  
> I am working on a project that involves VRML (yes I know)
> these project what it does is that if you give him a board file
> (like a CAD file) import a file from a server and this project 
> what it does is that it gives you a 3D view of the board
> with all the components and we are obtaining the values 
> from the board fileand we are using C++ to extract the data 
>  
> but the problem is that sometime it takes forever!!!
> is there any way I can do this with Perl?
>  
> I meant interact with VRML
>  
> I just don't know the full range of the capabilties of Perl
>  
> thank you
>  
>  
>  
>  
>  
> Armando Gomez Guajardo 
> Process Engineer
> Work Ph   956 547 6438 
> Beeper956 768 4070
> 
>  
> 
> 





This mail sent through www.mywaterloo.ca

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Sockets recv question

2005-12-16 Thread Scott
I am working on a sockets based script. My question is what if the length
of the recv is likely to change, but you need the following recv lines not
to get corrupted?

Example

$client->recv($bkserv,128);
$client->recv($bkuser,128);
$client->recv($dumppath,128);
$client->recv($dumpname,128);

Any one of these may be more or less than 128. Say in the top two lines
bkserv ends up 12, then the bkuser ends up part of the $bkserv scalar.
This information is likely to vary based on the system it is running
against.

Thanks..
Scott




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




one odd question

2005-12-16 Thread Gomez, Juan



Hello guys!!
 
I have to ask you a very odd 
question
 
I am working on a project that involves VRML 
(yes I know)
these project what it does is that if you 
give him a board file
(like a CAD file) import a file from a 
server and this project 
what it does is that it gives you a 3D view 
of the board
with all the components and we are 
obtaining the values 
from the board fileand we are using C++ to extract the data 
 
but the problem is that sometime it takes 
forever!!!
is there any way I can do this with 
Perl?
 
I meant interact with VRML
 
I just don't know the full range of the 
capabilties of Perl
 
thank you
 
 
 
 
 
Armando Gomez 
Guajardo Process EngineerWork Ph   956 547 
6438 Beeper    956 768 
4070
 


press key to external program

2005-12-16 Thread Ing. Branislav Gerzo
Hi all,

I unpack some files in my script with external unpacker
(unrar, unzip, unarj, unace...). But some files are passworded, to
continue in script I have to press some key. It is some easy way how
to do this ?

I am think about eval and alarm...

/brano


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: sub args as pointers or values?

2005-12-16 Thread Bryan R Harris


Thanks, Chris and Wiggins!

- Bryan



> On Fri, 16 Dec 2005, Bryan R Harris wrote:
> 
>> I remember from my C++ class that when you pass arguments to
>> subroutines you can pass them either as a pointer to the real variable
>> (so you modify the original if you change it), or as a copy (which you
>> can change all you want and not affect the original).
> 
> The terminology I was taught for this was "pass by reference" to denote
> sending around pointers to the same physical memory location, and "pass
> by value" to denote sending around abstract logical pieces of
> information that are typically copies of the original variable.
> 
> Like most languages, Perl has ways to do both of these.
> 
> Normal argument passing in Perl is basically like pass by value or pass
> by copy. You don't generally have to do anything extra to get this
> behavior.
> 
> To pass a reference to a variable to a subroutine, prefix the variable
> name with a backslash: \%myhash, [EMAIL PROTECTED], etc. You can capture this
> reference into a scalar -- $hashref = \%myhash -- and then access the
> contents of the reference by dereferencing: $$hashref{"KEY"} = "VALUE";
> 
> This is explained in detail in perldoc's perlref and perlobj pages:
> 
> http://perldoc.perl.org/perlref.html
> http://perldoc.perl.org/perlobj.html
> 
> It's also in books like _Learning Perl Objects, References & Modules_
> and _Object Oriented Perl_:
> 
> http://www.oreilly.com/catalog/lrnperlorm/
> http://www.amazon.com/exec/obidos/tg/detail/-/0596004788?v=glance
> http://books.perl.org/book/200
> 
> http://www.manning.com/Conway/
> http://www.amazon.com/exec/obidos/tg/detail/-/188491?v=glance
> http://books.perl.org/book/171
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: sub args as pointers or values?

2005-12-16 Thread Chris Devers
On Fri, 16 Dec 2005, Bryan R Harris wrote:

> I remember from my C++ class that when you pass arguments to 
> subroutines you can pass them either as a pointer to the real variable 
> (so you modify the original if you change it), or as a copy (which you 
> can change all you want and not affect the original).

The terminology I was taught for this was "pass by reference" to denote 
sending around pointers to the same physical memory location, and "pass 
by value" to denote sending around abstract logical pieces of 
information that are typically copies of the original variable.

Like most languages, Perl has ways to do both of these.

Normal argument passing in Perl is basically like pass by value or pass 
by copy. You don't generally have to do anything extra to get this 
behavior.

To pass a reference to a variable to a subroutine, prefix the variable 
name with a backslash: \%myhash, [EMAIL PROTECTED], etc. You can capture this 
reference into a scalar -- $hashref = \%myhash -- and then access the 
contents of the reference by dereferencing: $$hashref{"KEY"} = "VALUE";

This is explained in detail in perldoc's perlref and perlobj pages:

http://perldoc.perl.org/perlref.html
http://perldoc.perl.org/perlobj.html

It's also in books like _Learning Perl Objects, References & Modules_ 
and _Object Oriented Perl_:

http://www.oreilly.com/catalog/lrnperlorm/
http://www.amazon.com/exec/obidos/tg/detail/-/0596004788?v=glance
http://books.perl.org/book/200

http://www.manning.com/Conway/
http://www.amazon.com/exec/obidos/tg/detail/-/188491?v=glance
http://books.perl.org/book/171



-- 
Chris Devers

Ù³ÄCIü[Ð-Q˜
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: sub args as pointers or values?

2005-12-16 Thread Wiggins d'Anconia
Bryan R Harris wrote:
> 
> I remember from my C++ class that when you pass arguments to subroutines you
> can pass them either as a pointer to the real variable (so you modify the
> original if you change it), or as a copy (which you can change all you want
> and not affect the original).
> 
> Is there a perl equivalent of both of those two concepts?
> 
> - B
> 
> 
> 

perldoc perlsub

"Sort of" is the short answer. Perl uses a sort of "smart"
pass-by-reference. But unless you pass explicit references then if you
assign the arguments to named variables then you have pass-by-value. The
details are best found in the above docs.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




sub args as pointers or values?

2005-12-16 Thread Bryan R Harris


I remember from my C++ class that when you pass arguments to subroutines you
can pass them either as a pointer to the real variable (so you modify the
original if you change it), or as a copy (which you can change all you want
and not affect the original).

Is there a perl equivalent of both of those two concepts?

- B



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: A question about modules

2005-12-16 Thread vmalik
It is okay to do something like that. However, you should not use the package
declaration on the top. If you do that, you will have to use the Exporter module
to export your subroutine names to your script when you say "use DBConn;"

Quoting Robert <[EMAIL PROTECTED]>:

> I have broken out my DB connection calls into a small module. It isn't 
> anything fancy so it is basically:
> 
> package DBConn
> 
> use strict;
> use warnings;
> 
> sub { # connection info for db1 }
> 
> sub { # connection info for db2 }
> 
> sub { # connection info for db3 }
> 
> 1;
> 
> The question is do I go through the formal process of creating a module for 
> everything (I use Module::Starter) or is it okay to do something like the 
> above for very small modules?
> 
> Robert
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 





This mail sent through www.mywaterloo.ca

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Freeze CPAN module version for just one script on system?

2005-12-16 Thread Mohammed Shameer
Hi,
  I would have done this.
1) download  the module source and dependencies and untar
2) perl Makefile.pl
3) Modify PERLPREFIX,SITEPREFIX,VENDORPREFIX in Makefile  to a local folder
4) while starting the application set  PERLLIB environment variable to include 
   the  folder.
 there might be easier methods, I am a beginner

Thanks
Shameer

On Friday 16 December 2005 14:42, [EMAIL PROTECTED] wrote:
> Hello,
>
> I would like to use a complex CPAN module group that is currently under
> active revision. (Task::Catalyst)
>
> Is there a way to use the cpan shell to install a "local" version of the
> module for just this application so I don't have to worry about things
> breaking if the main CPAN library install on the server upgrades this
> module?   (Other modules outside the specified "module group" that are
> required can be used from the regular Perl install as I am not too worried
> about those APIs changing...  )
>
> From what I understand, I think that there is a way to make a per-user
> library area, but this is not quite the per-app application granularity I
> need.
>
> Any ideas?
>
> Thanks,
> David

-- 
If you can't convince them, confuse them.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: : shared

2005-12-16 Thread Beast

Jeff Pang wrote:

Do you mean something as below?

my $foo::shared = '';
my @bar::shared = ();



No. Take a lokk at this code:

http://tobyinkster.co.uk/Software/linux/jukebox/jukebox-2.19b.pl

...
# Shared variables for passing info around.
my @queue : shared = ();# queue
my $tQueue : shared = '';   # pretty-printed queue
my @allSongs : shared = (); # list of songs
my $nowSong : shared = '';  # current song file name
my $nowSongDetails : shared = '';   # pretty song pretty-printed details
my $instaQuit : shared = FALSE; # used to pass back and forth quitting 
data
my $vol : shared = 100; # volume
my $mute : shared = 0;  # used to store volume when jukebox is 
muted
my $dofades : shared = 1;   # should we use the fade effect?
...




--

--beast


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: : shared

2005-12-16 Thread John W. Krahn
Beast wrote:
> 
> I saw code which has something like :
> 
> 
> my $foo : shared = '';
> my @bar : shared = ();
> ...
> 
> What is that means?

perldoc attributes
perldoc perlthrtut
perldoc perlsub


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Inserting line at a specific point

2005-12-16 Thread John W. Krahn
MARG wrote:
> Hi,

Hello,

> I want to insert these two lines in Apache's httpd.conf:
> LoadModule python_module modules/mod_python.so
> AddModule mod_python.c
> 
> just right after the line
> LoadModule php5_module modules/libphp5.so
> 
> and not at the end of the file (with a simple echo "AddModule
> mod_python.c" >> httpd.conf).
> 
> I've searched the web, tried my best, but couldn't make it.
> 
> Can you help me please ?

perl -i~ -pe'?LoadModule php5_module modules/libphp5.so? && ( $_ .=
"LoadModule python_module modules/mod_python.so\nAddModule mod_python.c\n" )'
httpd.conf


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: : shared

2005-12-16 Thread Jeff Pang
Do you mean something as below?

my $foo::shared = '';
my @bar::shared = ();

I don't know what you writted too.


-Original Message-
>From: Beast <[EMAIL PROTECTED]>
>Sent: Dec 16, 2005 5:00 AM
>To: beginners@perl.org
>Subject: : shared
>
>
>I saw code which has something like :
>
>
>my $foo : shared = '';
>my @bar : shared = ();
>...
>
>What is that means?
>
>
>
>-- 
>
>--beast
>
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: copy using perl on windows

2005-12-16 Thread Charles K. Clarkson
Umesh T G  wrote:

: It is not copying the files, though there is no error printed on
: screen. :(

It looks like you are not using warnings and strict. That
pretty much stops most errors from going to the screen.

Your problem *may* be in @src. In perl, the file separator is
"/", not "\". "\" is an escape character. Change the array to
reflect perl's path structure.

According to the File::Copy docs:


 All functions return 1 on success, 0 on failure.
 $! will be set if an error was encountered.


See the code below for an example.


: my array contains all the source file names like this
:
: "..\..\..\AlgSource\ISA\C64x\asm\idct_8x8_c64xplus_h.asm"
:  "..\..\..\AlgSource\ISA\C64x\asm\jpegdec_ti_vld_n_mcu.asm"
:  "..\..\..\AlgSource\ISA\C64x\C\byte_unstuff.c"
:  "..\..\..\AlgSource\ISA\C64x\C\dc_pred_comp.c"

Change this to:

'../../../AlgSource/ISA/C64x/asm/idct_8x8_c64xplus_h.asm',
'../../../AlgSource/ISA/C64x/asm/jpegdec_ti_vld_n_mcu.asm',
'../../../AlgSource/ISA/C64x/C/byte_unstuff.c',
'../../../AlgSource/ISA/C64x/C/dc_pred_comp.c',


: Now, I want to copy all these files into a new dir   D:\newsrc\

The copy() function you are using requires two file names.
The second argument has to be a file name and file path, not a
directory name. To extract the file name from a path above use the
File::Basename module.


: I tried like this,
: 
:
: Use File::Copy
:
: $newpath="D:\\newsrc\\";

my $newpath = 'D:/newsrc/';


: foreach $source (@src)

foreach my $source (@src)


: {
: print "COpying $source to $newpath \n";
: copy ("$source","$newpath");

Don't quote variables needlessly. You need to code something
which will add a file name to $newpath. Always check I/O
operations for success.

copy( $source, "$newpath$filename" ) or
die qq(Cannot copy "$source" to "$newpath$filename": $!);


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




: shared

2005-12-16 Thread Beast


I saw code which has something like :


my $foo : shared = '';
my @bar : shared = ();
...

What is that means?



--

--beast


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Freeze CPAN module version for just one script on system?

2005-12-16 Thread pbdgny
Hello,

I would like to use a complex CPAN module group that is currently under
active revision. (Task::Catalyst)

Is there a way to use the cpan shell to install a "local" version of the
module for just this application so I don't have to worry about things
breaking if the main CPAN library install on the server upgrades this
module?   (Other modules outside the specified "module group" that are
required can be used from the regular Perl install as I am not too worried
about those APIs changing...  )

>From what I understand, I think that there is a way to make a per-user
library area, but this is not quite the per-app application granularity I
need.

Any ideas?

Thanks,
David


RE: DBI problem

2005-12-16 Thread Charles K. Clarkson
john  wrote:

: Thanks, Charles, for your suggestions. I think I've incorporated
: most of them.

You're welcome.


: Your regex is a lot more practical than what I was using.

I wouldn't have used it a year ago. Perhaps I'm getting
better. :)


: Here is the improved script. I can live with the one warning
: "Newline in left-justified string for printf at ./describe_skus.pl
: line 29".

That's strange, there doesn't seem to be a new line in that
format string. Try adding this to the top of the script and see if
you can track down the problem. You might get a better idea of how
to correct this problem. Did you leave it wrapped like it is in the
email perhaps? The format should all be on one line.

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

use diagnostics;

===

I indented and wrapped this to make it easier to read.

: while ( my $columns = $sth2->fetchrow_arrayref() ) {
: printf OUTFILE ("%-4d %-40s %-22s %d",
  "@$columns[0]",
  "@$columns[1]",
  "@$columns[2]",
  "@$columns[3]"
  );
: print OUTFILE "\n";
: }

I assume you chose fetchrow_arrayref() over fetchrow_array()
because it's more efficient. Good. Now we need to break
you of this double-quoting variables habit. :)

The code above can be written without the double quotes. The
only warning is from the printf.

while ( my $columns = $sth2->fetchrow_arrayref() ) {
printf OUTFILE (
'%-4d %-40s %-22s %d',
@$columns[0],
@$columns[1],
@$columns[2],
@$columns[3],
);
print OUTFILE "\n";
}

You can play along at home with this test code (no database
needed).

while ( my $columns = [0..3] ) {
printf (
'%-4d %-40s %-22s %d',
@$columns[0],
@$columns[1],
@$columns[2],
@$columns[3],
);
print "\n";
last;
}

When I run this, I get the following error. We can avoid this
by dropping the parenthesis. See code below.

printf (...) interpreted as function at a.pl line 10.


while ( my $columns = [0..3] ) {
printf
'%-4d %-40s %-22s %d',
@$columns[0],
@$columns[1],
@$columns[2],
@$columns[3];

print "\n";
last;
}


The new line (\n) can be added into the format and allow us to
eliminate the second print statement. Special characters like this
and \t are the only reasons for putting formats in double quotes.
Only single quoted strings are normally needed.

while ( my $columns = [0..3] ) {
printf
"%-4d %-40s %-22s %d\n",
@$columns[0],
@$columns[1],
@$columns[2],
@$columns[3];

last;
}

While this code does not give any errors, it is more common to
use the -> operator.

while ( my $columns = [0..3] ) {
printf
"%-4d %-40s %-22s %d\n",
$columns->[0],
$columns->[1],
$columns->[2],
$columns->[3];

last;
}

There is another way to go. In this example we deference the
array reference with the @{} operator.

while ( my $columns = [0..3] ) {
printf
"%-4d %-40s %-22s %d\n",
@{ $columns };

last;
}

As a shortcut we can use @$columns.

while ( my $columns = [0..3] ) {
printf
"%-4d %-40s %-22s %d\n",
@$columns;

last;
}

Taking this back to the database example, we end up with this.

while ( my $columns = $sth2->fetchrow_arrayref() ) {
printf "%-4d %-40s %-22s %d\n", @$columns;
}


Or, if you are feeling lucky, this might do.

printf "%-4d %-40s %-22s %d\n", @$_ while $sth2->fetchrow_arrayref();


If the "sku" column is unique, only one row is returned and
this will do the trick.

printf "%-4d %-40s %-22s %d\n", @{ $sth2->fetchrow_arrayref() };

# or (maybe):

printf "%-4d %-40s %-22s %d\n", $sth2->fetchrow_array();


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Inserting line at a specific point

2005-12-16 Thread Mulander
2005/12/16, MARG <[EMAIL PROTECTED]>:
> Hi,
>
> I want to insert these two lines in Apache's httpd.conf:
> LoadModule python_module modules/mod_python.so
> AddModule mod_python.c
>
> just right after the line
> LoadModule php5_module modules/libphp5.so
>
> and not at the end of the file (with a simple echo "AddModule
> mod_python.c" >> httpd.conf).
>
> I've searched the web, tried my best, but couldn't make it.
>
> Can you help me please ?
>
> Warm Regards,
> MARG
>

Hi there,
You can do it either by going through every line of the file and
insert your lines just   as you recognize the line after witch your's
should apper ( read the conf file and create another one on the fly ).
Or you can also try and use Tie::File witch allows you to dynamically
bind an array to a file, so  when you would let's say do $file[11] =
'hey'; the string 'hey' should immidietly appear on the 12 line of the
file. Try it out more info in:
perldoc Tie::File

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




copy using perl on windows

2005-12-16 Thread Umesh T G
I want to copy few files from a source directory to a destination directory

my array contains all the source file names like this

"..\..\..\AlgSource\ISA\C64x\asm\idct_8x8_c64xplus_h.asm"
 "..\..\..\AlgSource\ISA\C64x\asm\jpegdec_ti_vld_n_mcu.asm"
 "..\..\..\AlgSource\ISA\C64x\C\byte_unstuff.c"
 "..\..\..\AlgSource\ISA\C64x\C\dc_pred_comp.c"


Now, I want to copy all these files into a new dir   D:\newsrc\


I tried like this,


Use File::Copy

$newpath="D:\\newsrc\\";

foreach $source (@src)
{
print "COpying $source to $newpath \n";
copy ("$source","$newpath");

 }



It is not copying the files, though there is no error printed on screen. :(



Can you please help.?





thanks

satya