Re: Looking for good Perl projects

2005-12-19 Thread Todd W

"Zentara" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Fri, 16 Dec 2005 18:40:50 -0800, [EMAIL PROTECTED] (Just Another)
> wrote:
>

> >
> >I want to learn Perl. I believe doing a project is the best way to learn
it.
> >It gives me motivation to find out more about the language and use it.
> >
> >So I am looking for good project. It will be even great if the project is
> >real-time and I can help fix or make something.
> >Can anyone please tell me about a project or point me to a place to find
> >one?
> >
>
> You can ask this on http://perlmonks.org , which by the way is a great
> place to get coding ideas and ask questions.
>
> Monks there are always looking for testers and/or people to take over
> maintenance of modules.
>

http://apprentice.perl.org/

This is the example application developed during the writing of the Mason
book.

Todd W.



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




Re: Reading the built-in number variables

2005-12-19 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> The issue:
> 
> I have a routine which builds a regex and 'knows' which paren matches to use
> afterwords.  For instance after a line such as:
> 
> use strict;
> my $data =~ m/^(\S+)\s+((\S+\s+)?(\S+))$/;
> 
> the routine 'knows' it wants $1 and $4.  Another pass through the regex will
> be different and the variables might be $2 and $5 for that regex.
> 
> The needed variable numbers are in an array:
> my @indexes;
> @indexes = (1, 4); for the first example above and:
> @indexes = (2, 5); for the second example above.
> 
> The question:
> Is there a way to reference the built-in variables: $1, $2, ... in a
> programmatic manner?
> 
> Something like:
> @values;
> push @values,${$_} foreach(@indexes);
> which didn't work for me, but you get the idea.
> 
> Yes, I already thought of a subroutine with a big ifels ladder that hard codes
> a test for $1, $2, ... but there has to be a more eloquent solution than this.

You may need to use the @- and @+ arrays, see:

perldoc perlvar

for an explanation.


John
-- 
use Perl;
program
fulfillment

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




Re: use constant

2005-12-19 Thread John W. Krahn
David Gilden wrote:
> Greetings, 

Hello,

> I looked for documentation on 'use constant'  but it has eluded it me.
> 
> my $path =  `pwd`;
> use constant UPLOAD_DIR => "/home/sites/site123/web/private/_data/";
> 
> 
> I want to get the Document Root at runtime and concatenate like such...
> 
> 
> my $path =  `pwd`;

You should probably use the Cwd module to do that.

> use constant UPLOAD_DIR => "$path/_data/";

use Cwd;

my $path;
BEGIN { $path = cwd }

use constant UPLOAD_DIR => "$path/_data/";



John
-- 
use Perl;
program
fulfillment

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




Reading the built-in number variables

2005-12-19 Thread vansyckellist
The issue:

I have a routine which builds a regex and 'knows' which paren matches to use
afterwords.  For instance after a line such as:

use strict;
my $data =~ m/^(\S+)\s+((\S+\s+)?(\S+))$/;

the routine 'knows' it wants $1 and $4.  Another pass through the regex will
be different and the variables might be $2 and $5 for that regex.

The needed variable numbers are in an array:
my @indexes;
@indexes = (1, 4); for the first example above and:
@indexes = (2, 5); for the second example above.

The question:
Is there a way to reference the built-in variables: $1, $2, ... in a
programmatic manner?

Something like:
@values;
push @values,${$_} foreach(@indexes);
which didn't work for me, but you get the idea.

Yes, I already thought of a subroutine with a big ifels ladder that hard codes
a test for $1, $2, ... but there has to be a more eloquent solution than this.

Thanks,
Don


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




use constant

2005-12-19 Thread David Gilden
Greetings,

I looked for documentation on 'use constant'  but it has eluded it me.

my $path =  `pwd`;
use constant UPLOAD_DIR => "/home/sites/site123/web/private/_data/";


I want to get the Document Root at runtime and concatenate like such...


my $path =  `pwd`;
use constant UPLOAD_DIR => "$path/_data/";

But this fails.

is this construct from the PERL 4 days?
constant UPLOAD_DIR

Any guidance would be greatly appreciated.

Thx,

Dave Gilden 
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

Cool music.From Guineé comes this CD of kora fusion, electronica  
[ Audition Mp3s at the URL below ]







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




Re: Constant Hash problem

2005-12-19 Thread John W. Krahn
Shawn Corey wrote:
> John W. Krahn wrote:
>> Shawn Corey wrote:
>>> for my $key ( sort keys %{ { STOPWORDS } } ){
>>>  my $value = ${ { STOPWORDS } }{$key};
>>
>>
>> In both lines you are copying the entire list to an anonymous hash. 
>> If you
>> want efficient code (and less punctuation) you should just use a hash.
> 
> Efficiency. There's that word again. If you truly want efficient code
> you won't create subroutines that return lists. They would return
> references to the lists or store them in global arrays.

You can't create a reference to a list.


John
-- 
use Perl;
program
fulfillment

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




Re: parse hash to module

2005-12-19 Thread JupiterHost.Net



You can do either but a refernce is more efficient:


Maybe I should use a reference as you suggest now Iam using ...

MyModule::function(%person)

and in my function :
my %person = @_;

For now I don't think I have an performance issue, - but ofcourse for now I 
have 2 copies. 


2 copies is twtice the memory :) plus its more maintainable and expandable.

