Authen::SMB

2005-01-24 Thread ds10025
Morning
Do anyone know where I can get information on how this module work? I've 
search the Internet nothing so-far.

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



Re: Authen::SMB

2005-01-24 Thread Tor Hildrum
On Mon, 24 Jan 2005 10:09:09 +, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Morning
> 
> Do anyone know where I can get information on how this module work? I've
> search the Internet nothing so-far.

www.cpan.org would be a good place to start:
http://search.cpan.org/~pmkane/Authen-Smb-0.91/Smb.pm

Tor

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




Re: file and dir time stamps

2005-01-24 Thread Francesco
Thomas Browner ha scritto:
I have a hard time writing a script that look at file and directories 
time and date stamp then delete any thing that is so many days old. if 
someone would give me a good starting point.

Some time ago i had the same problem, so here what i came up with. This 
script includes some options, can be used interactively or with a 
configuration file, can be recursive or not, and so on. I hope the 
documentation included in the script could be enough.

HTH
--
Francesco
# FILE: clean.pl
# NAME: clean old files
# VERSION: 0.3
# AUTHOR: abeni
# MODIFIED: 01/12/2004
# DESCRIPTION: it deletes files older than X days in a given folder.
#  Parameters can be given from command line:
# "clean.pl -d folder1 days1 folder2 days2"
#  or with an external configuration file:
#  oppure tramite un file di configurazione:
# "clean.pl -f configfile"
#  The configuration file should have on each row:
# "folder days"
#  For other parameters run clean.pl -h

use strict;
use Getopt::Std;
sub clean;  # procedura di cancellazione vera e propria
sub usage;  # sub che illustra la sintassi del programma
sub cmd_line;   # sub che reperisce i parametri da linea di comando
sub cfg_file;   # sub che reperisce i parametri da file di configurazione
sub interact;   # sub che richiede i parametri in modalita' interattiva
(@ARGV > 0) or die usage;
my %days = ();	# hash con nomi directory e giorni di anzianita' dei file 
da cancellare
my $dir;
my $progdir = "d:/perls/prog/clean/";
my $logfile = $progdir."clean.log";
my %opts;


### PRINCIPALE
##
# analizza gli switch passati al programma ed elabora di conseguenza i 
parametri
getopts('rd:f:h',\%opts);

SWITCH: {
$opts{d}&& do {%days=split/,/,$opts{d}; last SWITCH};
$opts{f}&& do {my $file = $opts{f};
%days=cfg_file($file);
last SWITCH};
$opts{h}&& usage;
};
open (LOG,">> $logfile") or die "Impossibile accedere al file di log 
$logfile: $!";

print LOG "\n\n***".scalar(localtime)."\n\n";
# avvia la cancellazione ogni cartella passata come parametro
foreach $dir (keys %days) {
my $filecount = 0;
print LOG "Cartella: $dir\nGiorni: $days{$dir}\n";
$filecount += clean($dir,$days{$dir});
print LOG "Totale file cancellati: $filecount\n\n";
}
print "End";
### CLEAN
#
sub clean {
	my $dir = shift;
	my $days = shift;
	my $filecount = 0;
	opendir (DIR,$dir) or do {print LOG "Impossibile aprire la cartella 
$dir: $!\n\n";
	next;};

	foreach my $file (readdir DIR) {
		next if $file =~ /^\.*$/;
		if (-d "$dir\\$file") {
			if ($opts{r}) {
$filecount += clean("$dir\\$file",$days);
rmdir "$dir\\$file" or print LOG "Impossibile cancellare la cartella 
$dir: $!\n";
			};
		next;
		};
		next unless (-M "$dir\\$file" > $days);
		unlink ("$dir\\$file") or print LOG "Impossibile cancellare il file 
$dir\\$file: $!\n";
		$filecount++;
	}
	closedir DIR;
	return $filecount;
}

### USAGE
#
sub usage {
print "\nSyntax:\n";
print "   $0 -d \"[dir1],[days],[dir2],[days]...\" [-r]\n";
print "   $0 -f [config file] [-r]\n";
print "\nThe configuration file has the following format:\n";
print "   dir1, days\n";
print "   dir2, days\n";
print "   ...\n\n";
print "If you choose -f option without specifying a configuration 
file,\n";
print "the script looks for a \"clean.ini\" in the script folder\n";
print "If you choose both -d and -f, the -d option will prevail\n";
print "and command line parameters will be used.\n\n";
print "The -r option enable recursive deletion (go into subfolders)\n\n"
print "To show this help:\n";
print "   $0 -h\n";
exit;
}
### CFG_FILE

sub cfg_file {
	my $file = (shift or $progdir."clean.ini");
	my %days;
	open (FILE, $file) or die "Can't open configuration file $file: $!";
	while () {
		next if /^#/;
		next unless /\S/;
		chomp;
		# verifica il formato
		die "Errori nel file di configurazione: $_\n" unless 
(/([^\,]+)\,(\d+)$/);		
		$days{$1} = $2;
	}
	return %days;
}

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



Logfile name

2005-01-24 Thread Jan Eden
Hi,

I create monthly log files with names like statistics_01_2005.log. Now I have a 
function which returns the logfile name for the current month:

sub statfile {
my @date = localtime(time);
my ($month, $year) = @date[4,5];
$year += 1900;
$month = sprintf ("%02d", $month+1);
return my $statfile = qq{statistics_${month}_${year}.log};
}

In some cases I need the name of last month's logfile. To achieve this, I 
modified the subroutine like this:

sub statfile {
my $mode = shift;
my @date = localtime(time);
my ($month, $year) = @date[4,5];
$year += 1900;
if ($mode) {
$month = sprintf ("%02d", $month);
$month = 12 if $month == 0;
$year = $year - 1;
}
else {
$month = sprintf ("%02d", $month+1);
}
return my $statfile = qq{statistics_${month}_${year}.log};
}

This looks quite clumsy to me. Is there a more elegant way?

Thanks,

