Re: Parsing problem

2003-12-11 Thread drieux
On Dec 11, 2003, at 8:00 PM, R. Joseph Newton wrote:
drieux wrote:

Still think you should shoot who EVER came up with
the original file format...
[..]
Now, now, no need for violence.
Perhaps seeking a commitment order,
but no violence, please!
p0: in light of your MOST EXCELLENT
RDBMS table lay out, I wish to start
by tipping my Hat!!! Most Well Played!
{ or DoublePlusMoGooder... 8-) }

I suck, you Rule! - I really should have
stepped back and looked more at the data
than the simpler parsing problem...
clearly this is a db_conversion_tool problem,
but doing it from these types of Yuk, Yuk, Yuk,
dumps of the old db is, GROSS!
p1: unfortunately the phrase you should assert is

drieux, you are a professional,
remember your 12-step programme
		"no contract, no killing"

	we do not do pro-bono work...

since technically I have obligations to that trade.

p2: can we at least highly recommend
incrementing the bad_kharma_count for
who ever wrote the db_dump_tool for
leaving a coder with way ugly file
formatting to re-parse???
how about say:
bad_kharma_count++ while($infestation_unit_is_breathing);
ciao
drieux
---

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



Re: Parsing problem

2003-12-11 Thread R. Joseph Newton
drieux wrote:

>
> Still think you should shoot who EVER came up with
> the original file format...
>
> HTH
>
> ciao
> drieux

Now, now, no need for violence.  Perhaps seeking a commitment order, but no violence,
please!

Joseph


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




Re: Parsing problem

2003-12-11 Thread R. Joseph Newton
Larry Sandwick wrote:

>
> I know I can split the file on "|" but because the data is not
> consistent and my skill set is limiting me to re-parse this file into a
> file I can upload into MySql

Just Don't Do It.

This data is not ready for entry into a database.  MySQL is an RDBMS engine,
and RDBMS is designed for normalized data.

The presence of so many nulls, and your professed need to have colums filled
in with the same data, indicates that the data in these columns is probably
not informative.  Sure, you can use MySQL or any other database temporarily
to store even badly organized material, but it should not remain that way.
This is really outside of Perl, but there are some serious issues of data
structure involved here.

I'm not going to try to plumb the details, but it's pretty clear that this
file has the data rows grouped, by some object with two fields.  That object
should have a table of its own, and only the primary key of that object
[preferably *not* a meaningful data field] should appear in the rows of the
data table.  As long as you are not intending to change the structure of
these files, you may as well leave them in a flat file.


> I am asking for help and suggestions I do I
> detect that column 1 has change ? Some how I need to read in the first
> three lines for every backorder, before I can start outputting the data?
> .
>
> This is the file before ( see below what is should look like after the
> parser.  (Before)
>
>
>
> 24165| DEF|   |  | | |
>
>  |O18580  |259|LEATHER BOOK SIDE TABLE   |1|1|   295.00
>
>  |05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0|35.00
>
>  ||1773   |FUNCTIONAL FLOOR LAMP |1|0|62.50
>
>  ||1302   |MOROCCAN FLORAL BX,BRASS  |1|0|29.00
>
>  ||1666   |CUBA COFFEE TABLE |1|1|   290.00
>
>  ||1666   |CUBA SIDE TABLE   |1|1|   147.50
>
> 24310| ABC|   |  | | |
>
>  |O18813  |1145   |FLEUR-DE-LIS DOCUMENT BOX |1|0|52.50
>
>  |07/29/03|1549   |TAOS CENTERPIECE  |1|1|65.00
>
>  ||1729L  |FRENCH BOX BOOKEND, LEFT  |1|1|69.00

I'd suggest instead something like

Table account:
ID   letters
24310DEF
24310ABC
5522 XYZ

Table invoice:
ID   account_iddate
O18580   24165 05/30/03

Table line_item
ID  invoice_id description  etc1   etc2
...yada, yada
259 O18580 Leather Bokk Side Table  1|1|
295.00
...


Please design something more stable to receive the data you extract.  You
should only have to deal with a file like this once, then get it into
something more sensible.  Once you have designed a more appropriate data
structure, I'd suggest that you pull this data out by:

Checking column 0 [the first] of each line for an account number.  If one is
found, then you can parse that line for characteristics of the account
object.
Checking column 1 for all other colums to see if there is a new invoice
number. You should start a new invoice object each time one is encountered.
The date attached to this invoice will have to wait till you read the next
line.
Take column 2 through the end of each of the data rows as data for the line
item itself.

Before you can get any real oomph out of your coding, you will have to have
a design that doesn't waste your efforts.

Joseph


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




Burn Baby Burn! was Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread drieux
On Dec 11, 2003, at 3:27 PM, Tassilo von Parseval wrote:
[..]
This is why Perl6 is on its way and promises to solve a lot of those
problems. Sometimes something functional has to be torn down in order 
to
build something better.
[..]

Depending upon which day of the week it is,
I am either excited to see perl6 come out,
or I am loathesome to see it come out.
I went through much of that with the Perl5
transition as well. I was so stoked that
5.6.1 became the dafault for most of my
base OS platforms, and was concerned that
the cut over to 5.8 would mean full rebuilds
of anything with XS in it... but then had the
odd moment when something I thought was 'cool'
and found that it worked in 5.8 but not in 5.6.1
made me giggle that things were clearly moving in
the right direction...
You also, unfortunately, present a part of
the ongoing problem with any open source solution
that is seeking to maintain cross platform compatability,
there comes a time when the heaving number of patches
on top of patches make it s hard to maintain.
ciao
drieux
---

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



Re: md5 function and storable module

2003-12-11 Thread Yannick Warnier
Le jeu 11/12/2003 à 16:19, Dan Anderson a écrit :

> Caveat Coder!  Perl can be set up so that the @INC doesn't point to the
> core modules.  I have seen this on shared hosting, where (I assume) the
> sys admin decided to use it as a way to secure the box.

I don't get it. What would be my interest in doing that? I've already
tried that with Storable.pm (I don't remember the version but I am using
perl 5.6.1) and it just failed horribly because the module needed
somehow to be compiled into perl libs... or something like that?

I'm not really into Perl enough to get into those compilation needs, but
I still have a problem, in the case of Storable.pm, because the
different versions don't keep backward compatibilities. 

The problem I have with that is that I have different scripts which
communicate from different OS and the "freezed" strings are not freezed
the same way from one version to the other and my scripts can thus not
communicate.

I have tried to get a certain (same everywhere) module release and put
it in another directory but then it wrecks from every part :-)

Also, Perl 5.8.0 seems to have Storable as a core module, so it's even
harder to get rid of this version.

As for now, I am forced not to move to Perl 5.8.1 because of the
installations already done on different client sites (pain to change it
everywhere) so I "freezed" the system everywhere but I would like to
find a solution.

Anyway, I don't get the point of what you were saying about loading the
modules from another place. Maybe the Digest::MD5 would work that way,
if that's what you were meaning, but it won't work with all modules.

Thx for your help (all),
Yannick


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




Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread Tassilo von Parseval
On Thu, Dec 11, 2003 at 11:29:14AM -0800 drieux wrote:
> 
> On Dec 11, 2003, at 10:28 AM, Tassilo von Parseval wrote:
> [..]
> > And since my attempts to get the specs for these META.yml failed,
> >I am the more happy that the latest EU::MakeMaker creates it for me.
> [..]
> 
> Excuse me while I giggle UNCONTROLably ( yes, I know
> that is read as 'screaming, in some ascii art - it was
> so intended. { ok, so I not spelt gooder in ascii either } )
> 
> p0: given that 'ya' traditionally denotes 'yet another',
> it worries me that most folks do not see 'yada'
> as 'yet another dumb acronym'. Mean while we have shifted
> from 'yaml' to 'yml' as the TLA suffix...

Dropping the 'a' is mostly a concession to archaic operating systems
that tend to expect 8.3 filenames.

> p1: given that I have been living with the dialectical
> tension of the voices in my head, where on one side
> i have 'sgt. rock' asking "do we have a dog in this fight?"
> and the 'college boy' in me willing to get 'wrapped
> around the axil' for some purely pedantic "issue"
> 
> I think I'll just follow your lead Sarge
> 
>   If and when they decide that we really need to
>   know how exactly they want to deal with this
>   "yaml-ization" I am more than sure that the
>   word will come on down from on high, and at
>   that time College Boy we will tell you your position...
> 
> Which of course is what makes me just bend over
> and giggle at the "growth" and/or "bloat" in
> 
>   h2xs, the EU::MM and ...
> 
> not to mention the ongoing efforts to either
> adopt the Build v. Maker Model, and the ... and ...

Especially the latter discussion has something to do with the
growth-problem. Traditionally, h2xs started as a tiny script that
created a skeletal directory structure with a few templated files in it.
However, that was obviously not powerful enough so it was tweaked to
automatically generate XS files based on some C headers fed to it. 

Once XS was tackled, the question was raised why it shouldn't also
generate accessors for functions defined in C headers. This unfortately
introduced a new prerequesite, namely C::Scan which is a module that
should have never been allowed into the wild and onto the CPAN. Since
this module is a non-core module, not every h2xs has the same
capabilities. Three flavours exist: those not having any C::Scan at
their disposal, those with an old C::Scan and those with a recent enough
C::Scan so that the -m and -a options can be used (calling those
switches obscure would be too favourable).

Since h2xs should continue running on any platform, edge cases like VMS
etc. had to be handled as well.

The result over the years is a script of around 1700 lines to which
maybe 20 different people have contributed. It's living proof that
security through obscurity is in fact a decent approach when done
'properly' and with enough imagination.

Rewriting it from scratch is impossible since the code wont reveal what
it does (my attempt of doing it is still buried deep down in my
home-directory). Furthermore, those people responsible for a particular
change either died or hide in shame so that there is no person alive who
could definitely say whether a particular clean-up to parts of the code
would be functionally equivalent.

EU::MM has a very similar biography, only that it is still maintained by
one brave guy who nonetheless freely admits that M::Build should be used
instead just because at some not too distant point in the past patching
EU::MM will become impossible.

> p2: Next time I think we should have a nice clean
> useful and appropriate BDUF about how Perl Really
> should have been built, developed, maintained, so
> that all due regards to the efficiencies of the
> algorithms with conform to the matrix of maintainablity...

There is no such thing as a dictum of maintainability in the context of
Perl5. Efficiency has always been one but - when done properly - doesn't
leave any room for maintainability. But it does change the way Perl5
develops now. New features are hard to get in because the people
involved have become cautious: They know that any new piece on top could
make the whole card-house collapse. Maybe not now, but possibly half a
year later.

This is why Perl6 is on its way and promises to solve a lot of those
problems. Sometimes something functional has to be torn down in order to
build something better.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval


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




Re: recursive replace command line

2003-12-11 Thread Paul Johnson
On Thu, Dec 11, 2003 at 12:17:03PM -0500, George Georgalis wrote:

> btw - what's the best manpage for the perl command line options?

perlrun

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: Parsing problem

2003-12-11 Thread drieux
On Dec 11, 2003, at 12:27 PM, Larry Sandwick wrote:

With the little amount of Perl that I know, I have come to a dilemma. I
do not know how to parse this file so in column 1 (24165) is the number
duplicate for every item number in the list. I also need  in the 2
column  (O185850) to duplicate itself for every item. The 3rd item
(05/30/03)needs to follow the same process. The file format is below,
before the parser.
I know I can split the file on "|" but because the data is not
consistent and my skill set is limiting me to re-parse this file into a
file I can upload into MySql I am asking for help and suggestions I do 
I
detect that column 1 has change ? Some how I need to read in the first
three lines for every backorder, before I can start outputting the 
data?
.
personally I say Shoot the "person" who came up with
the file lay out - but what you need is a bit of peek ahead
coding.
my $entry; # our entry - from the first line
my $key = '';  # the 'key' - that bit from the second line
my $date = ''; # date - that occurs on the third line
my $line;  # what we will cache the 'rest of the date line'
# I was using Inline::Files - so let us assume that
# you opened the file as INFO1
while ( my $stuff =  ) {

chomp($stuff);
next if ($stuff =~/^\s*$/); # blow off empty lines
# thin down the spaces around the "|"
# this way the $user in particular will be 'empty'
# as well as streamline the other fields
$stuff =~ s/\s*\|\s*/|/g;
my ($user,$itemkey,$tail) = split(/\|/, $stuff, 3);
if ( $user )
{
$entry = $user; # save the entry info
$key = $date = '';  # reset any previous key and date
} else {
if ( $key && $date ) # if we have both, this is a follow on 
item
{
print "$entry|$key|$date|$tail\n";
} elsif ( $key ) # if we have the key we need the date
{
$date = $itemkey; # collect the date
# send out foist the Old Line and then our new one
print "$entry|$key|$date|$line\n";
print "$entry|$key|$date|$tail\n";
} else {
$key = $itemkey; # save the key
$line = $tail;   # save the tail
}
} # else side of have user value
}
that will generate your
24165|O18580|05/30/03|259|LEATHER BOOK SIDE TABLE|1|1|295.00
24165|O18580|05/30/03|1774|FUNCTIONAL TABLE LAMP|1|0|35.00
24165|O18580|05/30/03|1773|FUNCTIONAL FLOOR LAMP|1|0|62.50
24165|O18580|05/30/03|1302|MOROCCAN FLORAL BX,BRASS|1|0|29.00
24165|O18580|05/30/03|1666|CUBA COFFEE TABLE|1|1|290.00
24165|O18580|05/30/03|1666|CUBA SIDE TABLE|1|1|147.50
24310|O18813|07/29/03|1145|FLEUR-DE-LIS DOCUMENT BOX|1|0|52.50
24310|O18813|07/29/03|1549|TAOS CENTERPIECE|1|1|65.00
24310|O18813|07/29/03|1729L|FRENCH BOX BOOKEND, LEFT|1|1|69.00
24310|O18813|07/29/03|1729R|FRENCH BOX BOOKEND, RIGHT|1|1|69.00
24310|O18813|07/29/03|1549|WINDEMERE BOOK CADDY|1|0|85.00
24310|O18813|07/29/03|1774|REVOLVING BOOK TABLE|1|1|234.00
24310|O18813|07/29/03|1574|NORMANDY 3 DRAWER CONSOLE|1|1|330.00
24310|O18813|07/29/03|1765|LEATHER BOOKS,ASST.SET/12|1|1|175.00
5522|O18549|05/20/03|1551|HEX LEATHER GARDEN STOOL|1|0|130.50
5522|O18549|05/20/03|1749|TRIVET STAND|1|1|87.75
5522|O18549|05/20/03|1801|DESK BOX, VICTORIA|1|1|85.50
5522|O18549|05/20/03|1549|TAOS CENTERPIECE|1|1|58.50
Still think you should shoot who EVER came up with
the original file format...
HTH

ciao
drieux
---

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



Re: dbmopen problem - solved

2003-12-11 Thread Joel Newkirk
On Thu, 2003-12-11 at 14:06, drieux wrote:
> On Dec 10, 2003, at 11:34 PM, Joel Newkirk wrote:
> [..]
> > I found my problem - apparently webmin was doing "use GDBM_File;" for
> > me, which is why it worked in the webmin module, and since I wasn't
> > including either that or the webmin "web-lib.pl" it was defaulting to a
> > different DB format, hence the "File Not Found" error.  Once I include
> > "Use GDBM_File;" I can successfully read the DBM written by the webmin
> > module.  Doh!  Maybe my second week with Perl will be smoother... ;^)
> [..]
> 
> p0: if you want to have 'compatibility' with webmin,
> you might work out whether or not you too should be
> 'sourcing in' their web-lib.pl information as a way
> to keep your 'basics' consistent with theirs.

I'd rather not depend on the webmin lib for the console command, I'd
like it to be a 'standalone' tool.  In the webmin module that covers 
similar functionality (albeit interactively) I use "web-lib.pl" in
order to get the HTML and CGI extras, with HTML headers and such 
matched to the current webmin theme, and webmin's access control
system that lets me control which users have access to the module.

> p1: thanks for explaining that you were planning
> on actually using that foo.dbm to create the
> 
>   foo.dbm.pag
>   foo.dbm.dir
> 
> even if that makes me go YIKES! may I recommend
> that you adopt the naming strategy
> 
>   foo_dbm
> 
> so as not to scare 'old guys'

Old Guys... Hah...  :^)  Actually, I've changed it to remove the "dbm"
completely, just calling it "rules" within the program, and thus the
files actually created are "rules.pag" and "rules.dir".

> p2: You might also want to look at
> 
>   use SDBM_File;
> 
> which is a db format that comes with Perl
> and is actually a bit More ubiquitous than
> the GDBM_File format, which assumes that the
> build out of perl already had the underlying
> gdbm libraries.

Well, actually I misspoke, and SDBM is what I've used, and doing so
causes it to create the two files noted when I specify "rules.dbm".

> p3: It all goes down hill from here...
> 
> Since of course I will go back to my
> general recommendation to heed the warning
> and shift to 'tie' . That way of course
> would lead you into creating your own
> stand alone DB Abstraction Layer, where you
> hide from yourself and the rest of the system
> what you are doing with the 'db stuff' - and
> since you will be building that out using
> h2xs to correctly form up your perl modules,
> it will be all so much easier.

I'll probably be doing so sometime early next week.  (IE, you can look
forward to more questions from me around then... [grin])

> p4: and on the 3rd week of perl programming.

I have to get there first.  ;^)

> ciao
> drieux

j

-- 
"Not all those who wander are lost."  - JRR Tolkien


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




Re: Parsing problem

