Re: Regex assistance

2005-12-17 Thread M. Lewis

Charles K. Clarkson wrote:

M. Lewis  wrote:

: But I don't think the following regex is really doing that:
: 
: /micr[qw]o[-]ca[a]p[k][s]/i
: 
: Suggestions, corrections welcome.


 /Microcap|Micro-cap|MicroCaap|Micrqocap|MicrwoCap|MicroCapks/

One advantage of this regex is that new obfuscations can
be added very easily.


HTH,

Charles K. Clarkson


Thanks Charles. I see your point. Initially I had that for up to maybe 3 
or 4 variations. Then I thought I was improving it via the regex. Your 
method is certainly clear without even thinking about it a whole lot.


Thanks,
Mike

--

 IBM: Illustrious Busy Mice
  23:50:01 up 5 days,  6:59,  7 users,  load average: 0.08, 0.11, 0.23

 Linux Registered User #241685  http://counter.li.org

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




RE: Regex assistance

2005-12-17 Thread Charles K. Clarkson
M. Lewis  wrote:

: But I don't think the following regex is really doing that:
: 
: /micr[qw]o[-]ca[a]p[k][s]/i
: 
: Suggestions, corrections welcome.

 /Microcap|Micro-cap|MicroCaap|Micrqocap|MicrwoCap|MicroCapks/

One advantage of this regex is that new obfuscations can
be added very easily.


HTH,

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




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




beginners@perl.org

2005-12-17 Thread Charles K. Clarkson
JupiterHost.Net  wrote:

: I tried this also but stil can't do FH:
: 
: fake_print "wee";
: is easy *but*
: fake_print STDERR "wee";
: 
: :( what a fun little challenge :)

Eek. It's the missing (and expected) comma, I suppose. Perhaps a
source filter would help, though I think you need to use them with a
module. Filter::Simple may be of help.


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









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




Regex assistance

2005-12-17 Thread M. Lewis

I'm trying to match some obfuscations in some spam.

The words that I'm trying to catch are:

Microcap
Micro-cap
MicroCaap
Micrqocap
MicrwoCap
MicroCapks

But I don't think the following regex is really doing that:

   /micr[qw]o[-]ca[a]p[k][s]/i

Suggestions, corrections welcome.

--

 . REALITY.SYS Corrupted - Unable to recover Universe
  23:05:02 up 5 days,  6:14,  6 users,  load average: 0.12, 0.22, 0.49

 Linux Registered User #241685  http://counter.li.org

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




beginners@perl.org

2005-12-17 Thread JupiterHost.Net



For an Acme module I'm trying to make an alternative to print, but can;t
get goto to work with print:

I'd like this:

perl -mstrict -wle 'sub x {goto &print} x("hi");'

to work like this:

perl -mstrict -MCarp -wle 'sub x {goto &Carp::croak } x("hi");'

I'm sure I'm missing a simple namespace issue but main:: and UNIVERSAL::
aren't it and I can't seem to find it documented.

Any ideas what I'm missing?



Read the section "Overriding Built-in Functions" in perlsub.

perldoc perlsub


Good info John, I don;t want to change print() calls though I want to 
make foo() act just like print, the trick is getting print()s to Filehandles


fake_print "wee";
is easy *but*
fake_print STDERR "wee";

:) Its been an interesting mental exercise.

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




beginners@perl.org

2005-12-17 Thread JupiterHost.Net



Charles K. Clarkson wrote:


JupiterHost.Net  wrote:

: For an Acme module I'm trying to make an alternative to print, but
: can;t get goto to work with print:
: 
: I'd like this:
: 
:   perl -mstrict -wle 'sub x {goto &print} x("hi");'
: 
: to work like this:
: 
:   perl -mstrict -MCarp -wle 'sub x {goto &Carp::croak } x("hi");'
: 
: I'm sure I'm missing a simple namespace issue but main:: and

: UNIVERSAL:: aren't it and I can't seem to find it documented.
: 
: Any ideas what I'm missing?


CORE:: isn't it either. I think Carp::croak works because it is
an actual subroutine, not a built-in function. I'm not sure what you
are ultimately attempting, but you can override print first and
then goto print.

sub foo {
goto &print;
}

sub print {
return CORE::print @_;
}

foo('hi');


I tried this also but stil can't do FH:

fake_print "wee";
is easy *but*
fake_print STDERR "wee";

:( what a fun little challenge :)

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




beginners@perl.org

2005-12-17 Thread Charles K. Clarkson
JupiterHost.Net  wrote:

: For an Acme module I'm trying to make an alternative to print, but
: can;t get goto to work with print:
: 
: I'd like this:
: 
:   perl -mstrict -wle 'sub x {goto &print} x("hi");'
: 
: to work like this:
: 
:   perl -mstrict -MCarp -wle 'sub x {goto &Carp::croak } x("hi");'
: 
: I'm sure I'm missing a simple namespace issue but main:: and
: UNIVERSAL:: aren't it and I can't seem to find it documented.
: 
: Any ideas what I'm missing?

CORE:: isn't it either. I think Carp::croak works because it is
an actual subroutine, not a built-in function. I'm not sure what you
are ultimately attempting, but you can override print first and
then goto print.

sub foo {
goto &print;
}

sub print {
return CORE::print @_;
}

foo('hi');


HTH,

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



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




beginners@perl.org

2005-12-17 Thread John W. Krahn
JupiterHost.Net wrote:
> Howdy,

Hello,