Jan
-- 
How many Microsoft engineers does it take to screw in a lightbulb? None. They 
just redefine "dark" as the new standard.

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




perltidy on windows - error

2005-01-24 Thread Absolut Newbie
When running perltidy on windows i get the following error. I
uninstalled/reinstalled from PPM and looked at the perltidy site but no
luck.

Any ideas ?

D:\Perl\bin>perl perltidy -b foo.pl
Subroutine Cwd::cwd redefined at D:/Perl/lib/Cwd.pm line 518.
Subroutine Cwd::getcwd redefined at D:/Perl/lib/Cwd.pm line 519.
Subroutine Cwd::fastcwd redefined at D:/Perl/lib/Cwd.pm line 520.
Subroutine Cwd::fastgetcwd redefined at D:/Perl/lib/Cwd.pm line 521.
Subroutine Cwd::abs_path redefined at D:/Perl/lib/Cwd.pm line 522.
Prototype mismatch: sub Cwd::abs_path (;$) vs none at D:/Perl/lib/Cwd.pm
line 52
2.
Subroutine Cwd::realpath redefined at D:/Perl/lib/Cwd.pm line 523.
Prototype mismatch: sub Cwd::realpath (;$) vs none at D:/Perl/lib/Cwd.pm
line 52
3.




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




matrix problem

2005-01-24 Thread manfred
Hi,
I need to write an application to calculate prices.
Some of these pricelists come as matrices where, say the pr/m2 depends on  
length and width like so:

heigth\width||30|36 |42 |48 |54 |60 |72 |84 
|96 |108|120|
---
30  ||69|   |   |   |   |   |   |   
|   |   |   |
36  ||69|69 |   |   |   |   |   |   
|   |   |   |
42  ||69|69 |69 |   |   |   |   |   
|   |   |   |
48  ||69|69 |69 |69 |   |   |   |   
|   |   |   |
54  ||69|69 |69 |69 |55 |   |   |   
|   |   |   |
60  ||76|69 |69 |54 |55 |55 |   |   
|   |   |   |
72  ||76|69 |69 |55 |55 |55 |48 |   
|   |   |   |
84  ||68|69 |69 |55 |55 |55 |48 |48 
|   |   |   |
96  ||and   |so |on |...|   |   |   |   
|   |   |   |
108 ||  |   |   |   |   |   |   |   
|   |   |   |
120 ||  |   |   |   |   |   |   |   
|   |   |   |
150 ||  |   |   |   |   |   |   |   
|   |   |   |
180 ||  |   |   |   |   |   |   |   
|   |   |   |
In some lists it may be prices per piece ond not m2.
But what I'm not shure yet is whether it's better to load that whole list  
into the matrix (arrays of hashes) and do the calculation what price  
applies to the current calculation with perl or let postgres find out what  
pr/m2 applies it with a query.
Also what would be the best way to store something like that in the db  
(but that I might need to ask in another list)?

I reckon something like that has been covered before but I couldn't find  
it :-)
Would be grateful for a hint in the right direction.

--manfred
--
http://glassdoc.org
http://glassdoc.de
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to find regex at specific location on line

2005-01-24 Thread Dave Gray
> 'plain_regex'=> sub { if ( $string =~ /^.{38}\|[BNPG]\|/ ) {
> my $a = $_ } },
> 'plain_regex'=> sub { if ( $string =~ /^.{38}\|N\|/ ) { my $a = $_ } 
> },
> 
> What was interesting to me was that although, predictably, the
> substring/regex combo was consistently the best performer for the
> original match, regexing the whole line was consistently the best
> performer when looking for "|N|".  This seems to fly in the face of
> the conventional wisdom that substr is faster than m// when you know
> what you're looking for and where you're looking for it.

I believe the conventional (faster?) way to do a regex search when you
want to start matching a fixed number of characters in is along the
lines of:

pos($string) = 38;
print "found!\n" if $string =~ /\G\|[BNPG]\|/;

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




RE: How to find regex at specific location on line

2005-01-24 Thread Jason Balicki
Thanks to everyone that answered this question.

I ended up using (/^.{30}\|[BNPG]\|/).  I plan
on adding some more checks for "|" at specific
locations (other than just ^ and $, which
I have now) for sanity's sake.

Thanks again.

Would it be helpful to others if I were to post the
complete script I've come up with so far?

--J(K)


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




RE: How to find regex at specific location on line

2005-01-24 Thread Graeme St. Clair
I knew what I meant, I just didn't write what I meant.  Next time, I'll have
a coffee first...

Of course you're right I forgot to anchor it too.

Rgds, GStC.


-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 22, 2005 8:41 PM
To: Perl Beginners
Subject: Re: How to find regex at specific location on line

Graeme St. Clair wrote:
> Try the {} notation, that says how many whats are required before the 
> which (as it were).  Perhaps something like:-
> 
>  if (/.{31,33}\|[BNPG]\|/){
> return 2;
> }
> 
> Meaning, between 31 & 33 characters.  Untested!

No, that is not what it means.  It means match . (any character except
newline) 31, 32 or 33 times and since it is greedy it will usually be 33
times and *then* match \|[BNPG]\|.  So it will try to match \|[BNPG]\| at
the 34th or later position since the pattern isn't anchored to the beginning
of the line.


John
--
use Perl;
program
fulfillment

--
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: How to find regex at specific location on line

2005-01-24 Thread Jay
On Mon, 24 Jan 2005 10:46:38 -0500, Dave Gray <[EMAIL PROTECTED]> wrote:
> > 'plain_regex'=> sub { if ( $string =~ /^.{38}\|[BNPG]\|/ ) {
> > my $a = $_ } },
> > 'plain_regex'=> sub { if ( $string =~ /^.{38}\|N\|/ ) { my $a = $_ 
> > } },
> >
> > What was interesting to me was that although, predictably, the
> > substring/regex combo was consistently the best performer for the
> > original match, regexing the whole line was consistently the best
> > performer when looking for "|N|".  This seems to fly in the face of
> > the conventional wisdom that substr is faster than m// when you know
> > what you're looking for and where you're looking for it.
> 
> I believe the conventional (faster?) way to do a regex search when you
> want to start matching a fixed number of characters in is along the
> lines of:
> 
> pos($string) = 38;
> print "found!\n" if $string =~ /\G\|[BNPG]\|/;
> 