2003-12-11 Thread John W. Krahn
Larry Sandwick wrote:
> 
> With the little amount of Perl that I know, I have come to a dilemma. I
> do not know how to parse this file so in column 1 (24165) is the number
> duplicate for every item number in the list. I also need  in the 2
> column  (O185850) to duplicate itself for every item. The 3rd item
> (05/30/03)needs to follow the same process. The file format is below,
> before the parser.
> 
> I know I can split the file on "|" but because the data is not
> consistent and my skill set is limiting me to re-parse this file into a
> file I can upload into MySql I am asking for help and suggestions I do I
> detect that column 1 has change ? Some how I need to read in the first
> three lines for every backorder, before I can start outputting the data?
> 
> This is the file before ( see below what is should look like after the
> parser.  (Before)
> 
> 24165| DEF|   |  | | |
>  |O18580  |259|LEATHER BOOK SIDE TABLE   |1|1|   295.00
>  |05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0|35.00
>  ||1773   |FUNCTIONAL FLOOR LAMP |1|0|62.50
>  ||1302   |MOROCCAN FLORAL BX,BRASS  |1|0|29.00
>  ||1666   |CUBA COFFEE TABLE |1|1|   290.00
>  ||1666   |CUBA SIDE TABLE   |1|1|   147.50
> 24310| ABC|   |  | | |
>  |O18813  |1145   |FLEUR-DE-LIS DOCUMENT BOX |1|0|52.50
>  |07/29/03|1549   |TAOS CENTERPIECE  |1|1|65.00
>  ||1729L  |FRENCH BOX BOOKEND, LEFT  |1|1|69.00
>  ||1729R  |FRENCH BOX BOOKEND, RIGHT |1|1|69.00
>  ||1549   |WINDEMERE BOOK CADDY  |1|0|85.00
>  ||1774   |REVOLVING BOOK TABLE  |1|1|   234.00
>  ||1574   |NORMANDY 3 DRAWER CONSOLE |1|1|   330.00
>  ||1765   |LEATHER BOOKS,ASST.SET/12 |1|1|   175.00
> 5522 |  XYZ   |   |  | | |
>  |O18549  |1551   |HEX LEATHER GARDEN STOOL  |1|0|   130.50
>  |05/20/03|1749   |TRIVET STAND  |1|1|87.75
>  ||1801   |DESK BOX, VICTORIA|1|1|85.50
>  ||1549   |TAOS CENTERPIECE  |1|1|58.50
> 
> (After)
> 
> Format user | itemkey | date | item | description | order | backorder | cost
> 
> 24165|O18580|05/30/03|259|LEATHER BOOK SIDE TABLE   |1|1| 295.00
> 24165|O18580|05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0| 35.00
> 24165|O18580|05/30/03|1773   |FUNCTIONAL FLOOR LAMP |1|0| 62.50
> 24165|O18580|05/30/03|1302   |MOROCCAN FLORAL BX,BRASS  |1|0| 29.00
> 24165|O18580|05/30/03|1666   |CUBA COFFEE TABLE |1|1| 290.00
> 24165|O18580|05/30/03|1666   |CUBA SIDE TABLE   |1|1| 147.50
> 24310|O18813|07/29/03|1145   |FLEUR-DE-LIS DOCUMENT BOX |1|0| 52.50
> 24310|O18813|07/29/03|1549   |TAOS CENTERPIECE  |1|1| 65.00
> 24310|O18813|07/29/03|1729L  |FRENCH BOX BOOKEND, LEFT  |1|1| 69.00
> 24310|O18813|07/29/03|1729R  |FRENCH BOX BOOKEND, RIGHT |1|1| 69.00
> 24310|O18813|07/29/03|1549   |WINDEMERE BOOK CADDY  |1|0| 85.00
> 24310|O18813|07/29/03|1774   |REVOLVING BOOK TABLE  |1|1| 234.00
> 24310|O18813|07/29/03|1574   |NORMANDY 3 DRAWER CONSOLE |1|1| 330.00
> 24310|O18813|07/29/03|1765   |LEATHER BOOKS,ASST.SET/12 |1|1| 175.00
> 5522 |O18549|05/20/03|1551   |HEX LEATHER GARDEN STOOL  |1|0| 130.50
> 5522 |O18549|05/20/03|1801   |DESK BOX, VICTORIA|1|1| 85.50
> 
> Any suggestions would greatly be appreciated !!!

This seems to do what you want:

#!/usr/bin/perl
use warnings;
use strict;

my ( %record, $user );
while (  ) {
my @fields = split /\|/ or next;
if ( /^\d/ or eof DATA ) {
for my $key ( keys %record ) { 
print join( '|', $key, @{ $record{ $key } }{ qw/ itemkey date / }, $_ )
for @{ $record{ $key }{ data } };
}
%record = ( $user = $fields[ 0 ] => {} );
}
else {
if ( $fields[ 1 ] =~ m|\d+/\d+/\d+| ) {
$record{ $user }{ date } = $fields[ 1 ];
}
elsif ( $fields[ 1 ] =~ m|\d+| ) {
$record{ $user }{ itemkey } = $fields[ 1 ];
}
push @{ $record{ $user }{ data } }, join '|', splice @fields, 2;
}
}

__DATA__
24165| DEF|   |  | | |
 |O18580  |259|LEATHER BOOK SIDE TABLE   |1|1|   295.00
 |05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0|35.00
 ||1773   |FUNCTIONAL FLOOR LAMP |1|0|62.50
 ||1302   |MOROCCAN FLORAL BX,BRASS  |1|0|29.00
 ||1666   |CUBA COFFEE TABLE |1|1|   290.00
 | 

Re: nested Paren's

2003-12-11 Thread drieux
On Dec 11, 2003, at 12:16 PM, Eric Walker wrote:

Ok,, back to some laymen terms hehe...
not sure I can do that, but hey, I'll try anything once...

it seems that the two issues are

a. Parser Mechanics
b. File Format.
The file is read by an application and what I am doing is this.
The application use to read this file that was created by hand
to set some internal settings.
The first question is who wrote the application,
and, well, to be polite, did the application writer
share the parser code the it is using to read the file.
But we will get back to this...
for the sake of argument let's assume the simpler

	myApp -f config_file

and myApp parses the config_file and set's it's internal values.
{ yes, the myApp could be reading some 'default config file',
'user preferance files', what ever - there exists some file
let us call it the 'config_file' that will be read to configure
the application . }
[..]
I am trying to dump the current values from the program
and do a compare between the file I auto created
and whats in the program now.
There exists some 'signal' or 'messaging' method that
will tell myapp:
	woof your current configuration data into a file

{ woof - technical term denoting, to heave up the foo.. }

[..]
So the keys Idea is a no go. I am glad at least the data was good 
enough for us
to kick around.  The way they are writting is the only way they can be
do to the application that reads them.
Actually what you will want to step into is
the notion of 'subs' - cf perldoc perlsub,
and you can 'abstract' the 'grovel_woof_file()'
so that it will return you a hash.
eg:

suf grovel_woof_file
{
my ($filename) = @_;
# return undefined if we can not read the file.
return undef unless (-r $filename );
# steal from dzhuo[at]looksmart.net (David)
open(FD, $filename) or die "unable to open $filename :$!";
my $parens;
$parens .= $_ while(); # read in the file
close(FD);
# cf perdoc map - and thank david.
my %hash = map split, $parens =~ /\(+([^()]+)\)+/g;
\%hash; # return hash ref
}
{ Yes, I know, that will ultimately need to be grown out
a bit to deal with the 'variations' in the 'configuration file'
as noted previously... }
then you could do say

my $def_hash = grovel_woof_file($default_file);
make_myApp_woof($new_file); # function to make running myApp Woof...
my $new_hash = grovel_woof_file($new_file);
foreach my $key ( keys %$def_hash )
{
if ( exists($new_hash->{$key}))
{
if ( $new_hash->{$key} eq $def_hash->{$key}) {
print "have same key $key\n";
} else {
whine("new key value", $key, $new_hash->{$key});
}
} else {
whine("no key value", $key, $def_hash->{$key});
}
}
we leave the whine() function to you as an exercise to whine about.
{ we will serve no whine() before it's time... }
 How do you determine if an application has a portable library?
well it is less about being 'portable' in terms of being
able to run on more than one os - as much as it is about
exposing the parser complex that the application is using.
WARNING: drieuxishSoapBoxMoment


Files do not Just GROW in File Systems! There
exists some 'code foo' that creates it, normally
because there is some 'parser foo' that will read it
into applications to set configuration information.
Writers of Configuration File Parsers SHOULD be polite
and offer up access to their Configuration File Parsing
routines so that they can be exposed in other languages,
such as Perl, so that the support crew can be more effective!
App Writers who create WACKO configuration file stuff so as
to create Wacko Configuration File Parsers that they are not
willing to share with their support crew are building up bad
kharma, and the BadKharmaFerrie Will Get them at PayBack!

{ I feel better now. }

I know nothing of that but sounds like something neat and witty..
If I could do that and use a perl module
that would be nice.
what you will want to learn down that path is

perldoc h2xs
perldoc perlmodlib
and specifically you will want to pick up
learning Perl Objects, References and Modules,
as well as the 3rd Edition of Programming perl...
perlknucklehead

I know nothing of xml I am sorry to say. you kinda dove off of the big
diving board and I am still back putting on my floaters. hehehe...
sorry, that Must have been my evil twin Skippy

ciao
drieux


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

Invoking multiple analyses

2003-12-11 Thread Amit Phatak
I am currently invoking an ABAQUS (A finite element analysis package) analysis through 
perl using the command - 

system("/usr/local/bin/tcsh -c 'source /eng/local/lib/source/use -quiet
abaqus; /eng/tools/abaqus/6.3/Commands/abaqus job=$input_file'");

where $input_file has a name like 'file.inp'

This analysis takes around 1 minute to complete until which i stall the script using 
sleep(60).

I now wish to invoke 3 such analyses at the same time on different $input_file files.

Kindly give your suggestions.

Thanks,
Amit



=-=-=-=-=
Never argue with a fool, people might not know the difference.
 - One of Murphy's Laws
-=-=-=-=-
Amit Sudhir Phatak
[http://www.buffalo.edu/~asphatak]

Re: counting down in a for

2003-12-11 Thread DrOwl
At 20:45 11/12/2003, you wrote:


>On Dec 11, 2003, at 11:49 AM, [EMAIL PROTECTED] wrote:
>[..]
>> there is probably a much better way of doing all this i am working on
>>the checkResults sub.
>>it should find the pollerAudit log created by the main process
>>(discover) the file format for the log file is
>>pollerAudit.M.D.Y.h.m.s.lan (MDYhms being month day year hrs min sec)
>[..]
>
>This Might be a good time to step back and
>look at this problem in terms of 'algorithm'
>then worry about the code side. Since, while,
>yes, I can 'read' your code, it may help to begin
>with 'what do you really want/need'?
>
>You are passing in two time values into a function,
>so that you can try to find the 'files' that would
>be made between those times, yes? In particular,
>you are looking for the most recent one, yes?

yes this is right i need the most recent one... as after the log is written it takes a 
few or more seconds for the command to return.
the "discover" or delta can be from a few seconds to a few minits (depending on the 
number of elements configured on the device)



>IF you only need the most recent one, then your basic
>iteration loop could be simplified with say
>
>for ( my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime--)
>{
>#my($fullFileName)="pollerAudit.$fileDate.$_.log";
># make one substitution
>my($fullFileName)="/$NH_HOME/log/pollerAudit.$fileDate.$fTime.log";
>if (-e "$fullFileName") {
>open UPDATELOG, "$fullFileName";
>my($reslutsLog) = ;
>close UPDATELOG;
>last; # break out of the loop we found one
>};
>};

this looks good to me i shall try it out tomorro, but i had a look on CPAN and found a 
golb module that may help???

>The question really is how many files will be in the
>'log' directory - who is cleaning them up - and the
>actual 'delta' between the $highFileName time value,
>and the actual 'youngest file' in the directory.

there are a "lot" of file in the dir, they are cycled / cleaned up, by a scheduled job 
every week,
but some will be a month old (ones the result from a monthly scheduled job)

>Why not Open the directory with say opendir()
>and get the list of files in it? then use
>the readdir() and 'grep' type tricks:
>
>   opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
>   @today_files = grep {$_ =~ /^pollerAudit.$fileDate.*\.log$/ } readdir(DIR);
>   closedir DIR;


humm if i have this list, can i "grep" through and find the one that contains "key" 
(ie host name)
that would do the trick...


>Then all you need to do is 'sort' that @today_files array...
>You might think of solving that problem with 'map',
>since you could then have a hash of 'existing files'
>and would have made one read of 'the directory block'
>and the rest is in core memory manipulations...
>


this could get messy as i could be running say 20 discovers and only after each one 
will the log file be ceated.
+new log could be created by non discover activities.

thanks for your help

Ritchie

>ciao
>drieux
>
>---
>
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003

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


Re: recursive replace command line

2003-12-11 Thread George Georgalis
On Thu, Dec 11, 2003 at 11:07:53AM -0800, R. Joseph Newton wrote:
>If you are going to do your regex work--especially at a high level--in Perl, it is 
>imperative that
>you read the Perl documentation.  The problem in the above sam[ple, or the one that 
>jumps out at me,
>is that you are using the backslash form of back reference in the replacement string. 
> In the Perl
>implementation, that is not appropriate.  Use the built-in scalars ($1, $2 ...) 
>instead.  Backslash
>backreferences are used within the scanning portion of the regex, but not in the 
>replqacement
>string.
>
>Please read:
>perldoc perlre

Thanks for the pointer, Joseph. Indeed, I'm not yet up to speed on
accessing perl-doc, there is quite a lot. ;-)

Bye,
// George

-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




RE: Help with manipulating a string.

2003-12-11 Thread Mark Weisman
I messed something up, for some reason my textarea is not saving the
text to a single line in the text file. I've got a standard text box
that users may hit the enter key to establish different paragraphs
within their post, however, for some reason it carries the CRLF down to
the variable and the text file I'm posting it all too, I know that this
is more html than PERL, but how do I remove the CRLF, and just have the
^M again? Help.

In Service,
Mark


-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2003 5:36 AM
To: Mark Weisman
Cc: [EMAIL PROTECTED]
Subject: Re: Help with manipulating a string.


On Dec 10, 2003, at 1:39 AM, Mark Weisman wrote:

> I've got a multiline text box that will feed the ^M at the end of each

> line. I want to capture it into a single line (which is done), but how

> do I get it back? Not knowing how many lines there may be with the ^M 
> between them. Currently, I use the old standby:
>
>> foreach my $rec (@post) {
>>  chomp($rec)
>>  (Unknown here) = split(/\^M/,$rec);
>>  print "whatever I need printed\n";
>> };
>
> I'm not sure as to how to declare it, or if there is another way?

my @lines = split /\^m/, $rec;

Is that what you mean?  The split just returns a list of the lines, so 
we can stick that in an array.

James


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




RE: specify the special tag :hireswallclock for Benchmark

2003-12-11 Thread Dan Muey


> How does one "specify the special tag :hireswallclock for 
> Benchmark" as mentioned here: 
> http://search.cpan.org/~nwclark/perl-5.8.2/lib/Benchmark.pm#:hireswallclock

Found it:
use Benchmark ':hireswallclock';

Duh!

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




Re: counting down in a for

2003-12-11 Thread drieux
On Dec 11, 2003, at 11:49 AM, [EMAIL PROTECTED] wrote:
[..]
 there is probably a much better way of doing all this i am working on
the checkResults sub.
it should find the pollerAudit log created by the main process
(discover) the file format for the log file is
pollerAudit.M.D.Y.h.m.s.lan (MDYhms being month day year hrs min sec)
[..]

This Might be a good time to step back and
look at this problem in terms of 'algorithm'
then worry about the code side. Since, while,
yes, I can 'read' your code, it may help to begin
with 'what do you really want/need'?
You are passing in two time values into a function,
so that you can try to find the 'files' that would
be made between those times, yes? In particular,
you are looking for the most recent one, yes?
IF you only need the most recent one, then your basic
iteration loop could be simplified with say
for ( my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime--)
{
#my($fullFileName)="pollerAudit.$fileDate.$_.log";
# make one substitution
my($fullFileName)="/$NH_HOME/log/pollerAudit.$fileDate.$fTime.log";
if (-e "$fullFileName") {
open UPDATELOG, "$fullFileName";
my($reslutsLog) = ;
close UPDATELOG;
last; # break out of the loop we found one
};
};
The question really is how many files will be in the
'log' directory - who is cleaning them up - and the
actual 'delta' between the $highFileName time value,
and the actual 'youngest file' in the directory.
Why not Open the directory with say opendir()
and get the list of files in it? then use
the readdir() and 'grep' type tricks:
   opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
   @today_files = grep {$_ =~ /^pollerAudit.$fileDate.*\.log$/ } 
readdir(DIR);
   closedir DIR;

Then all you need to do is 'sort' that @today_files array...
You might think of solving that problem with 'map',
since you could then have a hash of 'existing files'
and would have made one read of 'the directory block'
and the rest is in core memory manipulations...
ciao
drieux
---

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



Parsing problem

2003-12-11 Thread Larry Sandwick
With the little amount of Perl that I know, I have come to a dilemma. I
do not know how to parse this file so in column 1 (24165) is the number
duplicate for every item number in the list. I also need  in the 2
column  (O185850) to duplicate itself for every item. The 3rd item
(05/30/03)needs to follow the same process. The file format is below,
before the parser. 

I know I can split the file on "|" but because the data is not
consistent and my skill set is limiting me to re-parse this file into a
file I can upload into MySql I am asking for help and suggestions I do I
detect that column 1 has change ? Some how I need to read in the first
three lines for every backorder, before I can start outputting the data?
. 

This is the file before ( see below what is should look like after the
parser.  (Before)

 

24165| DEF|   |  | | |

 |O18580  |259|LEATHER BOOK SIDE TABLE   |1|1|   295.00

 |05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0|35.00

 ||1773   |FUNCTIONAL FLOOR LAMP |1|0|62.50

 ||1302   |MOROCCAN FLORAL BX,BRASS  |1|0|29.00

 ||1666   |CUBA COFFEE TABLE |1|1|   290.00

 ||1666   |CUBA SIDE TABLE   |1|1|   147.50

24310| ABC|   |  | | |

 |O18813  |1145   |FLEUR-DE-LIS DOCUMENT BOX |1|0|52.50

 |07/29/03|1549   |TAOS CENTERPIECE  |1|1|65.00

 ||1729L  |FRENCH BOX BOOKEND, LEFT  |1|1|69.00

 ||1729R  |FRENCH BOX BOOKEND, RIGHT |1|1|69.00

 ||1549   |WINDEMERE BOOK CADDY  |1|0|85.00

 ||1774   |REVOLVING BOOK TABLE  |1|1|   234.00

 ||1574   |NORMANDY 3 DRAWER CONSOLE |1|1|   330.00

 ||1765   |LEATHER BOOKS,ASST.SET/12 |1|1|   175.00

5522 |  XYZ   |   |  | | |

 |O18549  |1551   |HEX LEATHER GARDEN STOOL  |1|0|   130.50

 |05/20/03|1749   |TRIVET STAND  |1|1|87.75

 ||1801   |DESK BOX, VICTORIA|1|1|85.50

 ||1549   |TAOS CENTERPIECE  |1|1|58.50

 

(After)

 

Format user | itemkey | date | item | description | order | backorder |
cost

 

24165|O18580|05/30/03|259|LEATHER BOOK SIDE TABLE   |1|1|
295.00

24165|O18580|05/30/03|1774   |FUNCTIONAL TABLE LAMP |1|0|
35.00

24165|O18580|05/30/03|1773   |FUNCTIONAL FLOOR LAMP |1|0|
62.50

24165|O18580|05/30/03|1302   |MOROCCAN FLORAL BX,BRASS  |1|0|
29.00

24165|O18580|05/30/03|1666   |CUBA COFFEE TABLE |1|1|
290.00

24165|O18580|05/30/03|1666   |CUBA SIDE TABLE   |1|1|
147.50

24310|O18813|07/29/03|1145   |FLEUR-DE-LIS DOCUMENT BOX |1|0|
52.50

24310|O18813|07/29/03|1549   |TAOS CENTERPIECE  |1|1|
65.00

24310|O18813|07/29/03|1729L  |FRENCH BOX BOOKEND, LEFT  |1|1|
69.00

24310|O18813|07/29/03|1729R  |FRENCH BOX BOOKEND, RIGHT |1|1|
69.00

24310|O18813|07/29/03|1549   |WINDEMERE BOOK CADDY  |1|0|
85.00

24310|O18813|07/29/03|1774   |REVOLVING BOOK TABLE  |1|1|
234.00

24310|O18813|07/29/03|1574   |NORMANDY 3 DRAWER CONSOLE |1|1|
330.00

24310|O18813|07/29/03|1765   |LEATHER BOOKS,ASST.SET/12 |1|1|
175.00

5522 |O18549|05/20/03|1551   |HEX LEATHER GARDEN STOOL  |1|0|
130.50

5522 |O18549|05/20/03|1801   |DESK BOX, VICTORIA|1|1|
85.50

 

Any suggestions would greatly be appreciated !!!

 

TIA 

 

Larry Sandwick

Sarreid, Ltd.

Network/System Administrator

phone: (252) 291-1414 x223

fax  : (252) 237-1592

 



Re: nested Paren's

2003-12-11 Thread Eric Walker
Ok,, back to some laymen terms hehe...
The file is read by an application and what I am doing is this.  The
application use to read this file that was created by hand to set some
internal settings.  I a wrote a program to pull the same info from a
database. The auto generated file will ultimately be use for the program
to read and set these internal values.  I am trying to dump the current
values from the program and do a compare between the file I auto created
and whats in the program now.  this is why I am trying to suck in all
the values so I can do a compare and make sure the auto generated file
does the same things as the current file that was made by hand. So the
keys Idea is a no go. I am glad at least the data was good enough for us
to kick around.  The way they are writting is the only way they can be
do to the application that reads them.  How do you determine if an
application has a portable library?  I know nothing of that but sounds
like something neat and witty.. If I could do that and use a perl module
that would be nice.

perlknucklehead
 

I know nothing of xml I am sorry to say. you kinda dove off of the big
diving board and I am still back putting on my floaters. hehehe...
On Thu, 2003-12-11 at 12:39, drieux wrote:

On Dec 11, 2003, at 10:52 AM, Eric Walker wrote:

> Well, the problem is that this is just one section
> of a file the other sections actualy have different format.
[..]
> every know and then you get something
> like list( "one" "two").
[..]
> The data i am making up as I didn't think it
> was important.  I figured the form is what was needed.
[..]
> Once I get the
> key value pairs it doesn't matter because I am going to read another
> file like this and compare the data to make sure nothing has changed
> between the two files.
[..]

p0: the 'data' that you made up, was good enough to
get us some direction to start looking at solutions.

p1: You might ultimately want to look at a re-write
of how those 'files' are being created, so that the
sub-sequent post parsing is simpler. IF that is
not an option - then you might want to see if the
application that created the format has a library
that can be 'ported' and hence build out a perl module
of your own that would share it's parser structure.

p1.1 - either go with say an xml-ish model
hence use the LibXml module for parsing

p1.2 - assume that the applications library is
lib_fung_parser.so - then you want to get
your hands on the header files and use h2xs to
generate your Fung::Parser module

p2: The problem of multiple section readings from a
file should lead you towards a simpler process where
you have keys in the file that indicate which 'parser'
to be using at which point you might want to look at
a 'dispatcher'... where each 'function' knows how\
to return stuff related to what it knows how to read,
and specifically how it's 'end of section' will tell it
to stop parsing and go back.



ciao
drieux

---


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





counting down in a for

2003-12-11 Thread drowl

Hi all

 there is probably a much better way of doing all this i am working on
the
checkResults sub.
it should find the pollerAudit log created by the main process
(discover) the file format for the log file is
pollerAudit.M.D.Y.h.m.s.lan (MDYhms being month day year hrs min sec)
but as we do not know what the file name will be i want to search for
it, it will be between startTime and EndTime but closest to endTime

so i thort i should use a for loop form Max to Min as below, but its all
getting rather messy.

is there some CSPAN module that can help me out?
or has any one got any suggestions for a betta way to do this.
i have included the full proggi below for reff...


sub checkResults {
my($NH_HOME,$reslutsLog)=("nethealth1","");
my($lowTime,$highTime)=($_[0],$_[1]) ;
my($fileDate)=strftime("%m.%d.%Y",localtime($lowTime));
my($lowFileName)=strftime("%H%M%S",localtime($lowTime));
my($highFileName)=strftime("%H%M%S",localtime($highTime)); for (
my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime--
) {
my($fullFileName)="pollerAudit.$fileDate.$_.log";
if (-e "/$NH_HOME/log/$fullFileName") {
open UPDATELOG, "$NH_HOME/log/$fullFileName";
my($reslutsLog) = ;
close UPDATELOG;
};

};
print "$reslutsLog";


}


oh and before any one starts sorry about my bad spellings.

---
fnord
yes im a _Concord_ Engineer, no it never flown!

--
#!/usr/local/bin/perl
#
use strict;
use warnings;
use POSIX qw(strftime);


# main discover
#
#



my ($dataFileName)=$ARGV[0];# get file name of discover file
my ($SdtArfName)=$ARGV[1];  # get  std rule name


open DFILE, "$dataFileName"  # open datafile and read in  or die
or die "no file specified command format is \"autoDiscover
FILE-NAME Server \" $!";
my (@dataFile) = ;
close DFILE;

foreach my $site (@dataFile) {  # loop  for each line/site in dataFile
chomp $site ;
my ($siteIP,$siteString)=makeArf("$site","$SdtArfName"); # make
ARF file then return IP and Cominity String

print " Discovering $siteIP with $siteString \n ";

my ($startTime)=time;   # log start time of discover
`nhAutoDiscover -noCommit -l \"$siteIP\" -c \"$siteString\"
-mode
\"lanwan,router\" -nmsSource \"NH:Discover\" -dciRule
\"$siteIP.arf\" > tmp.$siteIP.Results \n `; # this is the command used
to do the discover
my ($endTime)=time; # log start time of discover
checkResults("$startTime","$endTime");  # run the results sub };

sub checkResults {
my($NH_HOME,$reslutsLog)=("nethealth1","");
my($lowTime,$highTime)=($_[0],$_[1]) ;
my($fileDate)=strftime("%m.%d.%Y",localtime($lowTime));
my($lowFileName)=strftime("%H%M%S",localtime($lowTime));
my($highFileName)=strftime("%H%M%S",localtime($highTime)); for (
my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime--
) {
my($fullFileName)="pollerAudit.$fileDate.$_.log";
if (-e "/$NH_HOME/log/$fullFileName") {
open UPDATELOG, "$NH_HOME/log/$fullFileName";
my($reslutsLog) = ;
close UPDATELOG;
};

};
print "$reslutsLog";


}



sub makeArf {
# Start of sub that makes arf files

# this function creates a arf rule file from input Data
# Version 0.1 6/11/03 original
# 0.2 21/11/03 tryed to convert to sub
# 0.3 42/11/03 finished converting to sub


my ($csvData)="$_[0]";
my ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$csvData,3); #split
up main / pvc info
my
($siteIP,$siteString,$siteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,/,$siteLink,6);
#split up main info
my @sitePVCs = split(/;/,$siteAllPVCs,$siteNoOfPVCs);

my $siteARFFILE = "$siteIP.arf";
open ARFFILE, ">$siteARFFILE"
or die "can not open '$siteARFFILE': $!";

# print header
print ARFFILE <;
close IN;
print ARFFILE "@standardRules\n"; #print standard bits



# print -Cpu- rule
print ARFFILE  




Re: nested Paren's

2003-12-11 Thread drieux
On Dec 11, 2003, at 10:52 AM, Eric Walker wrote:

Well, the problem is that this is just one section
of a file the other sections actualy have different format.
[..]
every know and then you get something
like list( "one" "two").
[..]
The data i am making up as I didn't think it
was important.  I figured the form is what was needed.
[..]
Once I get the
key value pairs it doesn't matter because I am going to read another
file like this and compare the data to make sure nothing has changed
between the two files.
[..]

p0: the 'data' that you made up, was good enough to
get us some direction to start looking at solutions.
p1: You might ultimately want to look at a re-write
of how those 'files' are being created, so that the
sub-sequent post parsing is simpler. IF that is
not an option - then you might want to see if the
application that created the format has a library
that can be 'ported' and hence build out a perl module
of your own that would share it's parser structure.
p1.1 - either go with say an xml-ish model
hence use the LibXml module for parsing
p1.2 - assume that the applications library is
lib_fung_parser.so - then you want to get
your hands on the header files and use h2xs to
generate your Fung::Parser module
p2: The problem of multiple section readings from a
file should lead you towards a simpler process where
you have keys in the file that indicate which 'parser'
to be using at which point you might want to look at
a 'dispatcher'... where each 'function' knows how\
to return stuff related to what it knows how to read,
and specifically how it's 'end of section' will tell it
to stop parsing and go back.


ciao
drieux
---

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



Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread drieux
On Dec 11, 2003, at 10:28 AM, Tassilo von Parseval wrote:
[..]
 And since my attempts to get the specs for these META.yml failed,
I am the more happy that the latest EU::MakeMaker creates it for me.
[..]

Excuse me while I giggle UNCONTROLably ( yes, I know
that is read as 'screaming, in some ascii art - it was
so intended. { ok, so I not spelt gooder in ascii either } )
p0: given that 'ya' traditionally denotes 'yet another',
it worries me that most folks do not see 'yada'
as 'yet another dumb acronym'. Mean while we have shifted
from 'yaml' to 'yml' as the TLA suffix...
p1: given that I have been living with the dialectical
tension of the voices in my head, where on one side
i have 'sgt. rock' asking "do we have a dog in this fight?"
and the 'college boy' in me willing to get 'wrapped
around the axil' for some purely pedantic "issue"
I think I'll just follow your lead Sarge

If and when they decide that we really need to
know how exactly they want to deal with this
"yaml-ization" I am more than sure that the
word will come on down from on high, and at
that time College Boy we will tell you your position...
Which of course is what makes me just bend over
and giggle at the "growth" and/or "bloat" in
	h2xs, the EU::MM and ...

not to mention the ongoing efforts to either
adopt the Build v. Maker Model, and the ... and ...
p2: Next time I think we should have a nice clean
useful and appropriate BDUF about how Perl Really
should have been built, developed, maintained, so
that all due regards to the efficiencies of the
algorithms with conform to the matrix of maintainablity...
	yada, yada, yada...

p3: "plan to improvise" - not just a slogan anymore.

ciao
drieux
---

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



RE: Use DBI quote without creating an object

2003-12-11 Thread david
David wrote:

> Bob Showalter wrote:
> 
>>use DBI;
>>print DBD::_::db->quote('Hello');
>> 
>> perldoc -m DBI
> 
> this does not work, you need:
> 

sorry. i am wrong. your version works as well.

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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




RE: Use DBI quote without creating an object

2003-12-11 Thread david
Bob Showalter wrote:

>use DBI;
>print DBD::_::db->quote('Hello');
> 
> perldoc -m DBI

this does not work, you need:

[panda]# perl -MDBI -le 'print DBD::_::db::quote(1,"abcd")'

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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




Re: Use DBI quote without creating an object

2003-12-11 Thread Daniel Staal
--As off Thursday, December 11, 2003 12:53 PM -0600, Dan Muey is 
alleged to have said:

I'd like to use DBI's quote function without having to
connect to a database and without having to create my own!
Is that possible?
--As for the rest, it is mine.

I would suspect it is not possible.  You have a simple problem here: 
what quote format does DBI need to use?  The purpose of the quote 
function is that each database needs a different quote format.  If 
you haven't connected to a database how can DBI know which you intend 
to use?

The only thing I would try yet at this point would be importing the 
DBD's (for your specific database) quote function (I'm assuming quote 
is implemented in the obvious way) and using it directly, but I 
wouldn't count on that working.

Either that or re-think your problem, so that you don't have to quote 
it until you actually know which database you are using...

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Use DBI quote without creating an object

2003-12-11 Thread Bob Showalter
Dan Muey wrote:
> Howdy!
> 
> I'm creating some sql entries into a text file.
> 
> I'd like to use DBI's quote function without having to
> connect to a database and without having to create my own!
> 
> Is that possible?
> 
> I've tried importing quote, doing DBI::quote, DBI::db::quote, and
> various versions of that. 
> 
> Any ideas?
> 
> GOAL:
> use DBI;
> my $quoted_data = DBI->quote($data);
> 
> Instead of
> 
> use DBI;
> my $dbh - DBI->connect(...)...;
> my $quoted_data = $dbh->quote($data);

   use DBI;
   print DBD::_::db->quote('Hello');

perldoc -m DBI

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




Re: dbmopen problem - solved

2003-12-11 Thread drieux
On Dec 10, 2003, at 11:34 PM, Joel Newkirk wrote:
[..]
I found my problem - apparently webmin was doing "use GDBM_File;" for
me, which is why it worked in the webmin module, and since I wasn't
including either that or the webmin "web-lib.pl" it was defaulting to a
different DB format, hence the "File Not Found" error.  Once I include
"Use GDBM_File;" I can successfully read the DBM written by the webmin
module.  Doh!  Maybe my second week with Perl will be smoother... ;^)
[..]

p0: if you want to have 'compatibility' with webmin,
you might work out whether or not you too should be
'sourcing in' their web-lib.pl information as a way
to keep your 'basics' consistent with theirs.
p1: thanks for explaining that you were planning
on actually using that foo.dbm to create the
foo.dbm.pag
foo.dbm.dir
even if that makes me go YIKES! may I recommend
that you adopt the naming strategy
	foo_dbm

so as not to scare 'old guys'

p2: You might also want to look at

	use SDBM_File;

which is a db format that comes with Perl
and is actually a bit More ubiquitous than
the GDBM_File format, which assumes that the
build out of perl already had the underlying
gdbm libraries.
p3: It all goes down hill from here...

Since of course I will go back to my
general recommendation to heed the warning
and shift to 'tie' . That way of course
would lead you into creating your own
stand alone DB Abstraction Layer, where you
hide from yourself and the rest of the system
what you are doing with the 'db stuff' - and
since you will be building that out using
h2xs to correctly form up your perl modules,
it will be all so much easier.
p4: and on the 3rd week of perl programming.



ciao
drieux
---

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



Re: recursive replace command line

2003-12-11 Thread R. Joseph Newton
George Georgalis wrote:

>
> that's what I needed to hear... however replacing text (with memory
> capturing) is still a problem:
>
> perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name 
> '*.txt' )

Hi George,

If you are going to do your regex work--especially at a high level--in Perl, it is 
imperative that
you read the Perl documentation.  The problem in the above sam[ple, or the one that 
jumps out at me,
is that you are using the backslash form of back reference in the replacement string.  
In the Perl
implementation, that is not appropriate.  Use the built-in scalars ($1, $2 ...) 
instead.  Backslash
backreferences are used within the scanning portion of the regex, but not in the 
replqacement
string.

Please read:
perldoc perlre

Joseph


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




Use DBI quote without creating an object

2003-12-11 Thread Dan Muey
Howdy!

I'm creating some sql entries into a text file.

I'd like to use DBI's quote function without having to 
connect to a database and without having to create my own!

Is that possible?

I've tried importing quote, doing DBI::quote, DBI::db::quote, and various versions of 
that.

Any ideas?

GOAL:
use DBI;
my $quoted_data = DBI->quote($data);

Instead of

use DBI;
my $dbh - DBI->connect(...)...;
my $quoted_data = $dbh->quote($data);


TIA

Dan

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




Re: nested Paren's

2003-12-11 Thread Eric Walker
Well, the problem is that this is just one section of a file the other
sections actualy have different format. When I get to this section I key
on the section name to know how to process it and will need to key on
the last paren know that this section is done and to try and key on what
the next section is and how it is processed.  Not all of the data in
this section is of the form mon 1 every know and then you get something
like list( "one" "two").  The data i am making up as I didn't think it
was important.  I figured the form is what was needed.   Once I get the
key value pairs it doesn't matter because I am going to read another
file like this and compare the data to make sure nothing has changed
between the two files.  I like the regx thing tho, it gives me some
ideas.. I will see if I can make it work with that...

perl knucklehead

On Thu, 2003-12-11 at 11:28, drieux wrote:

On Dec 11, 2003, at 9:30 AM, Eric Walker wrote:
[..]
> yes( "hello" "goodbye"
>
>  ( (one 2) (two 3) (three 4)
>  )
>  (( mon 1) (tues 2) (wed 3)
>  )
>  ((jan 1) (feb 2) (march 3)
>  )
> )
[..]
The question of course is whether that 'ordering'
is important, or can you just use a hash?

IF you do not really need to know about the
paren count then don't count it. IF you
know that your generalized date is going to
be of the form

( )

then your word_num regEx would look like

my $word_num = qr/\( # our opening paren
(\w+)\s+(\d+)
\)/ix; # our closing paren

I use the 'x' option to lay it out pretty like that.

then the rest is a walker

while (  ) {
chomp;
next if (/^\s*$/); # no need empty lines
s/^\s+//; # kill leaing lines
my $line = $_; # now we have a line to play with
while ( $line =~ /$word_num(.*)/)
{
$hash{$1} = $2; # our $word_num pattern fetched these
$line = $3; # for everything else there is (.*)
}
}

while (my ($k, $v) = each %hash)
{
print "$k -> $v\n";
}



ciao
drieux

---


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





Re: Problem with 'cc' command in CPAN makes (i.e., Bundle::CPAN)

2003-12-11 Thread drieux
On Dec 11, 2003, at 7:41 AM, glidden, matthew wrote:

I'm using the CPAN module to build my modules and have hung up just 
trying
install Bundle::CPAN. Installing Data::Dumper, for example, shows a 
'cc:
command not found' error during make. My system uses gcc instead of 
cc, but
I'm not sure where to set this option. Tried setting the CC env 
setting and
looking through .cpan/CPAN/MyConfig.pm, but no setting there seems 
right,
either. Where can I change the cc setting?
what you might want to check is:

	perl -MConfig -e 'print "$Config{cc}\n"';

a la
vladimir: 52:] perl -MConfig -e 'print "$Config{cc}\n"';
gcc
vladimir: 53:]
and/or -

[jeeves: 9:] perl -MConfig -e 'print "$Config{cc}\n"';
cc
[jeeves: 10:] which cc
/usr/bin/cc
[jeeves: 11:] ls -li /usr/bin/cc
1749093 lrwxr-xr-x  1 root  wheel  7 28 Nov 18:14 /usr/bin/cc -> gcc-3.3
[jeeves: 12:]
It is POSSIBLE that the version of perl you
have was built 'by the vendor' and Might
have the line in the Config.pm that is
	cc='cc'

eg:
vladimir: 63:] ^more^grep cc
./perl -V | grep cc
cc='cc', ccflags ='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
ccversion='Sun WorkShop', gccversion='', gccosandvers=''
ld='cc', ldflags =''
libpth=/lib /usr/lib /usr/ccs/lib
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R 
/usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE'
cccdlflags='-KPIC', lddlflags='-G'
11374 Make h2ph grok ccsymbols fo the form 1234L, 1234ULL etc
vladimir: 64:]

