Inserting Image in a button

2007-05-02 Thread Somu

Lets say, i have an image at E:/icons/ttt so, how do i show it on a
button created using Tk. I tried to learn from the widget application,
but they have some specific folder, INC or something..

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regexp problem

2007-05-02 Thread Howard Sherman
Glad you got the answer. Next time, please work harder on explaining your 
problem so the community can understand what you want and benefit from the 
solution.

Somu <[EMAIL PROTECTED]> wrote: I got the answer and its working fine.. 
Actually i made a TicTacToe
game using Tk. The buttons have are like as below:
 l o r
 m p s
 n q t
 and i keep adding the character alternatingly to 2 strings.. When any
of the strings reaches length >= 3 then i start checking for any
pattern out of the eight..

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





Re: New to OO Perl

2007-05-02 Thread Robert Boone

You may want to seperate your initialization from instantiation.

sub new {

my ( $class, $data ) = @_;

my $self = bless {}, $class;
$self->init();

   return $self;

}

sub init {
my ($self) = @_;
$self->{image_magick_object} = Image::Magick::new();

my $error = $data->{image_magick_object}->Read( $data->{path} );
croak $error if $error;
}

Future subclasses won't need a new sub and supply there own init sub:

sub init {
my ($self) = @_;
$self->SUPER::init()

$self->{'more_data'} = [];
}




On May 2, 2007, at 5:27 PM, Nigel Peck wrote:



Hi all,

I'm new to writing Object Oriented Perl and am hoping for some advice?

I found the need to use Image::Magick tonight and in order to reuse  
the code in future I put it in a package of subs.


I then thought it seemed like a good opportunity to try writing an  
OO module so I did.


However I'm not sure that I couldn't do it better by making use of  
inheritance although I'm not sure how to do it and also looking for  
any other suggestions.


A cut down version of my code goes like this...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/usr/bin/perl

use strict;
use warnings;

use Carp;

my $error;
my $obj_image;