That's an interesting point, although in my mind, it was niether a
substr() solution nor a pure regex solution so I just kind of skipped
over it.  Performance-wise, I can't seen any advantage, unless you're
trying to modify the behavior of m//g.  Slightly revised benchmarks
are below.  Today they're from the PII/166 running SuSE 9.1 I use as a
test server at work, and strangely, substr() is considerably faster,
as generally predicted.  This is very different from last night's
results on the G4/750 under OS X.  The regex engine must optimize very
well for the PPC--either that, or Benchmark.pm compiles with errors on
one of the hardware/software combinations.  Interesting.

Benchmark: timing 100 iterations of plain_regex, plain_substr,
pos_regex, regex_line, substr_regex_1, substr_regex_3...
plain_regex: 41 wallclock secs (40.16 usr +  0.01 sys = 40.17 CPU) @
24894.20/s (n=100)
plain_substr: 20 wallclock secs (20.20 usr +  0.01 sys = 20.21 CPU) @
49480.46/s (n=100)
 pos_regex: 32 wallclock secs (32.24 usr +  0.01 sys = 32.25 CPU) @
31007.75/s (n=100)
regex_line: 40 wallclock secs (39.85 usr +  0.01 sys = 39.86 CPU) @
25087.81/s (n=100)
substr_regex_1: 27 wallclock secs (27.69 usr +  0.00 sys = 27.69 CPU)
@ 36114.12/s (n=100)
substr_regex_3: 39 wallclock secs (39.06 usr +  0.01 sys = 39.07 CPU)
@ 25595.09/s (n=100)

#!/usr/bin/perl

use strict ;
use warnings ;
use Benchmark ;

my $string = '| B  B  B  B |13145551212 B  B  B  B  |N| B  B  B  B  B
B | B  0|001001|001001| 100|10|B|A|' ;

print "\n\nMultiple targets:\n\n" ;

timethese(100,{
'substr_regex_1' => sub { if ( substr( $string, 39, 1 ) =~
/[BNPG]/ ) { my $a = $_ } } ,
'substr_regex_3' => sub { if ( substr( $string, 38, 3 ) =~
/\|[BNPG]\|/ ) { my $a = $_ } } ,
'plain_substr'   => sub {
my $sub = substr( $string, 39, 1 );
if ($sub eq "B" || $sub eq "N" || $sub eq "P" || $sub eq "G")
{ my $a = $sub }
},
'plain_regex'=> sub { if ( $string =~ /.{38}\|[BNPG]\|/ ) { my
$a = $_ } },
'regex_line' => sub { if ( $string =~ /\|[BNPG]\|/ ) { my $a = $_ } },
'pos_regex'  => sub {
pos($string) = 38 ;
if ( $string =~ /\G\|[BNPG]\|/ ) { my $a = $_ }
}
}) ;

--jay

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




Problems installing Text-Iconv-1.4

2005-01-24 Thread Chris Brown
Hi.
I'm trying to install a local copy of the W3C HTML Validator. I've 
managed to install all the pre-requisites apart from Text-Iconv-1.4 - I 
get the following error message:

/[EMAIL PROTECTED] Text-Iconv-1.4]# perl Makefile.PL
Checking for iconv ... ok (added -liconv)
NOTE: If you have multiple iconv implementations installed, you might
 want to make sure that I've found the one you want to use.
 If necessary, you can explicitly specify paths like this:
 /usr/bin/perl5.8.5 Makefile.PL LIBS='-L/path/to/lib' 
INC='-I/path/to/include'

Checking if your kit is complete...
Looks good
Writing Makefile for Text::Iconv
[EMAIL PROTECTED] Text-Iconv-1.4]# make
cp Iconv.pm blib/lib/Text/Iconv.pm
AutoSplitting blib/lib/Text/Iconv.pm (blib/lib/auto/Text/Iconv)
/usr/bin/perl5.8.5 /usr/lib/perl5/5.8.5/ExtUtils/xsubpp  -typemap 
/usr/lib/perl5/5.8.5/ExtUtils/typemap -typemap typemap  Iconv.xs > 
Iconv.xsc && mv Iconv.xsc Iconv.c
make: *** No rule to make target 
`/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/EXTERN.h', needed by 
`Iconv.o'.  Stop.
[EMAIL PROTECTED] Text-Iconv-1.4]#/

Does anyone know what might be going wrong here? I have installed 
libiconv-1.9.1 and man iconv opens the manual up, so I assume I have got 
iconv installed.

I have tried to change LIBS/INC to reflect my setup but to be honest I'm 
not exactly sure what I should be pointing at here.

Any advice (or suggestions on where I can research this myself) would be 
greatly appreciated.

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



perl.beginners Weekly list FAQ posting

2005-01-24 Thread casey
NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?
Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?
Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?
Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?
Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?
This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?
Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?
Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who do I complain to?
You can send complaints to <[EMAIL PROTECTED]>

  1.9 - Who currently maintains the FAQ?
Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?
Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?
Feb 04, 2004

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?
A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?
* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.

  2.3 - Are there any rules?
Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun

  2.4 - What topics are allowed on this list?
Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?
Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?
We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?
Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?
YES! You have been warned! If you don't want to get ~100 emails per day
from this list, consider subscribing to the digest.

  2.9 Other tips before posti

Program to read data from serial port, filter and process

2005-01-24 Thread Jason Balicki
Some people emailed me privately and asked that I do post
what I've come up with to the list.

I wrote this program over the course of the last week,
starting with very little perl experience (I've modified
others code, and small things like that) and acomplished
a goal that prior to last week I considered unobtainable.