So you might want to work out a way that you have
say
	PATH = $HOME/bin:$PATH

and in your home/bin directory put in the symbolic
link for
	cc -> /opt/gnudev/bin/gcc

or where ever you have it installed. This way you
avoid
a. bit twiddling the Config.pm
b. have the cheap-cheat that is not an ENV trick


ciao
drieux
---

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



Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread Tassilo von Parseval
On Thu, Dec 11, 2003 at 09:32:18AM -0800 drieux wrote:

> On Dec 10, 2003, at 11:35 PM, Tassilo von Parseval wrote:

> >a decent META.yml is created and added to the distribution.
> 
> I'm still working out if i really 'get it'
> about the 'yml' trend.

I haven't yet grokked it either. AFAIK it's one day going to be CPAN's
reservoir for meta data on modules. This was as much as I was able to
deduce from following the discussions on the porters-list. And since my
attempts to get the specs for these META.yml failed, I am the more happy
that the latest EU::MakeMaker creates it for me.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval


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




Re: specify the special tag :hireswallclock for Benchmark

2003-12-11 Thread Wiggins d Anconia


> 
> How does one "specify the special tag :hireswallclock for Benchmark"
as mentioned here:
>
http://search.cpan.org/~nwclark/perl-5.8.2/lib/Benchmark.pm#:hireswallclock
> 
> TIA
> 
> DMuey

