Re: adding functionality

2004-12-15 Thread JupiterHost.Net

Christopher Spears wrote:
Here is the latest version of my script:
#!/usr/bin/perl -w
use strict;
my $Pixarport = 7498;
my $host = "lex";
my $Pixarfile = $Pixarport."@".$host;
my @input;
my $line;
my $line_number;
my $file_length;
my @features_array;
my @handles_array;
my $handles;
my $features;
my $sizeof;
my $counter = 0;
my $answer;
my $string;
my $userid = `whoami`;
@input = `cat clicenses_output`;
Why not
 my @input = `cat ...
here instead of my'ing it above and then assigning to it here?
$file_length = scalar(@input);
Sama as above...
print "Is ".$userid." your userid (Y or N)?";
Why not
print "Is $userid your userid (Y or N)?";
the "".$var."" is pointless and confusing...
$answer = ;
if ($answer =~ /^[nN]$/) {
print "Enter your userid: ";
chomp($userid = );
}elsif ($answer =~ /^[yY]$/) {
print $userid." is your userid.\n";

same as above...
} 

print "Do you wish to:"."\n";
same as above...
print "1) remove all of your floating licenses at
once"."\n";
same as above...
print "2) remove them one at a time"."\n";

same as above...
You could even use a here doc:
print <
$answer = ;
same as first "why not" above...
i know that wasn't your original question but it may be easier for you 
if the code was more readable...

HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: moving to the next line

2004-12-15 Thread Charles K. Clarkson
Christopher Spears <[EMAIL PROTECTED]> wrote:

: So everybody wants to know what I have been working
: on.  I finally got permission to post this:
: 
: #!/usr/bin/perl -w
: use strict;
: 
: my $Pixarport = 7498;
: my $host = "lex";
: my $Pixarfile = $Pixarport."@".$host;
: my @line;
: my $line;
: my @features_array;
: my @handles_array;
: my $handles;
: my $features;
: my $sizeof;
: my $counter = 0;
: my $answer;
: my $string;

Don't declare all your variables at the beginning
of the script. It works in other languages, but not
in perl. Declare them as you go.

: LOOKING_LINES: while(@line = `cat clicenses_output`){

Stop using line labels. They work in perl, but they
are rarely needed.
[snip]

: This is the line giving me issues:
: 
: LOOKING_HANDLES: while (@line = `cat
: clicenses_output`);
: 
: Basically, after I grab $feature I need to move to the
: next element of the array @line and start looking at
: each element until I hit Users again (in which case I
: grab the feature and the process begins again).  So
: how do I make the big jump to that next element?

Why is this output in a loop? Does `cat clicenses_output`
place a new array in @line each time through? Where does it
break its listing?

HTH,

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










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




How to detect present X-Server

2004-12-15 Thread Matthias Kraatz
Hi everybody -
is there a way to make a perl program find out whether a valid X-Server 
is running?
I.e. $ENV{DISPLAY} is not a dummy address, if set.

Thanks,
   Matthias

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



adding functionality

2004-12-15 Thread Christopher Spears
Here is the latest version of my script:

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

my $Pixarport = 7498;
my $host = "lex";
my $Pixarfile = $Pixarport."@".$host;
my @input;
my $line;
my $line_number;
my $file_length;
my @features_array;
my @handles_array;
my $handles;
my $features;
my $sizeof;
my $counter = 0;
my $answer;
my $string;
my $userid = `whoami`;

@input = `cat clicenses_output`;
$file_length = scalar(@input);

print "Is ".$userid." your userid (Y or N)?";
$answer = ;
if ($answer =~ /^[nN]$/) {
print "Enter your userid: ";
chomp($userid = );
}elsif ($answer =~ /^[yY]$/) {
print $userid." is your userid.\n";
} 

print "Do you wish to:"."\n";
print "1) remove all of your floating licenses at
once"."\n";
print "2) remove them one at a time"."\n";
$answer = ;

if ($answer == 1) {
foreach ($line_number = 0; $line_number <=
$file_length; $line_number++){
last if ($line_number == $file_length);
$line = $input[$line_number];
next unless $line =~ /\S/;
$line =~ s/^\s+//;
@features_array = split /\s/, $line ;   
#split $line along whitespace and place into an array
LOOKING_USERS: if ($features_array[0] eq
"Users") {
($features = $features_array[2]) =~ s/://;
   #assign second element into $features and remove
colon
$line_number++;
}
$line = $input[$line_number];   
if ($line =~ /Users/) {
@features_array = split /\s/, $line;  
 #split $line along whitespace and place into an array
goto LOOKING_USERS;
}
next unless $line =~ /\S/;
$line =~ s/^\s+//;
@handles_array = split /\s/, $line;#split
$line along whitespace and place into an array
$sizeof = scalar(@handles_array);
if ($sizeof >= 9 && $handles_array[0] eq
$userid){
($handles = $handles_array[5]) =~ s/\),//;
   #assign ninth element into $handles and remove ),
$string = join " ", @handles_array;
print $string."\n";
print "lmutil lmremove -c ".$Pixarfile."
-h ".$features." ".$host." ".$Pixarport."
".$handles."\n";
}
}
}

Basically, I'm trying to add some extra functionality
to the script.  I want the user to be able to pick
between have the script automatically remove all of
the licenses for them or query them like so:

Remove such-and-such license (Y or N)?

What would be the best way of going about this?

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




Help with https

2004-12-15 Thread Tham, Philip
Hi
 
I am trying to access a secured page using the code below. The page is
accessible with firefox using the proxy at proxy.inhouse.com port 8080.
 
On doing a snoop on the data while using firefox I can see a CONNECT
being sent to the website intranet.mysecuredpage.net directed to the
proxy unencrypted  and after receiving an OK SSL handshake starts and a
client hello is being sent to the proxy. After receceiving a Server
Hello information is exchanged and the web page is received encrypted.
 
On using perl and my code below, I am not seeing the CONNECT going out.
Instead a Client Hello is immediately being sent out to the proxy from
the client running the perl code.
 
Need some advise if anybody knows about this problem.
 
Philip
 
 
 
 
#!/usr/bin/perl
use strict;
use Crypt::SSLeay;
use URI::https;
use LWP::Protocol::https;
use LWP::UserAgent;
use HTTP::Request;
my $ua = LWP::UserAgent->new(keep_alive => 1, timeout =>30);
$ua->proxy('https','https://proxy.inhouse.com:8080');
my $rq=HTTP::Request->new(GET => "https://intranet.mysecuredpage.net";);
my $rsp=$ua->request($rq);
print $rsp->code;
print "\n";



Re: asking for y or n

2004-12-15 Thread Chap Harrison
Check out recipe 12.22 from the Perl Cookbook, called "pmdesc".  It
should also be available for download from O'Reilly and other places.
Also look into the CPANPLUS module from cpan.
Thanks, Jay.  pmdesc isn't pretty, but it gives the answers. :-)
Chap
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Automatically fill in a web-form field-get response

2004-12-15 Thread diogo . senai
Hi you all,

I´d like to thank everyone that helped me with that little problem about
filling in a webformfield and getting the result. I´d like to inform you,
in case it comes to you... LWP::UserAgent really didn´t help me out, but
www::mechanize solved all my problems, the script is up and running good!
Thank you all!

Diogo N Oliveira (brazilian)


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



moving to the next line

2004-12-15 Thread Christopher Spears
So everybody wants to know what I have been working
on.  I finally got permission to post this:

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

my $Pixarport = 7498;
my $host = "lex";
my $Pixarfile = $Pixarport."@".$host;
my @line;
my $line;
my @features_array;
my @handles_array;
my $handles;
my $features;
my $sizeof;
my $counter = 0;
my $answer;
my $string;

LOOKING_LINES: while(@line = `cat clicenses_output`){
foreach $line(@line){
next unless $line =~ /\S/;
$line =~ s/^\s+//;
@features_array = split /\s/, $line;#split $line
along whitespace and place into an array
LOOKING_USERS: if ($features_array[0] eq "Users") {
($features = $features_array[2]) =~ s/://;  #assign
second element into $features and remove colon
print "features: ".$features."\n";
LOOKING_HANDLES: while (@line = `cat
clicenses_output`){
if ($line =~ /Users/) {
@features_array = split /\s/, $line;
#split $line
along whitespace and place into an array
goto LOOKING_USERS;
}
next unless $line =~ /\S/;
$line =~ s/^\s+//;
@handles_array = split /\s/, $line; #split 
$line
along whitespace and place into an array
$sizeof = scalar(@handles_array);
if ($sizeof >= 9 && $handles_array[0] eq 
"manny"){
($handles = $handles_array[5]) =~ 
s/\),//;
#assign ninth element into $handles and remove ),
print "Do you wish to remove the 
floating
license: ".$features." (Y or N)?"."\n";
$string = join " ", @handles_array;
print $string."\n";
print "answer: ".$answer;
#if ($answer =~ /^[yY]$/) {
#print "lmutil lmremove -c 
".$Pixarfile." -h
".$features." ".$host." ".$Pixarport."
".$handles."\n";
#}
} 
#}
}
}
}

At this point of time, this script doesn't completely
work.  The input it is supposed to processed looks
like this:

Feature usage info:

Users of PhotoRealistic-RenderMan:  (Total of 15
licenses issued;  Total of 11 licenses in use)

  "PhotoRealistic-RenderMan" v12.000, vendor: pixard
  floating license

3d cell26 /dev/tty (v12.0) (lex/7498 2106), start
Fri 12/10 18:20
3d cell2 /dev/tty (v12.0) (lex/7498 1126), start
Fri 12/10 18:07
3d cell4 /dev/tty (v12.0) (lex/7498 6023), start
Fri 12/10 18:07
3d cell3 /dev/tty (v12.0) (lex/7498 7207), start
Fri 12/10 18:08
3d cell3 /dev/tty (v12.0) (lex/7498 9307), start
Fri 12/10 18:08
3d cell4 /dev/tty (v12.0) (lex/7498 9504), start
Fri 12/10 18:09
3d cell26 /dev/tty (v12.0) (lex/7498 933), start
Fri 12/10 18:15
3d cell20 /dev/tty (v12.0) (lex/7498 1810), start
Fri 12/10 18:18
3d cell20 /dev/tty (v12.0) (lex/7498 711), start
Fri 12/10 18:18
3d cell25 /dev/tty (v12.0) (lex/7498 4306), start
Fri 12/10 18:20
3d cell5 /dev/tty (v12.0) (lex/7498 3514), start
Fri 12/10 18:07

Users of PRMan-INTEL:  (Total of 15 licenses issued; 
Total of 11 licenses in use)

  "PRMan-INTEL" v12.000, vendor: pixard
  floating license

3d cell26 /dev/tty (v12.0) (lex/7498 1030), start
Fri 12/10 18:20
3d cell2 /dev/tty (v12.0) (lex/7498 1219), start
Fri 12/10 18:07
3d cell4 /dev/tty (v12.0) (lex/7498 6121), start
Fri 12/10 18:07
3d cell3 /dev/tty (v12.0) (lex/7498 3422), start
Fri 12/10 18:08
3d cell3 /dev/tty (v12.0) (lex/7498 3727), start
Fri 12/10 18:08
3d cell4 /dev/tty (v12.0) (lex/7498 2713), start
Fri 12/10 18:09
3d cell26 /dev/tty (v12.0) (lex/7498 3824), start
Fri 12/10 18:15
3d cell20 /dev/tty (v12.0) (lex/7498 4532), start
Fri 12/10 18:18
3d cell20 /dev/tty (v12.0) (lex/7498 4713), start
Fri 12/10 18:18
3d cell25 /dev/tty (v12.0) (lex/7498 6208), start
Fri 12/10 18:20
3d cell5 /dev/tty (v12.0) (lex/7498 5912), start
Fri 12/10 18:07

Users of PRMan-INTEL-NT:  (Total of 15 licenses
issued;  Total of 0 licenses in use)

Or at least  that is a portion of it.  Basically, I
need to go though and grab the features, which are
license names such as PRMan-INTEL-NT.  Then the script
starts looking for handles until it hits Users again. 
In the line:

 manny mannymac.entityfx.com /dev/tty (v6.000)
(lex/7111 503), start Fri 12/10 12:17

503 is the handle.

Originally, this script took input directly from
, but now I want to use  to process yes
or no from the user, so I am taking input from `cat
clicenses_output`.  Eventual

Re: asking for y or n

2004-12-15 Thread Jay
On Wed, 15 Dec 2004 11:57:32 -0600, Chap Harrison <[EMAIL PROTECTED]> wrote:
> On Dec 15, 2004, at 10:30 AM, Jay wrote:
> >  you can also use the cpan shell or perl -MCPAN
> > to get information on installed modules,
> 
> Is there a command to the cpan interface will produce a list of all
> installed modules?
> 
> Neither the 'h' command nor 'perldoc cpan' indicate anything, that I
> can see.
> 
> perl 5.8.1
> cpan script version 1.03
> CPAN.pm version 1.76
> 
> Chap
> 
> 

The short answer is no.

Check out recipe 12.22 from the Perl Cookbook, called "pmdesc".  It
should also be available for download from O'Reilly and other places. 
Also look into the CPANPLUS module from cpan.

HTH

--jay

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



Fwd: any perl project ideas

2004-12-15 Thread Harbhajan Julka
Thanks everybody for a great response. Appreciate all
the time you took for replying.

Sonia

Note: forwarded message attached.




__ 
Do you Yahoo!? 
Send holiday email and support a worthy cause. Do good. 
http://celebrity.mail.yahoo.com--- Begin Message ---
Hey all,
Need some pointers to perl projects that use all the
major functionalities of perl. Please pass your ideas
as soon as you can. I've been working on perl in
theory and tried some small programs to practice, but
need something bigger that would help understand perl
and learn it too.

Thanks in Advance.



__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

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



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


Re: asking for y or n

2004-12-15 Thread Chap Harrison
On Dec 15, 2004, at 10:30 AM, Jay wrote:
 you can also use the cpan shell or perl -MCPAN
to get information on installed modules,
Is there a command to the cpan interface will produce a list of all 
installed modules?

Neither the 'h' command nor 'perldoc cpan' indicate anything, that I 
can see.

perl 5.8.1
cpan script version 1.03
CPAN.pm version 1.76
Chap
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Segmentation fault when installing Perl 5.8.6

2004-12-15 Thread perl_cova
Hi.

This time I asked for a friend of mine for help with my English.

I've been having problems installing DBD::Oracle and finally Tim Bunce advised 
me to install Perl 5.8.6. I try to, but I got a segmentation fault when running 
make.

I tried this by running "sh Configure -de" and also by running "sh Configure" 
and answering all the questions manualy.

The last lines of the make command are the following.

Does anyone have any idea of what might be wrong? :-( I don't think this is 
normal... could this be a problem with the machine (it's an Itanium 64bits 
running Red Hat Advanced Server)

Thanks in advance,

Andre

cc -L/usr/local/lib -o miniperl \
miniperlmain.o opmini.o libperl.a -lnsl -ldl -lm -lcrypt -lutil -lc 
./miniperl -w -Ilib -MExporter -e '' || make minitest
Attempt to free unreferenced scalar: SV 0x600246b0.
./miniperl -Ilib configpm configpm.tmp
sh mv-if-diff configpm.tmp lib/Config.pm
./miniperl -Ilib lib/lib_pm.PL
Attempt to free unreferenced scalar: SV 0x60024910 at lib/lib_pm.PL 
line 1.
Attempt to free unreferenced scalar: SV 0x6002c440 at 
lib/File/Basename.pm line 138.
Attempt to free unreferenced scalar: SV 0x6002c440 at 
lib/File/Basename.pm line 142.
Attempt to free unreferenced scalar: SV 0x600589c0 at lib/warnings.pm 
line 134.
Attempt to free unreferenced scalar: SV 0x6002c470 at 
lib/File/Basename.pm line 143.
Attempt to free unreferenced scalar: SV 0x60032730 at 
lib/Exporter/Heavy.pm line 3.
make: *** [lib/lib.pm] Segmentation fault

-- 

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



Re: asking for y or n

2004-12-15 Thread Chris Devers
On Tue, 14 Dec 2004, Christopher Spears wrote:

> Thanks for the answer Chris!  Now my question is how
> do I find out if it is actually on my machine! 

It won't be -- this is a young module and not (yet) distributed with 
Perl. You can get it from CPAN, but if you're trying to avoid external 
modules, this may be a dead end.

On the other hand, I think it's a simple module -- maybe you could just 
bundle it with the code you're writing...



-- 
Chris Devers

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



Re: basic search engine

2004-12-15 Thread Dave Gray
> I am planning to write a simple search engine. The engine would be
> able to search for a word or phrases from a file and probably point
> the user the line number the word is found.
> The issue is I want the engine to be able to support more advance
> search techniques which means it could support keywords such as
> 
> word1 and word2
> word1 not word3
> word1 or word4
> 
> Is there any module where I could simply plug into my problem to
> enable this functinality. Thanks.

 might be more than you need, but it's worth a look.

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




Re: asking for y or n

2004-12-15 Thread Jay
On Tue, 14 Dec 2004 17:00:44 -0800 (PST), Christopher Spears
<[EMAIL PROTECTED]> wrote:
> Thanks for the answer Chris!  Now my question is how
> do I find out if it is actually on my machine!  I
> don't want to have to download anything because I am
> writing this script on one machine and then I am going
> to send it to another to be used.  perl -v yields:
> 
> This is perl, v5.8.1-RC3 built for
> darwin-thread-multi-2level
> (with 1 registered patch, see perl -V for more detail)
> 
> I am using Darwin on Mac OS X.
> 
> =
> "I'm the last person to pretend that I'm a radio.  I'd rather go out and be a 
> color television set."
> -David Bowie
> 
> "Who dares wins"
> -British military motto
> 
> "The freak is the norm." - "The Infernal Desire Machines of Dr. Hoffman" by 
> Angela Carter

The -M option to perl loads modules on the command line:

perl -MIO::Prompt -e 'print "module found\n"'

This will print module found if the module loaded, and a bunch of
errors if it didn't.  you can also use the cpan shell or perl -MCPAN
to get information on installed modules, but if all you need to know
is if it's there, the one-liner does the trick.

It's not part of the default install on OS X, though, so it's probably
not on your system.

HTH,

--jay

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




Re: Edit properties for MS-Office files

2004-12-15 Thread Bee
Thanks Jenda, That would be a big hint, but something I don't understand
from yours provided example, how do you know there's a class called
{PaperSize} ? What if I wanna do is just modifying the word or powerpoint
's author, last modify date, last saved person, company etc ?

Thanks
Bee

- Original Message - 
From: "Jenda Krynicky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 15, 2004 8:43 PM
Subject: Re: Edit properties for MS-Office files


> From: "Bee" <[EMAIL PROTECTED]>
> > I now have some thousands of ms-word and power point files .
> > And they are required to make some clone like properties data filling.
> > Now, I have to modify them one by one, is there any module would help
> > to do this ?  so I can just simply get a file list and clone data with
> > a loop Is that possible ?
> >
> > Thanks in advise,
> > Bee
>
> Win32::OLE
>
> I'm not sure what do you really want, but I do think you should be
> able to instruct MS Word and MS PowerPoint to do that via Win32::OLE.
>
> See http://jenda.krynicky.cz/#Letter2A4 for a tiny example. A script
> that scans word documents and changes the paper size from US Letter
> to A4. (I was never able to explain to the BFUs that we simply do not
> have US Letter paper.)
>
> Jenda
> = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery
>
>
> -- 
> 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: MySQL and flock

2004-12-15 Thread Jay
On Tue, 14 Dec 2004 17:21:04 +0200, Octavian Rasnita <[EMAIL PROTECTED]> wrote:
> Thanks but I don't have access to MySQL nor to the client that makes the
> update. I don't even know if it locks the tables or not.
> 
> I would like to just copy some files in order to create a backup but I don't
> want to copy them while they are locked.
> However, I don't know if this is possible, because now I am thinking that if
> my program starts copying the files, they might start beeing updated just
> after I have started the copy process...
> 
> Teddy
> 

Copying the files is tricky,  for the reasons you stated.  Also, 
while the files protect against data issues, they will not protect you
against system failue:  The files are not bianry compatible between
different versions of mysql.  If you were to have hard drive failure,
etc., you would have to be sure that you reinstalled exactly the same
version, or you would lose all your data.  Since many people take
system failures as an opportunity to upgrade the software as well as
the hardware...

If you really, really need copies of the files for some reason, the
only way to guarantee integrity is to makes the copies while the mysql
server process is not running.  wait until a low traffic time, stop
the server, make your copies, and restart the server.

The best way, however is to use write a script to back up the data,
rather than the binary file, or use one of the tools desgned
specifically for that purpose.  If you can read the root and
mysql-owned protected files, you should be able to access the data
base.  If you really don't have access, you should 1) rethink your
security strategy: anyone who can read the files can fairly easily
extract the data, so if you can copy the files, there's no earthly
reason for you not to have select privs on the database, and 2) just
give your DBA a shell account, and let him/her make the backup.  But
whatever you do, take the database off line before you copy the files,
or you will end up with useless backups.

HTH,

--jay

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



Re: Digest MD5 and speed

2004-12-15 Thread Traeder, Philipp
On Wednesday 15 December 2004 15:34, Benjamin Jeeves wrote:
> Hi all

Hi Benjamin,

>
> I'm writting a program in perl to md5sum about 500,000 files these files
> are text files and have different files size the biggest being about 500KB.
> my code is below

[..code snipped..]
>
> The thing is that it is taking about 3 to 4 hours to complete would these
> be about right on this number of files?

It's hard to estimate how long it should take - I'm md5sum'ing regularly about 
25.000 files, and it takes something like 2 minutes. Given those numbers, I'd 
think that it should take around 40 minutes to sum your files.

> This there any way to speed things up? if so any example would be good or a
> point in the right way too? If I do not md5sum the files it print to the
> screen in about 2 mins?

Off the top of my head, I don't know what could be improved in your code - 
maybe it would help not to instantiate an own MD5 object in each run of your 
for loop?

I'm attaching the code I'm using - maybe you want to run a test how long this 
code needs to scan your files.

HTH,

Philipp

# =
# SCAN_DIRECTORY
# =
# scan all files of a directory and write the result (filenames + MD5)
# into a specified file
# param $directory_name that should be scanned
# param $filename into which to write
# param (optional) $regexp that should be applied to filter out files

my $digest;
my $out_file;
my $directory;
my $filter;
my $base_file;

# callback procedure
sub process {
my $fh = new FileHandle;
return if (! -f $File::Find::name);

if ($filter) {
return if ($File::Find::name =~ /$filter/);
}   

# TODO jar support
#if ($File::Find::name =~ /\.jar$/) {
#   $base_file = $File::Find::name; 
#}

open ($fh, $File::Find::name) 
or die "cannot open file $File::Find::name : $!";
binmode($fh);
$digest -> addfile($fh);
my $file_name = substr($File::Find::name, length($directory)+1);
print $out_file $file_name . ";" . $digest -> hexdigest . "\n";
close ($fh);
}

sub scanDirectory {
$digest = Digest::MD5 -> new;
   ($directory, my $scan_file, $filter) = @_;   

   my $base_dir = getcwd();
   chdir($directory);

$out_file = new FileHandle;
sysopen($out_file, $scan_file, O_CREAT | O_RDWR) 
or die "could not open file $scan_file : $!";   

find ( \&process, $directory);

close($out_file) or die "could not close file $scan_file : $!";

chdir($base_dir);
}

sub testScanDirectory {
scanDirectory('d:/temp/tools', 'd:/tools.txt');

scanDirectory('d:/temp/tools', 'd:/tools_filtered.txt', '\.exe$');
}

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



Re: Finding missing syntax element

2004-12-15 Thread Jay
On Mon, 13 Dec 2004 20:23:00 +0100, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> From: Jay <[EMAIL PROTECTED]>
> > Turn on use strict for starters, and use warnings.  you won't want to
> > run with them, if you have things that you know will cause errors, but
> > they'll give you some other input.  Keep a special eye out for "Bare
> > word found where $x expected" errors.  The thing to remember is that
> > perl has no way of knowing what's really missing.  It just knows what
> > its expects to find based on what it's already seen.  You can change
> > what it expects with coding errors.  My best guess si that you're
> > actually missing a semicolon somewhere.  Consider the following:
> >
> > if (x) {
> > eval {
> > print "\n" ;
> > }
> > }
> >
> > under some combinations of warning, diagnotics, etc., Perl will carp
> > about a missing right brace because it never finds the end of the if
> > block before EOF.  The reason it never finds the end of the if block
> > is that eval needs a semicolon, but the compiler doesn't know why it
> > doesn't find the end of the block, it just knows that it doesn't find
> > the end of that block before EOF.
> 
> You sure? Could you show us a complete example ? And tell us which
> perl did you get this behaviour from?
> 
> Tried all combinations of
> use strict;
> use warnings;
> use diagnostics;
> and never received a word about a missing curly.
> 
> Semicolon is optional before the closing curly brace and it doesn't
> matter what the last command in the block is.
> 

First, you're right, that won't actually produce an error.  I
over-simplified the example, and I was working on the assumption that
the eval was being used to construct something executable.  Consider
the following, which is ugly as all get out, but which I've
encountered in a few different places and versions, mostly people
trying to post-process cgi scripts, particularly greymatter.

#!/usr/bin/perl

use warnings;
use strict;
use diagnostics;

# again simplified, but better
my $two = "]" ;

my $one = '{print "test\n"' ;
$two = '}' if 1 == 0 ;

my $three = $one . $two ;
eval {`perl -e $three`} ;

This produces a runtime (from the main block's perspective) exception
about missing baces, but not in a way that the syntax checker in your
editor would care about, because the brace in question is
single-quoted.

My point, though, was that what the comiler thinks are errors, and
what the programmer thinks are errors are often two different things. 
The most frequent culprit is orgetting a semi-colon, which can
generate several errors depending on the specific context (including,
I believe a missing brace), but never, at least in my experience, the
suggestion that you've forgotten a semicolon.  missing single and
double quotes produce interesting errors, too, as perl quotes
everything up to the next matching quote, and then generates an error
based on what it finds.

I can't tell you how many times every day a semicolon turns out to be
the culprit behind a "bareword found where...", " "'" not found before
EOF...", a "scalar found where operator expected", or a whole host of
other issues, including, I think, complaints about braces.  But then,
as you can probably see from this, when I'm in a hurry I'm not always
the worlds greatest typist.

--jay

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



Re: Digest MD5 and speed

2004-12-15 Thread Ing. Branislav Gerzo
Benjamin Jeeves [BJ], on Wednesday, December 15, 2004 at 14:34 (+)
typed:

BJ> in the right way too? If I do not md5sum the files it print to the screen in
BJ> about 2 mins?

I don't think there should be much impromevent in speed, because
Digest::MD5 uses C library for calculating MD5.

So you are telling us, that all files could be read into memory in 2
minutes ? Maybe you could do some benchmarking about reading speed,
because I think 2 mins is time, when file _names_ are written into STDOUT,
not ?

-- 

 ...m8s, cu l8r, Brano.

[May you never live to see your wife a widow.]



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




Digest MD5 and speed

2004-12-15 Thread Benjamin Jeeves
Hi all

I'm writting a program in perl to md5sum about 500,000 files these files are 
text
files and have different files size the biggest being about 500KB. my code is 
below

#!/usr/bin/perl
use strict;
use Cwd; # module for finding the current working directory
use Digest::MD5 qw(md5);


sub ScanDirectory
{
 
my $workdir = ("/mad-server/"); 
my ($workdir) = shift; 
my ($startdir) = &cwd; # keep track of where we began

chdir($workdir) or die "Unable to enter dir $workdir:$!\n";
opendir(DIR, ".") or die "Unable to open $workdir:$!\n";
my @names = readdir(DIR) or die "Unable to read $workdir:$!\n";
closedir(DIR);

foreach my $name (@names){
next if ($name eq "."); 
next if ($name eq "..");

if (-d $name){  # is this a directory?
&ScanDirectory($name);
next;
}
my $base_dir = ("/mad-server");
my $full_path = join("/", $base_dir, $workdir, $name);
my $file = shift || "$full_path";
open(FILE, $file) or die "Can't open '$file': $!";
binmode(FILE);
print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n";
chdir($startdir) or die "Unable to change to dir $startdir:$!\n";

}

}# Subroute ScanDirectory
&ScanDirectory(".");

The thing is that it is taking about 3 to 4 hours to complete would these be
about right on this number of files?
This there any way to speed things up? if so any example would be good or a 
point
in the right way too? If I do not md5sum the files it print to the screen in
about 2 mins?

Thank you

Benjamin

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



Re: any perl project ideas

2004-12-15 Thread Jean-Sébastien Guay
Hello Harbhajan,
Hey all,
Need some pointers to perl projects that use all the
major functionalities of perl. Please pass your ideas
as soon as you can. I've been working on perl in
theory and tried some small programs to practice, but
need something bigger that would help understand perl
and learn it too.
I have found that contributing to the Bugzilla project helped me learn a 
lot about Perl in a practical and interesting setting. You can start out 
by going to http://bugzilla.mozilla.org/ and doing a query on the 
Bugzilla product, and then choosing a bug that interests you and try to 
fix it. Be sure to communicate with the core Bugzilla developers on the 
mozilla-webtools mailing list and in the bug in Bugzilla (you'll need to 
create an account for this).

The best way to install Bugzilla is to get the most recent version from 
CVS. see http://www.bugzilla.org/ for details.

Good luck,
J-S
--
__
Jean-Sébastien Guay   [EMAIL PROTECTED]
   http://whitestar02.webhop.org/

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.5.4 - Release Date: 2004/12/15
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: receiving input from different sources

2004-12-15 Thread Jonathan Paton
Dear Christopher,

Keyboard input comes on STDIN, and you can not use STDIN for something
else if you need the keyboard.  [It *might* be possible to reopen the keyboard
file descriptor, but ask a Unix C programmer].

Usually, you would make either the file to be processed an option or the actions
you want as options.  See Edward's suggestion for this.  Also consider FIFO
special files (man fifo).

exec is used to replace the current process with another process.  STDIN,
STDOUT and STDERR are passed on (automatically?).  The idea is you rename
STDIN as another file descriptor, and then the new process will reopen
STDIN with
input coming from the keyboard.  Or something like that.

I think you need to search for unix systems programming (in C).  Once you know
how it is done in C, work out how to do the same in Perl.

Jonathan Paton [Writing of things I have little experience of]

-- 
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

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




Re: any perl project ideas

2004-12-15 Thread Chris Devers
On Wed, 15 Dec 2004, Tor Hildrum wrote:

> On Tue, 14 Dec 2004 23:10:48 -0800 (PST), Harbhajan Julka
> <[EMAIL PROTECTED]> wrote:
> > Hey all,
> > Need some pointers to perl projects that use all the
> > major functionalities of perl. Please pass your ideas
> > as soon as you can. I've been working on perl in
> > theory and tried some small programs to practice, but
> > need something bigger that would help understand perl
> > and learn it too.
> 
> Write a spam-filter.
 
When we've already got SpamAssassin, what's the point? SA may not be the 
perfect spam filter, but it's a pretty good attempt. 

Wouldn't it make more sense to spend efforts making the best general 
purpose spam filter available better with core patches & other plugins 
rather than starting from scratch?

Free software moves forward when someone has an itch to scratch. If you 
want to help solve the spam problem, contributing to the SpamAssassin 
project would be a good approach, or write one from scratch if you have 
fundamentally different ideas. If you want to make searching better, you 
can contribute to one of the many, many Perl based search projects 
(HT::Dig, Mnogosearch, Plucene, etc), or you can write one from scratch 
if you have fundamentally different ideas. But no matter what you do, do 
it because it's a probleem *you* want to solve.

Perl is a huge language; there's almost no one out there who has used 
the entire language (which, presumably, would mean all of CPAN). Pick an 
area that interests you, and learn enough Perl to solve problems in that 
area. Then try a new area, and broaden your awareness of the language. 

There's little point in trying to swallow the whole thing at once just 
to solve some artificial problem you fished off this list :-)



-- 
Chris Devers

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




Re: Edit properties for MS-Office files

2004-12-15 Thread Jenda Krynicky
From: "Bee" <[EMAIL PROTECTED]>
> I now have some thousands of ms-word and power point files .
> And they are required to make some clone like properties data filling.
> Now, I have to modify them one by one, is there any module would help
> to do this ?  so I can just simply get a file list and clone data with
> a loop Is that possible ?
> 
> Thanks in advise,
> Bee

Win32::OLE

I'm not sure what do you really want, but I do think you should be 
able to instruct MS Word and MS PowerPoint to do that via Win32::OLE.

See http://jenda.krynicky.cz/#Letter2A4 for a tiny example. A script 
that scans word documents and changes the paper size from US Letter 
to A4. (I was never able to explain to the BFUs that we simply do not 
have US Letter paper.)

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: How to install Tk.pm,LWP.pm?

2004-12-15 Thread Edward WIJAYA
On 15 Dec 2004 11:15:59 -, Prabahar Mosas  
<[EMAIL PROTECTED]> wrote:



  
Dear All,
   How to install Tk.pm,LWP.pm?
  I am new to perl, I did't know how to add
module into perl. So if anybody know regarding my doubt.
Please Mail me in simple manner.  My Perl version is
5.8.4.
TK and LWP are built in modules you don't need to
install it. Just invoke it with -> use Tk; OR use LWP;
However  to install other modules,
if you are under Linux you do this:
$CPAN
then:
CPAN> install Module::Name
if you are under Windows-Command assumed you are using Active State:
Dos> PPM
then:
ppm> install Module-Name
HtH
--
Regards,
Edward WIJAYA
Singapore
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



How to install Tk.pm,LWP.pm?

2004-12-15 Thread Prabahar Mosas
   
Dear All, 
   How to install Tk.pm,LWP.pm? 
  I am new to perl, I did't know how to add 
module into perl. So if anybody know regarding my doubt. 
Please Mail me in simple manner.  My Perl version is 
5.8.4.

RE: MySQL and flock

2004-12-15 Thread Ron Goral
> -Original Message-
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 9:21 AM
> To: Ron Goral; [EMAIL PROTECTED]
> Subject: Re: MySQL and flock
>
>
> Thanks but I don't have access to MySQL nor to the client that makes the
> update. I don't even know if it locks the tables or not.
>
> I would like to just copy some files in order to create a backup
> but I don't
> want to copy them while they are locked.
> However, I don't know if this is possible, because now I am
> thinking that if
> my program starts copying the files, they might start beeing updated just
> after I have started the copy process...
>
> Teddy

Hm.  Guess I thought you'd be doing this using SQL via a perl script.  Are
you going to be physically copying files?  If that is the case, you will
either have to deny access to them while you're copying or perhaps hold your
breath and hope for the best.  If you are using SQL, then the link I gave
you outlines how you can lock them while copying the data.

Ron



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



Re: any perl project ideas

2004-12-15 Thread Octavian Rasnita
Hi,

Write a guestbook, then a search engine.

Teddy

- Original Message - 
From: "Harbhajan Julka" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 15, 2004 9:10 AM
Subject: any perl project ideas


Hey all,


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



$sftp->put problem.............

2004-12-15 Thread roime puniran
Thanks...
And now it's seems like this...
$sftp->>put($file, $remote_path) or die
"...problem!...";

But it's still same error..I really stuck on it...


--- "Ing. Branislav Gerzo" <[EMAIL PROTECTED]> wrote:

> roime puniran [rp], on Wednesday, December 15, 2004
> at 00:33 (-0800
> (PST)) typed:
> 
> $sftp->>put("$file", "$remote_path") or die
> "...problem
> rp> !...";
> 
> try to remove ", so it should be like
> $sftp->put($file, $remote_path) or ...
> 
> -- 
> 
>  ...m8s, cu l8r, Brano.
> 
> [You may be recognized soon.  Perhaps you should
> hide?]
> 
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
> 
> 


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



basic search engine

2004-12-15 Thread Khairul Azmi
Hi,
I am planning to write a simple search engine. The engine would be
able to search for a word or phrases from a file and probably point
the user the line number the word is found.
The issue is I want the engine to be able to support more advance
search techniques which means it could support keywords such as

word1 and word2
word1 not word3
word1 or word4

Is there any module where I could simply plug into my problem to
enable this functinality. Thanks.

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




$sftp->put problem.............

2004-12-15 Thread roime puniran
It's going well, when I put it in debug mode..
Actually the main point is, I have only error i think
in this line code..

$sftp->put("$file", "$remote_path") or die "...problem
!...";

But there is still come out with this error msg and i
don't understand what happen..

Couldn't get handle: Failure at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 168.
routerPC02: sftp: Sent message T:10 I:7
Couldn't fsetstat: Failure at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 203.
routerPC02: sftp: Sent message T:4 I:8
Couldn't close file: No such file or directory at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 203.

Can anybody give me some idea...?..please!
Note: forwarded message attached.




__ 
Do you Yahoo!? 
Jazz up your holiday email with celebrity designs. Learn more. 
http://celebrity.mail.yahoo.com--- Begin Message ---
On Tue, 14 Dec 2004 23:10:48 -0800 (PST), Harbhajan Julka
<[EMAIL PROTECTED]> wrote:
> Hey all,
> Need some pointers to perl projects that use all the
> major functionalities of perl. Please pass your ideas
> as soon as you can. I've been working on perl in
> theory and tried some small programs to practice, but
> need something bigger that would help understand perl
> and learn it too.

Write a spam-filter.

Tor

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



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


$sftp->put problem.............

2004-12-15 Thread roime puniran
It's going well, when I put it in debug mode..
Actually the main point is, I have only error i think
in this line code..

$sftp->put("$file", "$remote_path") or die "...problem
!...";

But there is still come out with this error msg and i
don't understand what happen..

Couldn't get handle: Failure at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 168.
routerPC02: sftp: Sent message T:10 I:7
Couldn't fsetstat: Failure at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 203.
routerPC02: sftp: Sent message T:4 I:8
Couldn't close file: No such file or directory at
/usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 203.

Can anybody give me some idea...?..please!
Note: forwarded message attached.


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com --- Begin Message ---
On Tue, 14 Dec 2004 23:10:48 -0800 (PST), Harbhajan Julka
<[EMAIL PROTECTED]> wrote:
> Hey all,
> Need some pointers to perl projects that use all the
> major functionalities of perl. Please pass your ideas
> as soon as you can. I've been working on perl in
> theory and tried some small programs to practice, but
> need something bigger that would help understand perl
> and learn it too.

Write a spam-filter.

Tor

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



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


Re: $sftp->put problem.............

2004-12-15 Thread Ing. Branislav Gerzo
roime puniran [rp], on Wednesday, December 15, 2004 at 00:33 (-0800
(PST)) typed:

$sftp->>put("$file", "$remote_path") or die "...problem
rp> !...";

try to remove ", so it should be like
$sftp->put($file, $remote_path) or ...

-- 

 ...m8s, cu l8r, Brano.

[You may be recognized soon.  Perhaps you should hide?]



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




Re: basic search engine

2004-12-15 Thread Edward WIJAYA
On Wed, 15 Dec 2004 15:04:56 +0800, Khairul Azmi <[EMAIL PROTECTED]>  
wrote:

Hi,
Hello,
I am planning to write a simple search engine.
[snip]
Is there any module where I could simply plug into my problem to
enable this functinality. Thanks.
Maybe "Plucene" can be useful.
http://search.cpan.org/dist/Plucene/lib/Plucene.pm
It is a search engine in itself.
HtH
--
Regards,
Edward WIJAYA
Singapore
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]