Here is the current version.  I expect to continue tweaking
(one of the goals is to put the data in a database instead
of a flat text file) but otherwise the program is doing
what I want it to do.

I want to say thanks again to the guys on this list
who helped me crank out my very first, actual, useable,
from-scratch perl program.  I know it's simple, but
I'm still proud. :)

Comments are appreciated.

Anyway, it can be found here:

http://nothingimportant.net/perl-stuff/alcatel_readserial

Thanks again!

--J(K)


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




unable to include .pm file

2005-01-24 Thread Mark Henry
All, going to try this one again, sorry..!
---
Hi,
I'm trying to use a perl module that a tool I got, ccmeter.pl, requires and 
I can't no matter what I do..

I'm on hpux11.11, and the script was written for 5.005_03 so that’s what I'm 
including at the top of the perl script ( #!/apps/perl-5.005_03/bin/perl) - 
this exists and *is* that particular version.

The module is Time::HiRes, the file is HiRes.pm
I d/l'd the module from cpan and put it in my user directory… 
~mhenry/tools/3rdparty/Time/HiRes.pm
The file exists of course, has read bit set across the board.

When I run the script it complains it "Can't locate loadable object for 
module Time::HiRes in @INC"

If I run 'perl -V', I get (among other things):
 @INC:
   /apps/perl-5.005_03/lib/5.00503/PA-RISC1.1
   /apps/perl-5.005_03/lib/5.00503
   /apps/perl-5.005_03/lib/site_perl/5.005/PA-RISC1.1
   /apps/perl-5.005_03/lib/site_perl/5.005
So, in the script I put the following:
use lib '/users/mhenry/tools/3rdparty';
I get:
Can't locate loadable object for module Time::HiRes in @INC (@INC contains: 
/users/mhenry/tools/3rdparty /apps/perl-5.005_03/lib/5.00503/PA-RISC1.1 
/apps/perl-5.005_03/lib/5.00503 
/apps/perl-5.005_03/lib/site_perl/5.005/PA-RISC1.1 
/apps/perl-5.005_03/lib/site_perl/5.005) at ./ccmeter.pl line 221

I changed the line above to:
use lib '/users/mhenry/tools/3rdparty/Time';
I get the same..
I tried putting the HiRes.pm file at every level of the dirs mentioned above 
in the 'perl -V' return, but nothing!!

It seems to be a simple task but nothing will work.
The 'head' of the module is:
package Time::HiRes;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK @EXPORT_FAIL);
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
..which appears to be legit.
Can *anyone* help??!  I've tried every google search result out there..
Many thanks,
Mark

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



re: Splitting large file into little chunks based on tagging (example & script inc.)

2005-01-24 Thread FlashMX
Hi,

I have a large file that I want to split into smaller chunks based on
a start and end text (...)

My script works only partially. It only saves the first occurence of
my match and then closes the script. How can I get it to keep ripping
throught the file saving into individual files.

My file I'm reading in is called test.txt

Below is just an example.

blah...blah...
blah...blah...
blah...blah...


...


blah...blah...
blah...blah...
blah...blah...


...


and so on...


Here is my script:

#!/usr/bin/perl -w

use strict;

my $written = 0;
my $index = 1;
my $filename;

if ( open( FH, 'D:\test.txt' ) )
{
$filename = sprintf( 'D:\out%d.txt', $index );
open( OUT, ">$filename" );
while (  )
{
if ( m|^$| ... m|^$| )
{
print OUT $_;
$written = 1;
}
else
{
if ( $written )
{
close( OUT );
$index++;
$filename = sprintf( 'C:\out%d.txt', $index );
open( OUT, ">$filename" );
$written = 0;
}
}

print "-> $_";

}
close( FH );
}




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




RE: Naming Convention?

2005-01-24 Thread Graeme St. Clair
Thanks for the pointer to 'perlstyle' and 'Exporter'.  I shall read, mark
and inwardly digest.

But I don't understand what you mean by C?  (I'm already using strict &
warnings.)

Rgds, GStC.
 

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 22, 2005 11:02 AM
To: Graeme St. Clair
Cc: beginners@perl.org
Subject: Re: Naming Convention?

Graeme St. Clair wrote:
> Is there any common convention governing names of variables defined in 
> a 'require'd 'blah.pl'?  I'd like to make use of such variables 
> detectable to the naked eye in the scripts that 'require blah.pl'.
>  
> Rgds, GStC.
>  
> 

Well you should consider using C and making it a proper module. 
Then use the Exporter if you still have to pollute namespaces.  Don't just
throw everything in main::.  Turn on 'strict' and 'warnings'.

To your question, check out:

perldoc perlstyle

http://danconia.org

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




RE: unable to include .pm file

2005-01-24 Thread Bob Showalter
Mark Henry wrote:
> All, going to try this one again, sorry..!
> 
> ---
> 
> Hi,
> 
> I'm trying to use a perl module that a tool I got, ccmeter.pl,
> requires and I can't no matter what I do..
> 
> I'm on hpux11.11, and the script was written for 5.005_03 so that's
> what I'm including at the top of the perl script (
> #!/apps/perl-5.005_03/bin/perl) - this exists and *is* that
> particular version. 
> 
> The module is Time::HiRes, the file is HiRes.pm
> 
> I d/l'd the module from cpan and put it in my user directory...
> ~mhenry/tools/3rdparty/Time/HiRes.pm
> The file exists of course, has read bit set across the board.

There's your problem. You can't just copy the HiRes.pm file and be done with
it. The module has C code that needs to be compiled.

For the general procedure to install Perl modules, see the documentation at:

   perldoc perlmodinstall

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




tie DB_File flags

2005-01-24 Thread Ken Gillett
Information about these has proved hard to come by, but having 
ascertained what I need to use I find another problem. I want to 
calculate the flags to use beforehand, but if I try