Remember this is open source, you can check yourself... incidentally it
appears that the tag is checked for in the standard 'import' function,
which means the tag is issued similar to other modules' import tags, aka:

use Benchmark qw( :hireswallclock );

Though admittedly that is an odd location in the docs to put such
information and should really have an example to go with it...

At least I think :-) 

http://danconia.org


--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.

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




Re: nested Paren's

2003-12-11 Thread drieux
On Dec 11, 2003, at 9:30 AM, Eric Walker wrote:
[..]
yes( "hello" "goodbye"

 ( (one 2) (two 3) (three 4)
 )
 (( mon 1) (tues 2) (wed 3)
 )
 ((jan 1) (feb 2) (march 3)
 )
)
[..]
The question of course is whether that 'ordering'
is important, or can you just use a hash?
IF you do not really need to know about the
paren count then don't count it. IF you
know that your generalized date is going to
be of the form
	( )

then your word_num regEx would look like

my $word_num = qr/\( # our opening paren
(\w+)\s+(\d+)
\)/ix; # our closing paren
I use the 'x' option to lay it out pretty like that.

then the rest is a walker

while (  ) {
chomp;
next if (/^\s*$/); # no need empty lines
s/^\s+//; # kill leaing lines
my $line = $_; # now we have a line to play with
while ( $line =~ /$word_num(.*)/)
{
$hash{$1} = $2; # our $word_num pattern fetched these
$line = $3; # for everything else there is (.*)
}
}