Any drawbacks if I try some kind of asyncrhonous call if 
possbile ??.


Can you give us some code of what you mean by "asyncronouse call"?

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




Re: Constant Hash problem

2005-12-19 Thread Shawn Corey

John W. Krahn wrote:

Shawn Corey wrote:

for my $key ( sort keys %{ { STOPWORDS } } ){
 my $value = ${ { STOPWORDS } }{$key};



In both lines you are copying the entire list to an anonymous hash.  If you
want efficient code (and less punctuation) you should just use a hash.


Efficiency. There's that word again. If you truly want efficient code 
you won't create subroutines that return lists. They would return 
references to the lists or store them in global arrays.



--

Just my 0.0002 million dollars worth,
   --- Shawn

* Perl tutorials at http://perlmonks.org/?node=Tutorials

* Always write your code as though you aren't going to see it
* for another 25 years and then one day your boss comes up to you
* and says, "I want these changes and I want them yesterday!"

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_


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




Re: Constant Hash problem

2005-12-19 Thread John W. Krahn
Kevin Old wrote:
> On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
>>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.
> 
> So to achieve an anonymous hash I'd have to do the following, correct?
> 
> use constant STOPWORDS => {
>   'a' => 1,
>   'about' => 1,
>   'above' => 1,
>   'across' => 1,
>   'adj' => 1,
>   'after' => 1,
> };

Yes, that would store a reference to an anonymous hash in STOPWORDS.  Note
that only the reference would be a constant, the hash itself could still be
modified.


John
-- 
use Perl;
program
fulfillment

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




Re: Constant Hash problem

2005-12-19 Thread Kevin Old
On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
> 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.

So to achieve an anonymous hash I'd have to do the following, correct?

use constant STOPWORDS => {
  'a' => 1,
  'about' => 1,
  'above' => 1,
  'across' => 1,
  'adj' => 1,
  'after' => 1,
};

Thanks for your help,

Kevin
--
Kevin Old
[EMAIL PROTECTED]

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




about Excel modules

2005-12-19 Thread Jennifer Garner
hi,Lists,

I use Spreadsheet::WriteExcel /  Spreadsheet::ParseExcel modules to access
and write excel files.
The questions is, how to move the cursor in some a column to the top of next
column?Thanks.

Merry  Xmas! :-)


Re: parse hash to module

2005-12-19 Thread Ditlev, Unix Consulting
"JupiterHost.Net" <[EMAIL PROTECTED]> skrev i en meddelelse 
news:[EMAIL PROTECTED]
> Ditlev, Unix Consulting wrote:
>> Hi There,
>
> Hello,
>
>> I have some problems undestanding how to parse a hash to module of my 
>> own.
>>
>> I have this hash %person :
>> $person{$Name}{Name} = "xxx";
>> $person{$Name}{Id} = ;
>> @( $person{$Name} {Friends} )
>>
>> But what's the correct method for parsing this hash to my module ???
>>
>> I try something like mymodule::method(%person)
>>
>> or should I parse it as a reference ?
>> mymodule::method(\$person)
>
> I think "parse" is the wrong word :) i think you mean "pass"?

Yes its pass I mean.

>
> You can do either but a refernce is more efficient:
Maybe I should use a reference as you suggest now Iam using ...

MyModule::function(%person)

and in my function :
my %person = @_;

For now I don't think I have an performance issue, - but ofcourse for now I 
have 2 copies. Any drawbacks if I try some kind of asyncrhonous call if 
possbile ??.

Thnks for the input.

>
> MyModule::function(\%person);
>
> MyModule->method(\%person);
>
>
> sub ... {
>
>my ($person_ref) = @_;
>
> ...
>
> } 



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




Re: Split element in array

2005-12-19 Thread Ing. Branislav Gerzo
Andrej Kastrin [AK], on Monday, December 19, 2005 at 13:13 (+0100)
thinks about:

AK> So, following code split each line and print it.
AK> while (<>){
AK> @column = split(/\t/,$_);  # split current line, field separator set
AK> to tab
AK> print OUTPUT "$column[0]\t$column[1]\tt$column[2]\n";

if you can write this code, I'm sure, you can write the same, with "|"
as delimiter.
But here is example:

use strict;
use warnings;

$|++;
$, = "\t";

while (){
chomp;
next unless $_;
my @column = split /\t/;
print "$column[0]\t$column[1]" , split(/\|/, $column[2]) , "\n";
}
 
__DATA__
1   BRCA3   BRCA33|BRCA55   symbol 998
2   ABCB1   DASH|BASG|AVGA4 symbol 7583
2   ABCB1   DASHsymbol 7583

OUT:
1   BRCA3   BRCA33  BRCA55
2   ABCB1   DASHBASGAVGA4
2   ABCB1   DASH
-- 

How do you protect mail on web? I use http://www.2pu.net

["Angel in my armour, actress in my role."  -Rush]



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




Re: Split element in array

2005-12-19 Thread John Doe
Andrej Kastrin am Montag, 19. Dezember 2005 13.13:
> Ing. Branislav Gerzo wrote:
> >Andrej Kastrin [AK], on Monday, December 19, 2005 at 10:41 (+0100)
> >typed:
> >
> >AK> 1   BRCA3   BRCA33|BRCA55   symbol 998
> >AK> 2   ABCB1   DASH|BASG|AVGA4   symbol 7583
> >AK> In first step I split each row and store it in array; e.g.:
> >AK> @array=( '1',  'BRCA3',  'BRCA33|BRCA55',  'symbol998')
> >
> >if you want to split use split :) so simple, eh ?
> >
> >perldoc -f split
> >
> >I am not sure if split third column and add it to end to array is good
> >idea. I would use anonymous hashes for this, or AoA
>
> So, following code split each line and print it.
>
> while (<>){
> @column = split(/\t/,$_);  # split current line, field separator set
> to tab
> print OUTPUT "$column[0]\t$column[1]\tt$column[2]\n";
>
> If I'm right, I have to split third column and store it to @AoA. But how
> to print it (instead of $column[2] in my example?

If you are shure that '|' does not occur in any other columns than the third, 
you could simly split by '\t' *or* '|' :

use strict;
use warnings;

my $line='1   BRCA3   BRCA33|BRCA55   symbol 998';

# Note: the first '|' is the OR-operator in a regex
my @cols=split /\t|\|/, $line;

print join "-", @cols;

# gives:
1-BRCA3-BRCA33-BRCA55-symbol-998

> Additional problem: the length of third element variate. Is that  
> possible or have you any other suggestion.

Not sure what you mean by that. Unless in C, you don't have to think about the 
length of array items.



hth, joe

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




Re: Split element in array

2005-12-19 Thread Andrej Kastrin

Ing. Branislav Gerzo wrote:


Andrej Kastrin [AK], on Monday, December 19, 2005 at 10:41 (+0100)
typed:

AK> 1   BRCA3   BRCA33|BRCA55   symbol 998
AK> 2   ABCB1   DASH|BASG|AVGA4   symbol 7583
AK> In first step I split each row and store it in array; e.g.:
AK> @array=( '1',  'BRCA3',  'BRCA33|BRCA55',  'symbol998')

if you want to split use split :) so simple, eh ?

perldoc -f split

I am not sure if split third column and add it to end to array is good
idea. I would use anonymous hashes for this, or AoA

 


So, following code split each line and print it.

while (<>){
   @column = split(/\t/,$_);  # split current line, field separator set 
to tab

   print OUTPUT "$column[0]\t$column[1]\tt$column[2]\n";

If I'm right, I have to split third column and store it to @AoA. But how 
to print it (instead of $column[2] in my example?





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




Update All Modules CPAN.pm

2005-12-19 Thread Joel Divekar
Hi

Under CPAN when I run r command, I get the list of
updatable modules. Is there any command to get all
these modules auto updated. Thanks.

Regards

Joel
Mumbai, India
9821421965

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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




Re: Split element in array

2005-12-19 Thread Ing. Branislav Gerzo
Andrej Kastrin [AK], on Monday, December 19, 2005 at 10:41 (+0100)
typed:

AK> 1   BRCA3   BRCA33|BRCA55   symbol 998
AK> 2   ABCB1   DASH|BASG|AVGA4   symbol 7583
AK> In first step I split each row and store it in array; e.g.:
AK> @array=( '1',  'BRCA3',  'BRCA33|BRCA55',  'symbol998')

if you want to split use split :) so simple, eh ?

perldoc -f split

I am not sure if split third column and add it to end to array is good
idea. I would use anonymous hashes for this, or AoA

-- 

How do you protect mail on web? I use http://www.2pu.net

[Let's nuke the bridge we've burned 2,000 times before...]



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




Split element in array

2005-12-19 Thread Andrej Kastrin

Hi all

So, I have 4 fields file; fields are tab separated:

1   BRCA3   BRCA33|BRCA55   symbol 998
2   ABCB1   DASH|BASG|AVGA4   symbol 7583

In first step I split each row and store it in array; e.g.:

@array=( '1',  'BRCA3',  'BRCA33|BRCA55',  'symbol998')

Now I have to split  third  element - which is bar delimited ( i.e. 
BRCA33|BRCA55 --> split it to BRCA33 and BRCA55) and add it to @array. 
Additional problem: the length of third element variate. Is that  
possible or have you any other suggestion.


Thanks in advance, Andrej


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