tie %$dbm, "DB_File", $dbf, $dbflags, $mode, $DB_HASH;
even though $dbflags contains O_RDONLY I get the following error:=
	Argument "O_RDONLY" isn't numeric in subroutine entry at 
/usr/lib/perl5/5.8.6/i686-linux/DB_File.pm

This is caused by using the variable for the flags and if I replace 
that with the actual string (no quotes) it works fine, so it's happy 
with $dbf and $mode.

I'm using 5.8.6, but the problem also exists with 5.8.5 at least.
Can anyone suggest how I can get around this and use a variable for the 
flags?


Ken  G i l l e t t
_/_/_/_/_/_/_/_/_/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Logfile name

2005-01-24 Thread Owen
On Mon, 24 Jan 2005 14:31:53 +0100
Jan Eden <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I create monthly log files with names like statistics_01_2005.log. Now I have 
> a function which returns the logfile name for the current month:
> 
> sub statfile {
> my @date = localtime(time);
> my ($month, $year) = @date[4,5];
> $year += 1900;
> $month = sprintf ("%02d", $month+1);
> return my $statfile = qq{statistics_${month}_${year}.log};
> }
> 
> In some cases I need the name of last month's logfile. To achieve this, I 
> modified the subroutine like this:
> 
> sub statfile {
> my $mode = shift;
> my @date = localtime(time);
> my ($month, $year) = @date[4,5];
> $year += 1900;
> if ($mode) {
> $month = sprintf ("%02d", $month);
> $month = 12 if $month == 0;
> $year = $year - 1;
> }
> else {
> $month = sprintf ("%02d", $month+1);
> }
> return my $statfile = qq{statistics_${month}_${year}.log};
> }


I just get all the file names and sort them, last months is the second last (or 
first) 



opendir(DIR,$wherever) or die "Can't open DIR $!\n";
while (defined($file = readdir(DIR))) {
next unless($file =~ /\.log/); #just take out the .log files
push (@filenames,$file);
}
closedir(DIR);

# Now I get a sorted list for inclusion in a drop down menu

@filenames = sort{$a cmp [EMAIL PROTECTED];




Owen

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




Re: Problems installing Text-Iconv-1.4

2005-01-24 Thread mgoland


- Original Message -
From: Chris Brown <[EMAIL PROTECTED]>
Date: Monday, January 24, 2005 11:44 am
Subject: Problems installing Text-Iconv-1.4

> Hi.
Hi Chriss,
> 
> I'm trying to install a local copy of the W3C HTML Validator. I've 
> managed to install all the pre-requisites apart from Text-Iconv-
> 1.4 - I 
> get the following error message:
> 
> /[EMAIL PROTECTED] Text-Iconv-1.4]# perl Makefile.PL
> Checking for iconv ... ok (added -liconv)
> 
> NOTE: If you have multiple iconv implementations installed, you might
>  want to make sure that I've found the one you want to use.
>  If necessary, you can explicitly specify paths like this:
> 
>  /usr/bin/perl5.8.5 Makefile.PL LIBS='-L/path/to/lib' 
> INC='-I/path/to/include'
> 
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Text::Iconv
> [EMAIL PROTECTED] Text-Iconv-1.4]# make
> cp Iconv.pm blib/lib/Text/Iconv.pm
> AutoSplitting blib/lib/Text/Iconv.pm (blib/lib/auto/Text/Iconv)
> /usr/bin/perl5.8.5 /usr/lib/perl5/5.8.5/ExtUtils/xsubpp  -typemap 
> /usr/lib/perl5/5.8.5/ExtUtils/typemap -typemap typemap  Iconv.xs > 
> Iconv.xsc && mv Iconv.xsc Iconv.c
> make: *** No rule to make target 
> `/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/EXTERN.h', 
> needed by 
> `Iconv.o'.  Stop.
> [EMAIL PROTECTED] Text-Iconv-1.4]#/
> 
> Does anyone know what might be going wrong here? I have installed 
> libiconv-1.9.1 and man iconv opens the manual up, so I assume I 
> have got 
> iconv installed.
> 
> I have tried to change LIBS/INC to reflect my setup but to be 
> honest I'm 
> not exactly sure what I should be pointing at here.

Yaik's, what OS are you working with ?? Do you have more then one verssion of 
perl installed ?? Basicly the problem is that, it can't find your Perl Header 
files. Short solution would be to find where your header files are and create a 
link to them somewhere in /usr/lib/perl5...
> 
> Any advice (or suggestions on where I can research this myself) 
> would be 
> greatly appreciated.

let me know if that helps.
mark G
> 
> Kind regards,
> Chris
> 
> -- 
> 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]
 




perl script to binary executible

2005-01-24 Thread Manas Kulkarni
Hi,

I would like to convert my perl script into a binary executable before 
deploying it on a client machine

I checked on google and found "perlbin" at sourceforge.net but that 
does not seem to work. It gives compilation error with handy.h file 
which is the perl distribution file.

Is there a way to convert perl script to binary executable (linux 
platform) so that the code is not seen by the client ?

Thanks in Advance for the help

Manas

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




RE: perl script to binary executible

2005-01-24 Thread Bakken, Luke
> I would like to convert my perl script into a binary 
> executable before 
> deploying it on a client machine
> 
> I checked on google and found "perlbin" at sourceforge.net but that 
> does not seem to work. It gives compilation error with handy.h file 
> which is the perl distribution file.
> 
> Is there a way to convert perl script to binary executable (linux 
> platform) so that the code is not seen by the client ?

This question comes up a lot. The short answer is "no", there is no
perfect way to hide your code from prying eyes. You should take a look
at PAR http://par.perl.org/index.cgi

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




How to go back to a line and do something with it in an input fil e?

2005-01-24 Thread Li, Aiguo (NIH/NCI)
hello, all.

I need to transform the column3 data from an input file as indicated below
into three values: 0, 0.4, 1.
if there are more than 3 NoCall continuously in column3, change NoCall into
"1". this option has the highest precedence.
for the rows where column2 is between 52 and 105 (range from a file),
transform the values in column3 into "0.4".
for the rows outside of this region, change the values in column3 into "0"