while (my ($k, $v) = each %hash)
{
print "$k -> $v\n";
}


ciao
drieux
---

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



Re: nested Paren's

2003-12-11 Thread david
Eric Walker wrote:

> Hey all,
> I have a file with some data that has like nested parens.. example
> 
> yes( "hello" "goodbye"
> 
>  ( (one 2) (two 3) (three 4)
>  )
>  (( mon 1) (tues 2) (wed 3)
>  )
>  ((jan 1) (feb 2) (march 3)
>  )
> )
> 
> I need help  in trying to break this up and make key value pairs out of
> the data example:
> KEYVALUE
> one  2
> two  3
> three4
> mon 1
> tues 2
> wed 3
> jan   1
> feb   2
> march   3
> 

there are many ways of doing that, here is one:

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

(my $parens= 




specify the special tag :hireswallclock for Benchmark

2003-12-11 Thread Dan Muey

How does one "specify the special tag :hireswallclock for Benchmark" as mentioned here:
http://search.cpan.org/~nwclark/perl-5.8.2/lib/Benchmark.pm#:hireswallclock

TIA

DMuey

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




Re: Search and Replace question

2003-12-11 Thread david
Saju Palayur wrote:

> Hi
> 
> I am trying to do some thing like this, but am getting the wrong output.
> Can somebody tell if my regular expression is wrong or not?
> 
> -Perl script---
> $line = "ABCXYZGwcTI\\ABCXYZIntValTI";
> 
> $line=~s/ABCXYZ(.*)TI/Hello$1/g;
> print $line;
> -Output---
> HelloGwcTI\\ABCXYZIntVal

that's not the output of the above script. you shouldn't see '\\', there 
should be just one. the other one is long gone from the double quote. next 
time you post, you should be more careful to provide the correct output of 
your script as to avoid confusion.

> -Expected Output-
> HelloGwc\\HelloIntVal
> --

again, i assume you mean: "HelloGwc\HelloIntVal"

the reason is because (.*) is greedy and matching from the first 'G' up to 
the last 'l'. you need to stop the greedy-ness (.*) like:

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

my $line1 = "ABCXYZGwcTI\\ABCXYZIntValTI";
my $line2 = $line1;

#--
#-- for your purpose, you can use either one of followings
#--
$line1 =~ s/ABCXYZ(.+?)TI/Hello$1/g;
$line2 =~ s/ABCXYZ(.*?)TI/Hello$1/g;

print $line1,"\n";
print $line2,"\n";

__END__

prints:

HelloGwc\HelloIntVal
HelloGwc\HelloIntVal

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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




RE: Search and Replace question

2003-12-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Saju Palayur wrote:
> Hi
> 
> I am trying to do some thing like this, but am getting the wrong
> output. Can somebody tell if my regular expression is wrong or not?
> 
> -Perl script---
> $line = "ABCXYZGwcTI\\ABCXYZIntValTI";
> 
> $line=~s/ABCXYZ(.*)TI/Hello$1/g;
Regex by nature are greedy so you need to tell it not to be greedy. So if you 
try

$line =~ s/ABCXYZ(.+?)TI/Hello$1/g;

You will get the hello's correctly, but not the \'s.  If you want the double 
slash then you should have 4 slash's to get two slashes.  I tried with single qutoes 
and still had problems.  So we  will see how the gurus would handle.

Wags ;)
> print $line;
> -Output---
> HelloGwcTI\\ABCXYZIntVal
> -Expected Output-
> HelloGwc\\HelloIntVal
> --
> Thanks in Adcance
> Saju
> 
> _
> Tired of slow downloads and busy signals?  Get a high-speed Internet
> connection! Comparison-shop your local high-speed providers here.
> https://broadband.msn.com



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



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




Re: recursive replace command line

2003-12-11 Thread George Georgalis
On Thu, Dec 11, 2003 at 11:21:39AM -0500, Jeff 'japhy' Pinyan wrote:
>On Dec 11, George Georgalis said:
>
>>On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote:
>>>On Dec 10, George Georgalis said:
>>>
giving my perl a retry, I found some hints on a website to recursively
replace text

perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
'*.txt' )
>>>
>>>This isn't recursively replacing text; it's recursively going through a
>>>directory tree.
>>>
but from what I can tell, perl doesn't support the \1 for \(*\) symbols
like sed does.  What is the work around?
>>>
>>>Because Perl is not sed.  Perl uses (...), not \(...\) for its memory
>>>capturing.  In Perl's regexes, all non-alphanumeric metacharacters don't
>>>use backslashes.  That means [...] for character classes, not \[...\], and
>>>+ for " 1 or more", not \+, and so on.
>>
>>that's what I needed to hear... however replacing text (with memory
>>capturing) is still a problem:
>>
>>perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name 
>>'*.txt' )
>
>Right; first of all, \1 should only be used IN the regex ITSELF.  Outside
>of the regex, you should use $1.  However, "331$12027" still isn't
>appropriate; you'll need "331${1}2027".  The reason "331\12027" gave you
>"331P27" is because octal character 120 is "P".

Thanks,

perl -p -i -e 's/347(.)451(.)8229/646${1}331${2}2027/g;' $( find ./ -type f -name 
'*.html' -o -name '*.txt' )
perl -p -i -e 's/347(..)451(.)8229/646${1}331${2}2027/g;' $( find ./ -type f -name 
'*.html' -o -name '*.txt' )

worked perfect to update my web pages... :)
btw - what's the best manpage for the perl command line options?

TAI, 

// George


-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread drieux
On Dec 10, 2003, at 11:35 PM, Tassilo von Parseval wrote:
On Wed, Dec 10, 2003 at 02:26:40PM -0800 drieux wrote:
On Dec 10, 2003, at 4:39 AM, Ben Crane wrote:
[..]
5.8.2's h2xs
[..]
 in accordance with the preferred style of CPAN modules:

[EMAIL PROTECTED]:/tmp$ h2xs5.8.2 -b 5.6.0 -AX Wetware::Pid
Writing Wetware-Pid/lib/Wetware/Pid.pm
[..]
Writing Wetware-Pid/t/Wetware-Pid.t
[..]

Thank you for the Happy Moment There!!!

I'm still not sure I like the

	Foo::Bar

being converted into

	Foo-Bar

although that was what we had adopted for our
build and release system since we were converting
them on into Solaris Packages.
[..]
a decent META.yml is created and added to the distribution.
I'm still working out if i really 'get it'
about the 'yml' trend.
[..]
I used to belong to the 'interleave pod and code' school
but soon changed that when I realized that there is no
way to interleave POD into XS files.
Oye, yes... that was one of those 'byte me' elements
of XS that took me a
	What is the Wild, Wild World of Sports

iteration or two to figure out that I really did
not want, and/or need to put the comments into
the foo.XS itself.
I think I have decided that there needs to be
some alternative file that would be the
	ReadMe.Maintainer

file of kvetchings that are not pod for
the user of the module, but are if anything
notes about why one opted for A over B...
ciao
drieux
---

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



nested Paren's

2003-12-11 Thread Eric Walker
Hey all,
I have a file with some data that has like nested parens.. example

yes( "hello" "goodbye"

 ( (one 2) (two 3) (three 4)
 )
 (( mon 1) (tues 2) (wed 3)
 )
 ((jan 1) (feb 2) (march 3)
 )
)

I need help  in trying to break this up and make key value pairs out of
the data example:
KEYVALUE
one  2
two  3
three4
mon 1
tues 2
wed 3
jan   1
feb   2
march   3

I currently to a while loop in the file and join each line and count the
opening and closing parens, this gets the entire set of lines in one
array location for me.  Now I get confused and need help to parse it
into key value pairs.

Thanks
perl knucklehead



)




(OT) RE: ScanMail Message: To Sender Match eManager setting and take actio n.

2003-12-11 Thread Tim Johnson
 
Far be it from me to tell someone else how to configure their email
filter, but maybe they should think about putting the subject line of
the email in the automated response?  

I wouldn't worry about it too much.  If they're using the default word
lists it could be almost anything.




-Original Message-
From: drieux [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 11, 2003 8:56 AM
To: System Attendant
Cc: Perl Perl
Subject: Re: ScanMail Message: To Sender Match eManager setting and take
actio n.


On Dec 11, 2003, at 4:14 AM, System Attendant wrote:

>  eManager Notification *
>
> The following mail was blocked since it contains sensitive content.
>
(snip)
>
> Please refrain from sending email that contains acial comments.
>
> *** End of message *

can someone explain this?

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




Re: ScanMail Message: To Sender Match eManager setting and take actio n.

2003-12-11 Thread drieux
On Dec 11, 2003, at 4:14 AM, System Attendant wrote:

 eManager Notification *

The following mail was blocked since it contains sensitive content.

Source mailbox: [EMAIL PROTECTED]
Destination mailbox(es): [EMAIL PROTECTED]
Rule/Policy: Racial Discrimination
Action: Quarantine to 
D:\Trend\SMCF\Quarantine\2003-12-11\05-14-53.22087

Please refrain from sending email that contains acial comments.

*** End of message *
can someone explain this?



ciao
drieux
---

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



Re: md5 function

2003-12-11 Thread Jeff 'japhy' Pinyan
On Dec 11, Dan Anderson said:

>Caveat Coder!  Perl can be set up so that the @INC doesn't point to the
>core modules.  I have seen this on shared hosting, where (I assume) the
>sys admin decided to use it as a way to secure the box.
>
>Of course, if you use something like this:
>
>BEGIN  {
>  unshift "./modules", @INC;
>}
>
>you can then store all your modules in the ./modules directory and have
>them accessed.  Of course, this may or may not violate their terms if
>you're selling the script.

I'd prefer you propogate

  use lib "modules";

which does what you show above, plus a little more (see the lib.pm docs).

However, if @INC has been set up so that lib.pm can't be found... then
you're in a world of hurt.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: recursive replace command line

2003-12-11 Thread Jeff 'japhy' Pinyan
On Dec 11, George Georgalis said:

>On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote:
>>On Dec 10, George Georgalis said:
>>
>>>giving my perl a retry, I found some hints on a website to recursively
>>>replace text
>>>
>>>perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
>>>'*.txt' )
>>
>>This isn't recursively replacing text; it's recursively going through a
>>directory tree.
>>
>>>but from what I can tell, perl doesn't support the \1 for \(*\) symbols
>>>like sed does.  What is the work around?
>>
>>Because Perl is not sed.  Perl uses (...), not \(...\) for its memory
>>capturing.  In Perl's regexes, all non-alphanumeric metacharacters don't
>>use backslashes.  That means [...] for character classes, not \[...\], and
>>+ for " 1 or more", not \+, and so on.
>
>that's what I needed to hear... however replacing text (with memory
>capturing) is still a problem:
>
>perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name 
>'*.txt' )