> For an Acme module I'm trying to make an alternative to print, but can;t
> get goto to work with print:
> 
> I'd like this:
> 
>  perl -mstrict -wle 'sub x {goto &print} x("hi");'
> 
> to work like this:
> 
>  perl -mstrict -MCarp -wle 'sub x {goto &Carp::croak } x("hi");'
> 
> I'm sure I'm missing a simple namespace issue but main:: and UNIVERSAL::
> aren't it and I can't seem to find it documented.
> 
> Any ideas what I'm missing?

Read the section "Overriding Built-in Functions" in perlsub.

perldoc perlsub



John
-- 
use Perl;
program
fulfillment

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




beginners@perl.org

2005-12-17 Thread JupiterHost.Net

Howdy,

For an Acme module I'm trying to make an alternative to print, but can;t 
get goto to work with print:


I'd like this:

 perl -mstrict -wle 'sub x {goto &print} x("hi");'

to work like this:

 perl -mstrict -MCarp -wle 'sub x {goto &Carp::croak } x("hi");'

I'm sure I'm missing a simple namespace issue but main:: and UNIVERSAL:: 
aren't it and I can't seem to find it documented.


Any ideas what I'm missing?

TIA!

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




Re: Constant Hash problem

2005-12-17 Thread John W. Krahn
Shawn Corey wrote:
> John W. Krahn wrote:
>> You can't because perl implements constants using subroutines and
>> subroutines
>> can only return a list.
> 
> Perl subroutines return only lists but it converts them to hashes
> automatically:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use Data::Dumper;
> 
> sub list_to_hash {
>   return qw( a 1 b 2 c 3 );
> }
> 
> my %hash = list_to_hash();

Any list can be assigned to a hash just as a hash can be assigned to a list.

> print Dumper( \%hash );
> 
> __END__
> 
> 
> The thing about constant is that does not create a true constant; it
> creates a reference to an anonymous subroutine.

If it were an anonymous code reference then it would have to be stored in a
scalar and have a '$' sigil in front of it.  Unless it was stored in a type
glob and then "strict 'subs'" would not allow it to be used without
parentheses or the '&' sigil.  It has to be a subroutine in the current
package for strict not to complain.  See the "Constant Functions" section in
perlsub.

> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use constant STOPWORDS => map { $_, 1 } qw(a about above across adj after);
> 
> 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.

>   print "$key => $value\n";
> }


John
-- 
use Perl;
program
fulfillment

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




Re: A question about modules

2005-12-17 Thread vishal malik
I see. That's fine then. I didn't know that you were using the package 
name as a prefix to the subroutine name (DBConn::). In that case you 
don't need to use the Exporter. You only need it if you want to use the 
the subroutines as if they were in the current package (for example, 
db1(), and not DBConn::db1()).


Vishal


Robert wrote:


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 
   





 


__
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: A question about modules

2005-12-17 Thread Shawn Corey

Robert wrote:

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.


No, it doesn't. You can mix packages in any manner you like throughout 
your modules. Whether you should ...




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


If you want to make a proper module out of it, separate it into three, 
one for each connection. Then add (to each) a close connection 
subroutine, a commit, and a rollback. Change the names so that they are 
more descriptive of the data.


Always write your code as though you won't see it for 25 years and then 
have to change it yesterday.



--

Just my 0.0002 million dollars worth,
   --- Shawn

"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-17 Thread Shawn Corey

John W. Krahn wrote:

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


Perl subroutines return only lists but it converts them to hashes 
automatically:


#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

sub list_to_hash {
  return qw( a 1 b 2 c 3 );
}

my %hash = list_to_hash();

print Dumper( \%hash );

__END__


The thing about constant is that does not create a true constant; it 
creates a reference to an anonymous subroutine. You have to learn to use 
it as such:


#!/usr/bin/perl

use strict;
use warnings;

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

for my $key ( sort keys %{ { STOPWORDS } } ){
  my $value = ${ { STOPWORDS } }{$key};
  print "$key => $value\n";
}

__END__

Interpretation:

%{ { STOPWORDS } } means create an anonymous hash from the list returned 
by STOPWORDS and then dereference it.


${ { STOPWORDS } }{$key} means create an anonymous hash from the list 
returned by STOPWORDS, dereference it, and get the value for $key.



--

Just my 0.0002 million dollars worth,
   --- Shawn

"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: Looking for good Perl projects

2005-12-17 Thread vishal malik
I don't know if my answer would help. I was in the same shoes as you 
are. I was experienced in Java and not in Perl. My supervisor gave me a 
project to write JMS (Java Messaging Service) applications in perl, 
since it is much easier to access system resources in Perl. So, I used a 
Perl module called Inline::Java  to access  Java libraries from Perl. 

So, just pick one of your favorite Java projects where you had to access 
system resources (files, directories, command line options, processes 
etc. etc.), and do text processing (at which Perl happens to be really 
strong), and implement it in Perl. That way you can see how much easier 
Perl makes many things for you.


Vishal


Just Another wrote:


Hello all,

I am sure many before me asked this question. Could not locate it in
archive. So here I am.
I am new to Perl but not to programming. I have experience with software
development using Java and J2EE (back-end).

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?

Thank you all in advance.
-JustAnother

 


__
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]
 




Looking for good Perl projects

2005-12-17 Thread Just Another
Hello all,

I am sure many before me asked this question. Could not locate it in
archive. So here I am.
I am new to Perl but not to programming. I have experience with software
development using Java and J2EE (back-end).

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?

Thank you all in advance.
 -JustAnother