print into an output file.

I am struggling with how to go back to the line to change the column 3 after
3 consecutive NoCall has been counted??? 

I currently read the input data into an array and used this line to go back
to the beginning of first NoCall line: my $nocalline = $contents[$line_num -
3];
Perl does not like it and an error message says: ""my" variable $nocalline
masks earlier declaration in same scope a
 line 38. Use of implicit split to @_ is deprecated at trynocall.pl line 38.
syntax error at trynocall.pl line 38, near ");"

Can anyone give some hints?

Thanks

Aiguo


input data is:  output data should be:
==  
1   22  AA  1   22  0
1   24  AA  1   24  0
1   26  NoCall  1   26  0
1   27  BB  1   27  0
1   30  AB  1   30  0
1   35  NoCall  1   35  1
1   40  NoCall  1   40  1
1   41  NoCall  1   41  1
1   42  NoCall  1   42  1
1   48  AB  1   48  0
1   50  AB  1   50  0
1   52  BB  1   52  0.4
1   53  NoCall  1   53  0.4
1   55  NoCall  1   55  0.4
1   56  BB  1   56  0.4
1   66  AA  1   66  0.4
1   70  NoCall  1   70  1
1   90  NoCall  1   90  1
1   99  NoCall  1   99  1
1   100 NoCall  1   100 1
1   101 NoCall  1   101 1
1   103 AA  1   103 0.4
1   105 BB  1   105 0.4
2   22  AA  2   22  0
2   24  BB  2   24  0
2   26  AB  2   26  0
2   27  BB  2   27  0
2   30  AA  2   30  0
2   35  AA  2   35  0
2   40  AA  2   40  0


the code I have
=
#!usr/local/bin/perl

use strict;
use warnings;

open (DATA, "C:/Aiguo_2004/SNP_Johnpark/work files/summary/testnocall1.txt")
or die "Can not open file \n";
open (LOH, "C:/Aiguo_2004/SNP_Johnpark/work files/summary/loh.txt") or die
"Can not open file \n";
open (OUT1, ">C:/perl/work/nocallout.txt") or "die can not open file \n";

my @contents = ;
my $chro_num;
my $lohbegin;
my $lohend;
my $line_num = 0;