Right; first of all, \1 should only be used IN the regex ITSELF.  Outside
of the regex, you should use $1.  However, "331$12027" still isn't
appropriate; you'll need "331${1}2027".  The reason "331\12027" gave you
"331P27" is because octal character 120 is "P".

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




RE: copying complex data structures

2003-12-11 Thread NYIMI Jose (BMB)
Try clone method of Storable module from CPAN.
There is also Clone module out there.

HTH,

José.

-Original Message-
From: West, William M [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 11, 2003 4:37 PM
To: [EMAIL PROTECTED]
Subject: copying complex data structures




the following will not work:

$arrayref_one = $arrayreftwo; #it's just making a new name for the same
#reference.


the following works fine:

foreach my $a (0..$what){
foreach my $b (0..$why){
$arrayref_one->[$a]->[$b] = $arrayref_two->[$a]->[$b];

}
}

it would be nice to have something to copy complex data structures that isn't going to 
be a code maintenance headache-  the above is dependent on the data structure being a 
"2 dimensional array" of particular size. i don't want that restriction.

any help would be apreciated :)

thanks,
willy


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





 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: copying complex data structures

2003-12-11 Thread James Edward Gray II
On Dec 11, 2003, at 9:37 AM, West, William M wrote:



the following will not work:

$arrayref_one = $arrayreftwo; #it's just making a new name for the same
#reference.
the following works fine:

foreach my $a (0..$what){
foreach my $b (0..$why){
$arrayref_one->[$a]->[$b] = $arrayref_two->[$a]->[$b];
}
}
it would be nice to have something to copy complex data structures that
isn't going to be a code maintenance headache-  the above is dependent
on the data structure being a "2 dimensional array" of particular size.
i don't want that restriction.
any help would be apreciated :)
From the Perl Cookbook (2nd Edition), recipe 11.12:

use Storable;
$arrayref_one = dclone( $arrayref_two );
James

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



RE: Problem with 'cc' command in CPAN makes (i.e., Bundle::CPAN)

2003-12-11 Thread Thomas Bätzler
Hi,

glidden, matthew <[EMAIL PROTECTED]> asked:
> I'm using the CPAN module to build my modules and have hung 
> up just trying install Bundle::CPAN. Installing Data::Dumper,
> for example, shows a 'cc: command not found' error during make.
> My system uses gcc instead of cc, but I'm not sure where to 
> set this option.

That information lives in Config.pm, which is created
during the build process of Perl. Tweaking this might
or might not help you - on Win32 at least, you can't
build Perl modules for ActiveState's binary port with
GCC. Your best bet is to roll your own Perl, of course.
Apart from that, you might want to try and install the
same compiler environment as used by the peope who built
your Perl.

HTH,
Thomas

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




Search and Replace question

2003-12-11 Thread Saju Palayur
Hi

I am trying to do some thing like this, but am getting the wrong output. Can 
somebody tell if my regular expression is wrong or not?

-Perl script---
$line = "ABCXYZGwcTI\\ABCXYZIntValTI";
$line=~s/ABCXYZ(.*)TI/Hello$1/g;
print $line;
-Output---
HelloGwcTI\\ABCXYZIntVal
-Expected Output-
HelloGwc\\HelloIntVal
--
Thanks in Adcance
Saju
_
Tired of slow downloads and busy signals?  Get a high-speed Internet 
connection! Comparison-shop your local high-speed providers here. 
https://broadband.msn.com

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



RE: -e with single quotes

2003-12-11 Thread Dan Muey


Thanks for all the suggestions everyone!
I'll keep playing around until I get it all ironed out.

Thanks!
Dan

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




Re: recursive replace command line

2003-12-11 Thread George Georgalis
On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote:
>On Dec 10, George Georgalis said:
>
>>giving my perl a retry, I found some hints on a website to recursively
>>replace text
>>
>>perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
>>'*.txt' )
>
>This isn't recursively replacing text; it's recursively going through a
>directory tree.
>
>>but from what I can tell, perl doesn't support the \1 for \(*\) symbols
>>like sed does.  What is the work around?
>
>Because Perl is not sed.  Perl uses (...), not \(...\) for its memory
>capturing.  In Perl's regexes, all non-alphanumeric metacharacters don't
>use backslashes.  That means [...] for character classes, not \[...\], and
>+ for " 1 or more", not \+, and so on.

that's what I needed to hear... however replacing text (with memory
capturing) is still a problem:

perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name 
'*.txt' )

here I'm trying to replace instances of of a phone number, that might
use "-" " " or "." to separate the first and second parts.
451-8229 to 331-2027
451 8229 to 331 2027
etc

the result "331P27" hinted 3 digits may be used for the call back

perl -p -i -e 's/451(.)8229/331\0012027/g;' $( find ./ -type f -name '*.html' -o -name 
'*.txt' )

that puts the characters where they go but the dash has changed to some
other character (an ascII 001 I suppose).

// George


-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




Problem with 'cc' command in CPAN makes (i.e., Bundle::CPAN)

2003-12-11 Thread glidden, matthew
I'm using the CPAN module to build my modules and have hung up just trying
install Bundle::CPAN. Installing Data::Dumper, for example, shows a 'cc:
command not found' error during make. My system uses gcc instead of cc, but
I'm not sure where to set this option. Tried setting the CC env setting and
looking through .cpan/CPAN/MyConfig.pm, but no setting there seems right,
either. Where can I change the cc setting?

-- 
Matthew Glidden 

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




copying complex data structures

2003-12-11 Thread West, William M


the following will not work:

$arrayref_one = $arrayreftwo; #it's just making a new name for the same
#reference.


the following works fine:

foreach my $a (0..$what){
foreach my $b (0..$why){
$arrayref_one->[$a]->[$b] = $arrayref_two->[$a]->[$b];

}
}

it would be nice to have something to copy complex data structures that
isn't going to be a code maintenance headache-  the above is dependent
on the data structure being a "2 dimensional array" of particular size.
i don't want that restriction.

any help would be apreciated :)

thanks,
willy


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




Re: md5 function

2003-12-11 Thread Dan Anderson
On Thu, 2003-12-11 at 05:51, Randy W. Sims wrote:
> On 12/11/2003 5:41 AM, Yannick Warnier wrote:
> 
> > Hi all,
> > 
> > Is there an easy function to apply an md5 to a string? (sha1 could also
> > do)
> > I've looked at the perl base functions and didn't find it but I would
> > like to avoid the use of modules as much as I can.
> > 
> > Thanks,
> > Yannick
> > 
> > 
> Digest::MD5 & Digest::SHA1
> 
> Both of these modules are included in core perl. There are no builtins 
> as you describe, but that shouldn't be a problem since these are core 
> modules. Why avoid modules?

Caveat Coder!  Perl can be set up so that the @INC doesn't point to the
core modules.  I have seen this on shared hosting, where (I assume) the
sys admin decided to use it as a way to secure the box.

Of course, if you use something like this:

BEGIN  {
  unshift "./modules", @INC;
}

you can then store all your modules in the ./modules directory and have
them accessed.  Of course, this may or may not violate their terms if
you're selling the script.

-Dan


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




Re: recursive replace command line

2003-12-11 Thread Jeff 'japhy' Pinyan
On Dec 10, George Georgalis said:

>giving my perl a retry, I found some hints on a website to recursively
>replace text
>
>perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
>'*.txt' )

This isn't recursively replacing text; it's recursively going through a
directory tree.

>but from what I can tell, perl doesn't support the \1 for \(*\) symbols
>like sed does.  What is the work around?

Because Perl is not sed.  Perl uses (...), not \(...\) for its memory
capturing.  In Perl's regexes, all non-alphanumeric metacharacters don't
use backslashes.  That means [...] for character classes, not \[...\], and
+ for " 1 or more", not \+, and so on.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: md5 function

2003-12-11 Thread Yannick Warnier
Le jeu 11/12/2003 à 11:51, Randy W. Sims a écrit :
> On 12/11/2003 5:41 AM, Yannick Warnier wrote:

> > Is there an easy function to apply an md5 to a string? (sha1 could also
> > do)
> > I've looked at the perl base functions and didn't find it but I would
> > like to avoid the use of modules as much as I can.
> > 
> Digest::MD5 & Digest::SHA1
> 
> Both of these modules are included in core perl. There are no builtins 
> as you describe, but that shouldn't be a problem since these are core 
> modules. Why avoid modules?

Avoiding modules...
I have to install my script on several computers and would like to
minimise the installation. Using core functions ensures me that I won't
have to install more than just Perl. But since it is in the core
modules...

Thx
Yannick


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




RE: -e with single quotes

2003-12-11 Thread Thomas Bätzler
Dan Muey <[EMAIL PROTECTED]> asked:

> I'm tryign to do a perl -e '' command and am wondering if it is 
> possible to do single quotes inside the single quotes.

perl -e "print \"joe's mama\n\";"

perl -e 'print "joe".chr(39)."s mama";'

HTH,
Thomas

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




Re: dbmopen problem

2003-12-11 Thread Joel Newkirk
On Wed, 2003-12-10 at 22:11, drieux wrote:
> On Dec 10, 2003, at 5:58 PM, Joel Newkirk wrote:
> [..]
> >> whenever I reach:
> >> dbmopen (%PLRULES, "/var/szs/rules.dbm", undef) or die $!;
> >> I die, with "No such file or directory".
> [..]
> 
> are you sure about that dbmopen() line?
> 
> eg:
> 
>   perldoc -f dbmopen
> 
> seems to suggest that DBNAME shoudl be
> the 'name' without the Suffix,
>   
>   dbmopen (%PLRULES, "/var/szs/rules",0755) or die $!;
> 
> because i'm a bit concerned that your dmbopen is actually
> trying to find the file "/var/szs/rules.dbm.dbm" - depending
> upon the underlying OS it is on.

Underlying OS is Linux, specifically Mandrake 9.2, with perl V5.8.1.  I
named it that way because I was migrating from a textfile named "rules"
that originally held the regex rules.  The actual files used are
"rules.dmb.dir" and "rules.dbm.pag", created when I originally accessed
the nonexistant DBM with:
dbmopen (%PLRULES, "/var/szs/rules.dbm", 0644) or die $!;
and it opens and reads without problems from the webmin CGI, but the
precise dbmopen command that works in the webmin CGI fails in the
console-command version.

> but you might want to actually cross over and
> look at doing a 'tie' - cf
> 
>   perldoc -f tie

I thought that was what 'dbmopen' did for me, in this simplistic case of
'tie'.  This is my first week with Perl, so I've got a way to go
still...

> ciao
> drieux
> 
> ---

j

-- 
"Not all those who wander are lost."  - JRR Tolkien


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




Re: dbmopen problem

2003-12-11 Thread Joel Newkirk
On Wed, 2003-12-10 at 22:07, Owen wrote:
> On Mon, 08 Dec 2003 01:06:04 -0500
> Joel Newkirk <[EMAIL PROTECTED]> wrote:
> 
> > dbmopen (%PLRULES, "/var/szs/rules.dbm", undef) or die $!;
> > I die, with "No such file or directory".
> 
> No idea but;
> 
> I would tend to beleive the "No such file or directory" statement.
> you can do an ls -la /var/szs/rules.dbm ?