my $obj_image = MIS::Common::Image_magick->new( { path => '/home/ 
nigel/scripts/taylor1.jpg' } );


$obj_image->resize ( { geometry => '360' } );
$obj_image->crop ( { geometry => '360x480' } );

$obj_image->output ( { path => '/home/nigel/scripts/taylor/ 
thumbnail.jpg' } );


##

package MIS::Common::Image_magick;

use Image::Magick;

sub new {

my ( $class, $data ) = @_;

$data->{image_magick_object} = Image::Magick::new();

my $error = $data->{image_magick_object}->Read( $data->{path} );
croak $error if $error;

return bless $data, $class;

}

sub output {

my ( $self, $args ) = @_;

my $error = $self->{image_magick_object}->Write( $args->{path} );
croak $error if $error;

}

sub resize {

my ( $self, $args ) = @_;

	$error = $self->{image_magick_object}->Resize( geometry => $args-> 
{geometry} );

croak $error if $error;

}

sub crop {

my ( $self, $args ) = @_;

	$error = $self->{image_magick_object}->Crop( geometry => $args-> 
{geometry} );

croak $error if $error;

}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

What could I do better?

TIA.

Cheers,
Nigel


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread Jeff Pang

2007/5/3, Jay Savage <[EMAIL PROTECTED]>:



Not quite. -M reports "Script start time minus file modification time,
in days." To put it another way, -M reports how old the file was when
the script started running. Or more appropriately, how old the file
would have been when the script started running, assuming its current
mtime. That's not the same thing as how old the file is when the test
is executed.

For short-lived scripts, the difference is mainly a technicalityFor
long-running programs, though, -M's behavior has serious consequences.
-M on its own is useless in, say, a daemon that runs for days or
months--if you're lucky--or even in a program that just takes a while
to process all its data. The math to correct for running time is
complicated by -M returning fractional days. To use -M effectively,
you need to do something like:



This is right.Under modperl using -M is a tricky since modperl scripts
are running all the time.:)

--
Chinese Practical Mod_perl book online
http://home.arcor.de/jeffpang/mod_perl/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regexp problem

2007-05-02 Thread Somu

I got the answer and its working fine.. Actually i made a TicTacToe
game using Tk. The buttons have are like as below:
l o r
m p s
n q t
and i keep adding the character alternatingly to 2 strings.. When any
of the strings reaches length >= 3 then i start checking for any
pattern out of the eight..

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




New to OO Perl

2007-05-02 Thread Nigel Peck


Hi all,

I'm new to writing Object Oriented Perl and am hoping for some advice?

I found the need to use Image::Magick tonight and in order to reuse the 
code in future I put it in a package of subs.


I then thought it seemed like a good opportunity to try writing an OO 
module so I did.


However I'm not sure that I couldn't do it better by making use of 
inheritance although I'm not sure how to do it and also looking for any 
other suggestions.


A cut down version of my code goes like this...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/usr/bin/perl

use strict;
use warnings;

use Carp;

my $error;
my $obj_image;

my $obj_image = MIS::Common::Image_magick->new( { path => 
'/home/nigel/scripts/taylor1.jpg' } );


$obj_image->resize ( { geometry => '360' } );
$obj_image->crop ( { geometry => '360x480' } );

$obj_image->output ( { path => 
'/home/nigel/scripts/taylor/thumbnail.jpg' } );


##

package MIS::Common::Image_magick;

use Image::Magick;

sub new {

my ( $class, $data ) = @_;

$data->{image_magick_object} = Image::Magick::new();

my $error = $data->{image_magick_object}->Read( $data->{path} );
croak $error if $error;

return bless $data, $class;

}

sub output {

my ( $self, $args ) = @_;

my $error = $self->{image_magick_object}->Write( $args->{path} );
croak $error if $error;

}

sub resize {

my ( $self, $args ) = @_;

	$error = $self->{image_magick_object}->Resize( geometry => 
$args->{geometry} );

croak $error if $error;

}

sub crop {

my ( $self, $args ) = @_;

	$error = $self->{image_magick_object}->Crop( geometry => 
$args->{geometry} );

croak $error if $error;

}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

What could I do better?

TIA.

Cheers,
Nigel


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if a file in a directory is older than 20 mins.

2007-05-02 Thread Chris E. Rempola

Chas Owens wrote:>

#!/usr/bin/perl

for my $file (<.* *>) {
   print "$file is ", int(24*60 * -M $file), " minutes old\n";
}


Thanks Chas!  Exactly what I was looking for =).

Cheers
-Chris

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




imlib2: draw special-chars

2007-05-02 Thread Raphael
Hi Users...

I want to write a text into a picture with Image::Imlib2
with this line:

$image->draw_text($x, $y, "$text");

before this I define also the font-path, the font-color and load after
the font...

If the text is this:

10/17

all went fine and the text is on the picture...

but if the text is

10°/17° (10 degree / 17 degree)

then the text is only 10 and after it's finish...

what can I do to draw the degree-sign... I don't like to draw a circle
the graphic way... 

Google don't show me a solution...
Thanks a lot for any help.

have nice evening...
Raphael

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread John W. Krahn
Jay Savage wrote:
> On 5/2/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
>> Chris E. Rempola wrote:
>> >
>> > Could someone point me in the right direction to write out a simple
>> Perl
>> > script to check for old files in a particular directory that are older
>> > than 20 mins.  Is there a module to grab current timestamp?  Thanks.
>>
>> Check out
>>
>>   perldoc -f -x
>>
>> and look at the -M option. It gives the age of the file in days in
>> floating point, so if its greater than 20/(24*60) your file is older than
>> twenty minutes.
> 
> Not quite. -M reports "Script start time minus file modification time,
> in days." To put it another way, -M reports how old the file was when
> the script started running. Or more appropriately, how old the file
> would have been when the script started running, assuming its current
> mtime. That's not the same thing as how old the file is when the test
> is executed.
> 
> For short-lived scripts, the difference is mainly a technicality For
> long-running programs, though, -M's behavior has serious consequences.
> -M on its own is useless in, say, a daemon that runs for days or
> months--if you're lucky--or even in a program that just takes a while
> to process all its data. The math to correct for running time is
> complicated by -M returning fractional days. To use -M effectively,
> you need to do something like:
> 
>my $minutes = 20;
>if ( (-M "file") + ((time - $^T) / (24 * 60 * 60)) >
> $limit_minutes/(24*60) )
>{ do something }
> 
> Usually it's easier to just use the mtime from stat():
> 
>if (time - (stat "file")[9] > $minutes * 60)
>{ do something }

Or you could simply do:

$^T = time;

Before you do the file test which will put the current time into $^T which is
what -M uses to calculate the file time:

$ perl -le'
$file = shift;
print -M $file;
$^T = time() - 86400;
print -M $file;
' yourfile.txt
8.75521990740741
7.75521990740741



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if a file in a directory is older than 20 mins.

2007-05-02 Thread Chas Owens

On 5/2/07, Chris E. Rempola <[EMAIL PROTECTED]> wrote:

Hi All:

Can anyone give me some direction in writing a simple Perl script for
checking files in a particular directory thats older than 20 mins.  Is
there a module I can use to grab the current time-stamp of a file?
Thanks in advance

-Chris


The -M test will tell you how old a file is in days relative to the
start of the script.  To get minutes you can multiply that value by
24*60


#!/usr/bin/perl

for my $file (<.* *>) {
   print "$file is ", int(24*60 * -M $file), " minutes old\n";
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Win32 script cannot read command line argument.

2007-05-02 Thread Vladimir Lemberg

Hi David,

Thanks a lot! It works -)
My association was "C:\Perl\bin\perl.exe" "%1"

Vladimir

- Original Message - 
From: "Wagner, David --- Senior Programmer Analyst --- WGO" 
<[EMAIL PROTECTED]>

To: "Vladimir Lemberg" <[EMAIL PROTECTED]>; 
Sent: Wednesday, May 02, 2007 2:11 PM
Subject: RE: Win32 script cannot read command line argument.




-Original Message-
From: Vladimir Lemberg [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 02, 2007 14:01
To: beginners@perl.org
Subject: Win32 script cannot read command line argument.

Hi All,

My script is unable to read argument when I'm executing it
as: script.pl .
However, when I'm running it as: perl script.pl  -
it works fine.

I did associate perl scripts with Perl as explained in
ActivePerl-Winfaq4.htm
All my scripts, which doesnt require any arguments works file.

Your folder assocation looks like:

"C:\Perl\bin\perl.exe" "%1" %*
If like this, then should be working. Been using this for what
seems like forever.


I have WinXP with Service Pack 2.

All appriciate any help to resolve it.

Thanks,
Vladimir


 Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us

**
This message contains information that is confidential and proprietary to 
FedEx Freight or its affiliates.  It is intended only for the recipient 
named and for the express  purpose(s) described therein.  Any other use is 
prohibited.

**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Win32 script cannot read command line argument.

2007-05-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO

> -Original Message-
> From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 02, 2007 14:01
> To: beginners@perl.org
> Subject: Win32 script cannot read command line argument.
> 
> Hi All,
> 
> My script is unable to read argument when I'm executing it 
> as: script.pl .
> However, when I'm running it as: perl script.pl  - 
> it works fine.
>  
> I did associate perl scripts with Perl as explained in 
> ActivePerl-Winfaq4.htm
> All my scripts, which doesnt require any arguments works file. 
Your folder assocation looks like:

"C:\Perl\bin\perl.exe" "%1" %*
If like this, then should be working. Been using this for what
seems like forever.
>  
> I have WinXP with Service Pack 2. 
>  
> All appriciate any help to resolve it.
>  
> Thanks,
> Vladimir

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread Jay Savage

On 5/2/07, Rob Dixon <[EMAIL PROTECTED]> wrote:

Chris E. Rempola wrote:
> Hi All:
>
> Could someone point me in the right direction to write out a simple Perl
> script to check for old files in a particular directory that are older
> than 20 mins.  Is there a module to grab current timestamp?  Thanks.

Check out

  perldoc -f -x

and look at the -M option. It gives the age of the file in days in
floating point, so if its greater than 20/(24*60) your file is older than
twenty minutes.

HTH,

Rob


Not quite. -M reports "Script start time minus file modification time,
in days." To put it another way, -M reports how old the file was when
the script started running. Or more appropriately, how old the file
would have been when the script started running, assuming its current
mtime. That's not the same thing as how old the file is when the test
is executed.

For short-lived scripts, the difference is mainly a technicalityFor
long-running programs, though, -M's behavior has serious consequences.
-M on its own is useless in, say, a daemon that runs for days or
months--if you're lucky--or even in a program that just takes a while
to process all its data. The math to correct for running time is
complicated by -M returning fractional days. To use -M effectively,
you need to do something like:

   my $minutes = 20;
   if ( (-M "file") + ((time - $^T) / (24 * 60 * 60)) >
$limit_minutes/(24*60) )
   { do something }

Usually it's easier to just use the mtime from stat():

   if (time - (stat "file")[9] > $minutes * 60)
   { do something }

Best,

-- jay
--
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!


Win32 script cannot read command line argument.

2007-05-02 Thread Vladimir Lemberg
Hi All,

My script is unable to read argument when I'm executing it as: script.pl 
.
However, when I'm running it as: perl script.pl  - it works fine.
 
I did associate perl scripts with Perl as explained in ActivePerl-Winfaq4.htm
All my scripts, which doesnt require any arguments works file. 
 
I have WinXP with Service Pack 2. 
 
All appriciate any help to resolve it.
 
Thanks,
Vladimir

Re: crypt() and /etc/shadow entries do not match?

2007-05-02 Thread jbuburuz

Thanks John and Chas!

> [EMAIL PROTECTED] wrote:
>> Hey folks,
>
> Hello,
>
>> I have been using crypt for a while. No problems until recently.
>>
>> Problem crypt does not return a hash that matches getpwnam(). I have
>> been
>> using crypt for a long time without any problems.
>>
>> Bellow is test script I have using for testing hashs. The output of the
>> script bellow is as follows(Note passwd  for user "test" is "hello"):
>>
>> linux:/tmp# ./perltest.pl
>> Enter a string to encrypt with DES: hello
>> Enter two random alphanumerics to be used as a salt:n$!
>>
>> "hello" encrypted using the perl crypt() function and salt "$!" returns:
>> $!8VHq6xLWgQc  $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
>>
>> crypt returns= $!8VHq6xLWgQc
>> hash value returned by getpwnam= $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
>>
>> I have tested crypt() on debian, and redhat. Same problems. The has
>> values
>> do not match each other.
>>
>> Please help, any suggestions.
>>
>> thanks
>>
>> jerry
>>
>> #
>> Perl script bellow
>> #
>> #!/usr/bin/perl
>>
>> print "Enter a string to encrypt with DES:n";
>> chomp(my $string = ); #Take the input from the user and remove
>> the n
>>
>> print "Enter two random alphanumerics to be used as a salt:n";
>> chomp(my $salt = );
>>
>> my $encrypted_string = crypt($string,$salt); #take the string and the
>> salt
>> and put through crypt()
>>
>> $pass = (getpwnam(test))[1];
>
> You need to use the old password as the salt, so change that to:
>
> my $pass = ( getpwnam 'test' )[ 1 ];
>
> my $encrypted_string = crypt $string, $pass;

Great! the above works! John your correction works!

Thanks Chas your perldoc helped out a lot as well.

>
>
>> print qq~
>> "$string" encrypted using the perl crypt() function and salt "$salt"
>> returns:
>> $encrypted_string  $pass
>> ~;
>
>
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you can special-order
> certain sorts of tools at low cost and in short order.   -- Larry Wall
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>

thanks again,

jerry


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread John W. Krahn
Chris E. Rempola wrote:
> Hi All:

Hello,

> Could someone point me in the right direction to write out a simple Perl
> script to check for old files in a particular directory that are older
> than 20 mins.  Is there a module to grab current timestamp?  Thanks.

You could probably use the -M file test operator:

perldoc -f -M



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread Rob Dixon

Chris E. Rempola wrote:

Hi All:

Could someone point me in the right direction to write out a simple Perl 
script to check for old files in a particular directory that are older 
than 20 mins.  Is there a module to grab current timestamp?  Thanks.


Check out

 perldoc -f -x

and look at the -M option. It gives the age of the file in days in
floating point, so if its greater than 20/(24*60) your file is older than
twenty minutes.

HTH,

Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Checking if a file in a directory is older than 20 mins.

2007-05-02 Thread Chris E. Rempola

Hi All:

Can anyone give me some direction in writing a simple Perl script for 
checking files in a particular directory thats older than 20 mins.  Is 
there a module I can use to grab the current time-stamp of a file? 
Thanks in advance


-Chris

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Checking if files are older than 20 mins in a particular directory

2007-05-02 Thread Chris E. Rempola

Hi All:

Could someone point me in the right direction to write out a simple Perl 
script to check for old files in a particular directory that are older 
than 20 mins.  Is there a module to grab current timestamp?  Thanks.






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: crypt() and /etc/shadow entries do not match?

2007-05-02 Thread Chas Owens

On 5/2/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 5/2/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> On 5/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> snip
> > I have tested crypt() on debian, and redhat. Same problems. The has values
> > do not match each other.
> snip
>
> It looks like your /etc/shadow file is not using crypt to store the
> passwords on that system.
>
> from man shadow
>The password field must be filled. The encrypted password consists of
>13 to 24 characters from the 64 character alphabet a thru z, A thru Z,
>0 thru 9, \. and /. Optionally it can start with a "$" character. This
>means the encrypted password was generated using another (not DES)
>algorithm. For example if it starts with "$1$" it means the MD5-based
>algorithm was used.
>

Nevermind, John's email is the one you should pay attention to


The relevant doc is perldoc -f crypt:
  When verifying an existing digest string you should use the
  digest as the salt (like "crypt($plain, $digest) eq $digest").
  The SALT used to create the digest is visible as part of the
  digest.  This ensures crypt() will hash the new string with the
  same salt as the digest.  This allows your code to work with
  the standard crypt and with more exotic implementations.  In
  other words, do not assume anything about the returned string
  itself, or how many bytes in the digest matter.

  Traditionally the result is a string of 13 bytes: two first
  bytes of the salt, followed by 11 bytes from the set
  "[./0-9A-Za-z]", and only the first eight bytes of the digest
  string mattered, but alternative hashing schemes (like MD5),
  higher level security schemes (like C2), and implementations on
  non-UNIX platforms may produce different strings.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: crypt() and /etc/shadow entries do not match?

2007-05-02 Thread Chas Owens

On 5/2/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 5/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip
> I have tested crypt() on debian, and redhat. Same problems. The has values
> do not match each other.
snip

It looks like your /etc/shadow file is not using crypt to store the
passwords on that system.

from man shadow
   The password field must be filled. The encrypted password consists of
   13 to 24 characters from the 64 character alphabet a thru z, A thru Z,
   0 thru 9, \. and /. Optionally it can start with a "$" character. This
   means the encrypted password was generated using another (not DES)
   algorithm. For example if it starts with "$1$" it means the MD5-based
   algorithm was used.



Nevermind, John's email is the one you should pay attention to

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: crypt() and /etc/shadow entries do not match?

2007-05-02 Thread Chas Owens

On 5/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip

I have tested crypt() on debian, and redhat. Same problems. The has values
do not match each other.

snip

It looks like your /etc/shadow file is not using crypt to store the
passwords on that system.

from man shadow
  The password field must be filled. The encrypted password consists of
  13 to 24 characters from the 64 character alphabet a thru z, A thru Z,
  0 thru 9, \. and /. Optionally it can start with a "$" character. This
  means the encrypted password was generated using another (not DES)
  algorithm. For example if it starts with "$1$" it means the MD5-based
  algorithm was used.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: crypt() and /etc/shadow entries do not match?

2007-05-02 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> Hey folks,

Hello,

> I have been using crypt for a while. No problems until recently.
> 
> Problem crypt does not return a hash that matches getpwnam(). I have been 
> using crypt for a long time without any problems.
> 
> Bellow is test script I have using for testing hashs. The output of the
> script bellow is as follows(Note passwd  for user "test" is "hello"):
> 
> linux:/tmp# ./perltest.pl
> Enter a string to encrypt with DES: hello
> Enter two random alphanumerics to be used as a salt:n$!
> 
> "hello" encrypted using the perl crypt() function and salt "$!" returns:
> $!8VHq6xLWgQc  $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
> 
> crypt returns= $!8VHq6xLWgQc
> hash value returned by getpwnam= $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
> 
> I have tested crypt() on debian, and redhat. Same problems. The has values
> do not match each other.
> 
> Please help, any suggestions.
> 
> thanks
> 
> jerry
> 
> #
> Perl script bellow
> #
> #!/usr/bin/perl
> 
> print "Enter a string to encrypt with DES:n";
> chomp(my $string = ); #Take the input from the user and remove the n
> 
> print "Enter two random alphanumerics to be used as a salt:n";
> chomp(my $salt = );
> 
> my $encrypted_string = crypt($string,$salt); #take the string and the salt
> and put through crypt()
> 
> $pass = (getpwnam(test))[1];

You need to use the old password as the salt, so change that to:

my $pass = ( getpwnam 'test' )[ 1 ];

my $encrypted_string = crypt $string, $pass;


> print qq~
> "$string" encrypted using the perl crypt() function and salt "$salt" returns:
> $encrypted_string  $pass
> ~;



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regexp problem

2007-05-02 Thread Rob Dixon

Somu wrote:


Actually thats what i was looking for: l.*o.*r

So, if the user entered string is to be matched for 'lpt', then i'll
use l.*p.*t ?

And to match 'npr' i use .*n.*p.*r ?


Somu you need to tell us exactly what match you want, otherwise we can't
tell you whether something will work or not. Are you simply checking whether
the input string contains all of the match characters? I would forget about
sorting the input string and do it as in the program below. But please
explain what the problem is instead of asking how to implement a solution
which may not be optimal.

HTH,

Rob


use strict;
use warnings;

print "Match\n" if match('orql', 'lor');

sub match {
 
 my ($input, $match) = @_;
 
 foreach (split '', $match) {

   return '' unless $input =~ /\Q$_/;
 }
 
 return 1;

}





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




crypt() and /etc/shadow entries do not match?

2007-05-02 Thread jbuburuz
Hey folks,

I have been using crypt for a while. No problems until recently.

Problem crypt does not return a hash that matches getpwnam(). I have been 
using crypt for a long time without any problems.

Bellow is test script I have using for testing hashs. The output of the
script bellow is as follows(Note passwd  for user "test" is "hello"):

linux:/tmp# ./perltest.pl
Enter a string to encrypt with DES: hello
Enter two random alphanumerics to be used as a salt:n$!

"hello" encrypted using the perl crypt() function and salt "$!" returns:
$!8VHq6xLWgQc  $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1

crypt returns= $!8VHq6xLWgQc
hash value returned by getpwnam= $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1

I have tested crypt() on debian, and redhat. Same problems. The has values
do not match each other.

Please help, any suggestions.

thanks

jerry

#
Perl script bellow
#
#!/usr/bin/perl

print "Enter a string to encrypt with DES:n";
chomp(my $string = ); #Take the input from the user and remove the n

print "Enter two random alphanumerics to be used as a salt:n";
chomp(my $salt = );

my $encrypted_string = crypt($string,$salt); #take the string and the salt
and put through crypt()

$pass = (getpwnam(test))[1];

print qq~
"$string" encrypted using the perl crypt() function and salt "$salt" returns:
$encrypted_string  $pass
~;

End of script







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Open() and glob EXPR

2007-05-02 Thread Somu

Ok i got that.. I also checked the perldoc -f q

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Regexp problem

2007-05-02 Thread Somu

Actually thats what i was looking for: l.*o.*r

So, if the user entered string is to be matched for 'lpt', then i'll
use l.*p.*t ?

And to match 'npr' i use .*n.*p.*r ?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Perl plugin for eclipse

2007-05-02 Thread 万朝伟

Nath, Alok (STSD) 写道:

Hi,
  Has anybody used any perl plugin for Eclipse ?
  Please share your thoughts.
  I am looking for one.
Thanks
Alok.


  

Komodo is recommended

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Perl plug-in for eclipse

2007-05-02 Thread Paul
Yes, it works great.  But for some programs, it's still better to run from
command line, cause I've seen some that won't run in it for some reason. 
Well, especially ones looking for <>.  It'll run via the gui, but you
gotta guess what it's asking and type it in.


On Wed, May 2, 2007 8:11 am, Nath, Alok (STSD) wrote:
> Hi,
>   Has anybody used any perl plugin for Eclipse ?
>   Please share your thoughts.
>   I am looking for one.
> Thanks
> Alok.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Perl plugin for eclipse

2007-05-02 Thread Kumar, Akshay
http://e-p-i-c.sourceforge.net/ 

-Original Message-
From: Nath, Alok (STSD) [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 02, 2007 5:41 PM
To: beginners@perl.org
Subject: Perl plugin for eclipse

Hi,
  Has anybody used any perl plugin for Eclipse ?
  Please share your thoughts.
  I am looking for one.
Thanks
Alok.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Perl plugin for eclipse

2007-05-02 Thread Nath, Alok (STSD)
Hi,
  Has anybody used any perl plugin for Eclipse ?
  Please share your thoughts.
  I am looking for one.
Thanks
Alok.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Illegal use of undefined subroutine..

2007-05-02 Thread Randal L. Schwartz
> "Somu" == Somu  <[EMAIL PROTECTED]> writes:

Somu> Actually, that was just an example to explain my problem. I am facing
Somu> this problem when i use Tk. Any subroutine associated with the
Somu> -command option of a button widget.

Somu> use Tk;
Somu> my $mw = MainWindow->new;
Somu> my $b = $mw->Button(-text=>'hello',-command=>sub { &welcome })->pack;
Somu> my $l = $mw->Label(-text=>'')->pack;
Somu> sub welcome {
Somu> $l->configure(-text=>'welcome buddy'); }
Somu> MainLoop;

Somu> in the above example, i have to add a declaration
Somu> sub welcome;
Somu> before declaring $b, but cant define it.

Just a guess, but could you try changing that to -command => \&welcome ?
There's no need to make a closure to hold a global that doesn't yet exist,
when the coderef is a perfectly valid coderef. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/