while(my $lohline = ) #this file contain regions for changing to 0.4
{
($chro_num, $lohbegin, $lohend) = split(/\t/, $lohline);
foreach my $line (@contents) 
{
while($line =~ /^[1..9]/)
{
$line_num++;
#print $line_num;
(my $chro, my $position, my $call) = split (/\t/, $line);

if(($chro_num == $chro)&&($position >= $lohbegin) &&
($position <= $lohend))
{
call = 0.4;
unless($call =~ "NoCall")
{
my $n++;
my $m++;

if($n >= 3)
{
my $nocalline = $contents[$line_num - 3];
my ($nocall_chro, $nocall_begin, $nocall =
split(/\t/, $nocalline);
print "Nocall chro = $nocall_chro, Nocall
begin = $nocall_begin \n"; 
$nocall = "Nocall";
}
#else{$call = 0.4;}
print $call;
$contents[$line_num] = join('\t', $chro, $position,
$call);
}
}
#print "Chro:$chro, Position:$position, call=$call\n";
}
#print @contents;
}
}

close DATA;
close OUT1;
close LOH;

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




Re: perl script to binary executible

2005-01-24 Thread Alfred Vahau
so that the code is not seen by the client ?
Is shroud any good?
http://cpan.cbn.net.id/scripts/
Distributors of indigoperl provide a tool for doing what you want in 
Windows.
Haven't tried it on Linux though.

http://www.indigostar.com/
alfred,
Manas Kulkarni wrote:
Hi,
I would like to convert my perl script into a binary executable before 
deploying it on a client machine

I checked on google and found "perlbin" at sourceforge.net but that 
does not seem to work. It gives compilation error with handy.h file 
which is the perl distribution file.

Is there a way to convert perl script to binary executable (linux 
platform) so that the code is not seen by the client ?

Thanks in Advance for the help
Manas
 

--
Perl - 
Making simple things easy,
without making hard things impossible;


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



Re: perl script to binary executible

2005-01-24 Thread Jay
On Mon, 24 Jan 2005 16:45:37 -0500, Manas Kulkarni <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I would like to convert my perl script into a binary executable before
> deploying it on a client machine
> 
> I checked on google and found "perlbin" at sourceforge.net but that
> does not seem to work. It gives compilation error with handy.h file
> which is the perl distribution file.
> 
> Is there a way to convert perl script to binary executable (linux
> platform) so that the code is not seen by the client ?
> 
> Thanks in Advance for the help
> 
> Manas
> 
> --

Manas,

This depends to a large extent on how complicated the project is.  The
place to start, though is taking a look at perldoc perlcc.  I compile
simple scripts into binaries accoasionally.  But there is no good tool
to compile complex Perl programs into bytecode, and probably won't be
until Perl6, if then.  If you really need to hide the code from
people, Perl proably isn't what you need, or you need to set up some
kind of client-server scheme to run the code on your machine where the
user doesn't have read access.


HTH,

--jay

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




Splitting large file into little chunks based on tagging (example & script inc.)

2005-01-24 Thread FlashMX
Hi,

I have a large file that I want to split into smaller chunks based on
a start and end text (...)

My script works only partially. It only saves the first occurence of
my match and then closes the script. How can I get it to keep ripping
throught the file saving into individual files.

My file I'm reading in is called test.txt

Below is just an example.

blah...blah...
blah...blah...
blah...blah...


...


blah...blah...
blah...blah...
blah...blah...


...


and so on...


Here is my script:

#!/usr/bin/perl -w

use strict;

my $written = 0;
my $index = 1;
my $filename;

if ( open( FH, 'C:\test.txt' ) )
{
$filename = sprintf( 'C:\out%d.txt', $index );
open( OUT, ">$filename" );
while (  )
{
if ( m|^$| ... m|^$| )
{
print OUT $_;
$written = 1;
}
else
{
if ( $written )
{
close( OUT );
$index++;
$filename = sprintf( 'C:\out%d.txt', $index );
open( OUT, ">$filename" );
$written = 0;
}
}

print "-> $_";

}
close( FH );
}



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




How to tell what account I'm running in on Win2K3?

2005-01-24 Thread Siegfried Heintze
I've been having a terrible time soliciting [EMAIL PROTECTED] for help.
Apparently I'm on the mailing list because I see other folks' postings but I
never see my own messages post. 


I'm trying to send automated email from my web page and Mail::SendMail is
scrambling the URL in my anchor tag. (Everything else is working fine,
however). Since I cannot seem to figure out the problem I decided to go back
to using Microsoft's CDO (their proprietary API for sending email messages)
on IIS6 instead of Mail::SendMail.

CDO is not working either, I might add. But it is only a problem I invoke
the script from a browser via IIS6. When I log into the server as an
Administrator and run the script from the console prompt, it sends mail
using CDO fine. When I call CDO from ASP instead of perl, it works fine!

So there is obviously something funky with the context in which IIS is
creating the perl subprocesses.

So to diagnose the problem, I'd like to write a perl script that will give
me clues about what context I'm running. For example, how do I write a perl
script that will tell me what account I'm logged in under?

There must be some other things that would give me a clue. Can you think of
any?

Thanks,
Siegfried


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




Re: perl script to binary executible

2005-01-24 Thread Chris Devers
On Mon, 24 Jan 2005, Manas Kulkarni wrote:

> I would like to convert my perl script into a binary executable before 
> deploying it on a client machine

Why?

If you want security, this won't get you much.

This is a dead end, and also a Frequently Asked Question.

It is basically not possible to do what you're asking for. There are 
tools to turn a plain-text Perl script into a binary executable, but 
none of them are very effective at obscuring the code's functionality.

You'd have better luck by writing really really bad Perl, with vague 
variable names, lots of misdirections in the code itself, etc. (See, for 
example, Damian Conway's "SelfGOL".) You would, in effect, write the 
kind of line noise that gives Perl a bad reputation. 

But I don't actually think anyone should do this (except Damian Conway, 
but then he was trying to make a point with SelfGOL).

If you *really* want your code to be protected, reconsider your system's 
architecture, and find a way to have your code running on a machine 
where *you* are the only one in control of it. This ends up being the 
server and the encapsulation of all the system's interesting logic. On 
the machines you can't control, you have a simple, uninteresting client 
that accesses your secure part via some sort of API; for example, you 
could set it up as a web application, or by email, or RPC, etc. 

But if the code is running on a system you don't control, it will 
*always* be possible to reconstruct the code's original functionality.

 


-- 
Chris Devers

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




Re: perl script to binary executible

2005-01-24 Thread Lawrence Statton
> On Mon, 24 Jan 2005 16:45:37 -0500, Manas Kulkarni <[EMAIL PROTECTED]> wrote:
.
deletia
.

> > Is there a way to convert perl script to binary executable (linux
> > platform) so that the code is not seen by the client ?
> > 

This should be in the FAQ.

The short answer is:  *NO SYSTEM* whereby you deliver executable code
to a customer is immune from reverse engineering.

ActiveState sells a product that will produce executable binary files
for a variety of targets from Perl source.  This can be handy,
especially for Windows-targets, because it gives the user a single
.EXE file they can just run, without having to install Perl.

The comes-with perlcc will function for those cases where "I just want
to save myself the support hassle of casual users tweaking the
script."

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

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




Re: Program to read data from serial port, filter and process

2005-01-24 Thread John W. Krahn
Jason Balicki wrote:
Some people emailed me privately and asked that I do post
what I've come up with to the list.
I wrote this program over the course of the last week,
starting with very little perl experience (I've modified
others code, and small things like that) and acomplished
a goal that prior to last week I considered unobtainable.
Here is the current version.  I expect to continue tweaking
(one of the goals is to put the data in a database instead
of a flat text file) but otherwise the program is doing
what I want it to do.
I want to say thanks again to the guys on this list
who helped me crank out my very first, actual, useable,
from-scratch perl program.  I know it's simple, but
I'm still proud. :)
Comments are appreciated.
Anyway, it can be found here:
http://nothingimportant.net/perl-stuff/alcatel_readserial
You should really enable warnings and strict:
$ perl -Mwarnings -c alcatel_readserial
Scalar value @_[0] better written as $_[0] at alcatel_readserial line 257.
Scalar value @_[0] better written as $_[0] at alcatel_readserial line 326.
Scalar value @_[1] better written as $_[1] at alcatel_readserial line 327.
Name "main::tbs" used only once: possible typo at alcatel_readserial line 82.
alcatel_readserial syntax OK
98  if ($lograw=="yes"){
   101  if ($logerrors=="yes"){
   126  if ($lograw=="yes") {
   144  if ($logerrors=="yes"){
== is the numerical equality operator.  If you want to determine if strings 
are equal then you have to use 'eq' instead.

You are opening and closing $csvlog six times in the program.  It would 
probably be better to just open it once at the start of the program.


John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



hash slice/exists vs. grep benchmark weirdness...

2005-01-24 Thread JupiterHost.Net
In benchmarking some code I've come across something I did not expect:
slice:
use strict;
use warnings;
my @k=qw(1 2 3 4 5 6);
my %n;@[EMAIL PROTECTED] = @k;
print "hi" if exists $n{1};
print "hi" if exists $n{3};
print "hi" if exists $n{5};
print "hi" if exists $n{7};
print "hi" if exists $n{9};
print "hi" if exists $n{11};
grep:
use strict;
use warnings;
my @k=qw(1 2 3 4 5 6);
print "hi" if grep /^1$/, @k;
print "hi" if grep /^3$/, @k;
print "hi" if grep /^5$/, @k;
print "hi" if grep /^7$/, @k;
print "hi" if grep /^9$/, @k;
print "hi" if grep /^11$/, @k;

Benchmark: timing 500 iterations of grep, slice...
  grep: 3.65945 wallclock secs ( 2.33 usr +  0.04 sys =  2.37 CPU) 
@ 2109704.64/s (n=500)
 slice: 2.37966 wallclock secs ( 2.52 usr + -0.01 sys =  2.51 CPU) 
@ 1992031.87/s (n=500)
   Rate slice  grep
slice 1992032/s--   -6%
grep  2109705/s6%--

I would've thought the "slice and then use exists" would have been 
faster then "greping the entire array each time and using regexes" when 
you check it. but its consistently faster by an average 6-10%

Any ideas why that might be?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Splitting large file into little chunks based on tagging (example & script inc.)

2005-01-24 Thread John W. Krahn
FlashMX wrote:
Hi,
Hello,
I have a large file that I want to split into smaller chunks based on
a start and end text (...)
My script works only partially. It only saves the first occurence of
my match and then closes the script. How can I get it to keep ripping
throught the file saving into individual files.
My file I'm reading in is called test.txt
Below is just an example.
blah...blah...
blah...blah...
blah...blah...

...

blah...blah...
blah...blah...
blah...blah...

...

and so on...
Here is my script:
#!/usr/bin/perl -w
use strict;
my $written = 0;
my $index = 1;
my $filename;
if ( open( FH, 'D:\test.txt' ) )
{
$filename = sprintf( 'D:\out%d.txt', $index );
open( OUT, ">$filename" );
while (  )
{
if ( m|^$| ... m|^$| )
{
print OUT $_;
$written = 1;
}
else
{
if ( $written )
{
close( OUT );
$index++;
$filename = sprintf( 'C:\out%d.txt', $index );
open( OUT, ">$filename" );
$written = 0;
}
}
print "-> $_";
}
close( FH );
}
If I understand correctly then this should do what you want:  (UNTESTED)
if ( open FH, '<', 'D:/test.txt' ) {
while (  ) {
my $range = /^$/ .. /^$/;
if ( $range == 1 ) {
my $filename = sprintf 'C:/out%d.txt', $index++;
open OUT, '>', $filename or die "Cannot open $filename: $!";
}
if ( $range ) {
print OUT;
}
else {
print "-> $_";
}
}
close FH;
}

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: hash slice/exists vs. grep benchmark weirdness...

2005-01-24 Thread Lawrence Statton
> In benchmarking some code I've come across something I did not expect:
> 

You have to stop spending so much time playing with all this bogus
benchmarking :)


> slice:
> use strict;
> use warnings;
> my @k=qw(1 2 3 4 5 6);
> my %n;@[EMAIL PROTECTED] = @k;
> print "hi" if exists $n{1};
> print "hi" if exists $n{3};
> print "hi" if exists $n{5};
> print "hi" if exists $n{7};
> print "hi" if exists $n{9};
> print "hi" if exists $n{11};
> 
> grep:
> use strict;
> use warnings;
> my @k=qw(1 2 3 4 5 6);
> print "hi" if grep /^1$/, @k;
> print "hi" if grep /^3$/, @k;
> print "hi" if grep /^5$/, @k;
> print "hi" if grep /^7$/, @k;
> print "hi" if grep /^9$/, @k;
> print "hi" if grep /^11$/, @k;
> 
> 
> 
> Benchmark: timing 500 iterations of grep, slice...
>grep: 3.65945 wallclock secs ( 2.33 usr +  0.04 sys =  2.37 CPU) 
> @ 2109704.64/s (n=500)
>   slice: 2.37966 wallclock secs ( 2.52 usr + -0.01 sys =  2.51 CPU) 
> @ 1992031.87/s (n=500)
> Rate slice  grep
> slice 1992032/s--   -6%
> grep  2109705/s6%--
> 
> I would've thought the "slice and then use exists" would have been 
> faster then "greping the entire array each time and using regexes" when 
> you check it. but its consistently faster by an average 6-10%
> 
> Any ideas why that might be?

Well, first -- you're creating the hash inside the benchmark loop,
which is not particularly light-weight.

Second:  You're using pathologically small lists.  Try running it with
10,000 elements instead of ten.

Third:  Premature optimization is a terrible thing. 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

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




RegExp equivalencies

2005-01-24 Thread Michael Kraus
G'day...

Is:

my ($id) = $item =~ /_(\d+)$/;

Equivalent to:

$item =~ /_(\d+)$/;
$id = $1;

Thanks heaps...

-Mike




Wild Technology Pty Ltd , ABN 98 091 470 692
Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017
Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017
Telephone 1300-13-9453 |  Facsimile 1300-88-9453
http://www.wildtechnology.net
DISCLAIMER & CONFIDENTIALITY NOTICE:  The information contained in this email 
message and any attachments may be confidential information and may also be the 
subject of client legal - legal professional privilege. If you are not the 
intended recipient, any use, interference with, disclosure or copying of this 
material is unauthorised and prohibited.   This email and any attachments are 
also subject to copyright.  No part of them may be reproduced, adapted or 
transmitted without the written permission of the copyright owner.  If you have 
received this email in error, please immediately advise the sender by return 
email and delete the message from your system.



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




Re: RegExp equivalencies

2005-01-24 Thread John W. Krahn
Michael Kraus wrote:
G'day...
Hello,
Is:
my ($id) = $item =~ /_(\d+)$/;
Equivalent to:
$item =~ /_(\d+)$/;
$id = $1;
No.
In the first example my() creates a new variable $id and the result of the 
list returned from "$item =~ /_(\d+)$/" is assigned to it or an empty list 
(undef) if the pattern did not match.

In the second example the pattern is matched against $item in void context and 
then $id is assigned the value of $1 which may be from the previous line or 
from the last successfully matched pattern if the previous line didn't match.


John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]