Yep, the files are there (actually rules.dbm.dir & rules.dbm.pag, as
created previously with:

dbmopen(%PLRULES "/var/szs/rules.dbm", 0644) or die $!;

I use the precise same command (IE, with the "undef") in the CGI script
with no problems.

> I would have written the "or die $!;" as or die "Can't dbmopen $!\n"; but then maybe 
> you only have one die statement to worry about?
> 
> I have never seen "dbmopen (%PLRULES, "/var/szs/rules.dbm", undef)" normally I see 
>   dbmopen (%PLRULES, "/var/szs/rules.dbm", 0666) or die.
>   %PLRULES=();

Using undef is supposed to open the file for reading only and fail if
it's not found - '0666' will create a new file if one didn't already
exist, and assign it read+write permissions for all, failing only if it
is unable to create the file(s), 

> The syntax for dbmopen is Arrayname DB_filename mode 
> so I just wonder if undef is a mode?
> 
> 
> -- 
> Owen

j

-- 
"Not all those who wander are lost."  - JRR Tolkien


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




recursive replace command line

2003-12-11 Thread George Georgalis
Hi -

giving my perl a retry, I found some hints on a website to recursively   
replace text

perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
'*.txt' )

this should replace "old-atext" with "new-btext" and "old+atext" with
"new+btext" and similar occurrences in all the files from find.

but from what I can tell, perl doesn't support the \1 for \(*\) symbols
like sed does.  What is the work around?

// George


-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




Re: Match the first 3 characters of 2 words?

2003-12-11 Thread Boris Zentner

Hi,

Am Mittwoch, 10. Dezember 2003 21:19 schrieb Rod:
> What is the easiest way to test the first 3 characters of two words for
> a match.
>
> IE:  "dasf" test "dasg" to return positive.
>
>
> rod.

# return true, if the words differ
return unpack( "%32C3", $w1 ^ $w2 );
-- 
Boris

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




setPalette doesnt work in win32

2003-12-11 Thread James Osborn
An obscure and probably (?) highly specific problem.  When I install the 
"Apache/Perl (binaries for both Perl-5.6/Apache-1.0/mod_perl-1 and 
Perl-5.8/Apache-2/mod_perl-2)" from the ports page 
(http://www.cpan.org/ports/index.html#win32), using setPalette in my pTk 
programs works fine under XP Pro, but installing the same port under W2K 
Pro causes setPalette to do nothing.  Furthermore, the default color 
scheme varies from W2K machine to W2K machine (e.g. seafoam on one and 
black on another).  This behavior is clearly demonstrated by the widgets 
demo too, not just my programs.

Anybody know what I am talking about or how to fix it?

-- James

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



Re: md5 function

2003-12-11 Thread Randy W. Sims
On 12/11/2003 5:41 AM, Yannick Warnier wrote:

Hi all,

Is there an easy function to apply an md5 to a string? (sha1 could also
do)
I've looked at the perl base functions and didn't find it but I would
like to avoid the use of modules as much as I can.
Thanks,
Yannick

Digest::MD5 & Digest::SHA1

Both of these modules are included in core perl. There are no builtins 
as you describe, but that shouldn't be a problem since these are core 
modules. Why avoid modules?

Regards,
Randy.


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



md5 function

2003-12-11 Thread Yannick Warnier
Hi all,

Is there an easy function to apply an md5 to a string? (sha1 could also
do)
I've looked at the perl base functions and didn't find it but I would
like to avoid the use of modules as much as I can.

Thanks,
Yannick


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




Re: Who called subroutine.

2003-12-11 Thread Randy W. Sims
On 12/11/2003 5:18 AM, John Hennessy wrote:
Hi, a basic question how do I know who called my subroutine ?
It could be main, it could be another subroutine.
Is setting a return value on a subroutine and checking for it the only way 
? Surely not.

Thanks

John.



perldoc -f caller

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



Who called subroutine.

2003-12-11 Thread John Hennessy
Hi, a basic question how do I know who called my subroutine ?
It could be main, it could be another subroutine.
Is setting a return value on a subroutine and checking for it the only way 
? Surely not.

Thanks

John.



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




Re: 1 doubt.

2003-12-11 Thread Yannick Warnier
Le jeu 11/12/2003 à 10:27, Ajey Kulkarni a écrit :
> perl t.pl
> Name "main::FH" used only once: possible typo at t.pl line 6.
> 
> cat t.pl
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> open FH, "out.dat";
> 
> 
> Why am i getting this warning? When i remove the warnings,this goes off?
> Is there any problem if i not include "use warnings" line?

This is just a warning saying that you are using FH only once (well,
it's written so). Indeed, why would you need to open the file if you are
not writing or reading or accessing it anyway?
Just, for example, close it using
  close FH;
unless you wanna do something special with that?

Yannick


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




Re: First module!!! YAAAAY!!! :)

2003-12-11 Thread Tassilo von Parseval
On Wed, Dec 10, 2003 at 02:26:40PM -0800 drieux wrote:

> On Dec 10, 2003, at 4:39 AM, Ben Crane wrote:
> 
> >Just sat done and put together my FIRST MODULE

> It appears that perl5.8.1 rev of h2xs has some
> minor changes:
> [jeeves: 28:] h2xs -AX Wetware::Pid
> Defaulting to backwards compatibility with perl 5.8.1
> If you intend this module to be compatible with earlier perl versions, 
> please
> specify a minimum perl version with the -b option.
> 
> Writing Wetware/Pid/Pid.pm
> Writing Wetware/Pid/Makefile.PL
> Writing Wetware/Pid/README
> Writing Wetware/Pid/t/1.t
> Writing Wetware/Pid/Changes
> Writing Wetware/Pid/MANIFEST
> [jeeves: 29:]

5.8.2's h2xs has yet some more changes. It's advisable to get hold of
this version of h2xs (it will run with older perls as well) because it
creates a directory-structure that is more in accordance with the
preferred style of CPAN modules:

[EMAIL PROTECTED]:/tmp$ h2xs5.8.2 -b 5.6.0 -AX Wetware::Pid
Writing Wetware-Pid/lib/Wetware/Pid.pm
Writing Wetware-Pid/Makefile.PL
Writing Wetware-Pid/README
Writing Wetware-Pid/t/Wetware-Pid.t
Writing Wetware-Pid/Changes
Writing Wetware-Pid/MANIFEST

Furthermore, another thing I tend to keep up-to-date is
ExtUtils::MakeMaker. With a recent EU::MM and the conventional

perl Makefile.PL
make
make dist

a decent META.yml is created and added to the distribution.

> NOW comes the 'big uglies' about the design
> philosophy issues - Unless you are Lincoln Stein,
> do not try to make your module BOTH OO-ish and Procedural,
> it can be done - but pick one or the other.

I suppose that mixing styles can be done in a clever way. However,
obscenities such as the approach of CGI.pm really should be avoided.

> I come from the 'put the POD in a Foo.pod file'
> school, others come from the 'interleave pod and code',
> while some are true believers of the 'pod at the end'.
> But think about how other persons pod has helped you,
> do the same.

I used to belong to the 'interleave pod and code' school but soon
changed that when I realized that there is no way to interleave POD into
XS files.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval


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




Re: dbmopen problem - solved

2003-12-11 Thread Joel Newkirk
On Wed, 2003-12-10 at 20:58, Joel Newkirk wrote:

> On Mon, 2003-12-08 at 01:06, Joel Newkirk wrote:

> > Now I'm working on a console command to offer the same functionality
> > (only needing to read the rules, not write) using the same dbm.  I've
> > used precisely the same subroutine as in the webmin version, but
> > whenever I reach:
> > dbmopen (%PLRULES, "/var/szs/rules.dbm", undef) or die $!;
> > I die, with "No such file or directory".

> > What am I doing wrong??

I found my problem - apparently webmin was doing "use GDBM_File;" for
me, which is why it worked in the webmin module, and since I wasn't
including either that or the webmin "web-lib.pl" it was defaulting to a
different DB format, hence the "File Not Found" error.  Once I include
"Use GDBM_File;" I can successfully read the DBM written by the webmin
module.  Doh!  Maybe my second week with Perl will be smoother... ;^)

Many thanks to all who offered advice.  Once I get the suite working as 
desired I'll be going through again and optimizing, and during that
phase I plan to change over to using a tie instead, but for now I've got
the functionality I need - remaining work is webmin UI cleanup and
adding further analysis capabilities, and auto-unblock as counterpart
to the autoblock.pl/autoblock.cgi functionality.

Our spam-harried clients thank you as well...  :^)  Now I can get the
autoblock running under cron, instead of only being available manually
from webmin.

FWIW, here's the bigger picture:

Using the ULOG target in iptables, and ulog-acctd, I log a flag (SMTP,
POP3, or FILT) a timestamp and a source IP for every connection to our
mailserver cluster.  (the standard iptables LOG target gives us far more
information than we need, and as a result takes about 5x longer to process
and 10x more disk space) Periodic analysis brings up the top (N) source IPs
with greater than (M) SMTP connections, which we process as follows:

If the IP is already blocked, do nothing.  If the IP is one of our own,
do nothing.  If the IP is the source of authenticated POP3 connections,
do nothing.  If the IP is in /var/szs/whitelist, do nothing.  Otherwise:
Perform a reverse lookup of the IP.  If the reverse record is empty, or
contains all four octets of the IP (decimal or hex) the block it with
iptables from entering the cluster at all.  Then we compare the reverse
record against /var/szs/rules.dbm's regex rules, and if we find a match
we block it.  Those rules are crafted to identify end-user IPs by 
patterns in their naming, IE '$3.$4.{1,20}rr.com' with IP octets being
subbed for $1,$2,$3,$4 before regex evaluation.

The point is this - I'm opposed on principle to using mail-abuse.org's
DUL (dial-up IP pool list) and blocking huge blocks of dynamic IPs, 
since I consider it not unreasonable that someone is (like me) running 
a mailserver at home on a dynamic IP.  However, with the hundreds of
thousands of spam messages hitting the company mailservers each day,
largely from broadband-connected end-user machines infected with
SoBig or similar spam-relay infections, we needed a way to weed them
out.  In the last 24 hours, we've received just over 2 million SMTP
connections, roughly 85% of which are incoming spam.  (logging all of
those with the native iptables LOG target is hopeless, with logfiles
topping 1gb daily, while ULOG with the custom format is about 100mb)

This set of scripts has allowed us to cut our incoming spam by about 80%
while cutting the resource usage on the servers drastically, instead of
boosting it several times by implementing extensive content filtering
on the servers themselves.  The reason for the tremendous cut in resource
requirements is that not only is this crap never reaching the servers,
they don't get bogged down repeatedly trying to send "unknown recipient"
bounces to non-existant sources.  We reached one point where we had over
100,000 bounce messages clogging the outbound message queue...  And that's
with periodic manual flushes.

All of this processing takes place on the Director node of an LVS cluster
running qmail on multiple nodes, handling email for about 50 domains.  (we
are an ISP)  Apart from this processing, the only things the Director node
deals with is routing SMTP/POP3/HTTP(S) to the most-available node, and 
presenting a caching nameserver for use by the clustered servers, so I 
have resources to spare up front, while resources on the mailserver nodes 
themselves are in much higher demand.  And the reverse lookups performed
by the autoblock scripts come at very low cost, since we are performing
them anyway on behalf of the mailserver nodes, and caching the lookups.

Again, thanks for advice and hints.

j

Joel Newkirk
perl at newkirk.us
firewalldude @ dsslink.net

-- 
"Not all those who wander are lost."  - JRR Tolkien


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