Re: Config file

2003-12-02 Thread R. Joseph Newton
Rod wrote:

> What is the best way to read a config file for a perl script.  I have
> some very ugly code that can do it, but I would like to find something
> cleaner.
>
> Thanks,
> Rod.

It depends on how the config file is set up.  Asuming that your config
file is a simple name= value per line file, it is very simple:

my $options = {};

open IN, $option_file_name or die "Could not open ini file: $!";
while (defined my $line = IN) {
   next unless $line;
   my ($key, $value) = split /\s*=\s*/, $line;
   $options->{$key} - $value;
}
close IN;

Joseph


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



RE: Reading files

2003-12-02 Thread Tom Kinzer
OK, but how about:

1)where is $LOG being set?
2)does it get past the dies shown below?
3)got strict?  it's 'fer your own good, you know! ;)

-Tom Kinzer



#!/usr/bin/perl -w

$file="./text";
$|=1;
use Fcntl;
use IO::Handle;

$D_LOG = $ENV{MHCONTEXTFD};

open($LOG, "< logfile") or die "Unable to open 1st handle, stopped";
open($D_LOG, "<& LOG")  or die "Unable to open 2nd handle, stopped";
$LOG->autoflush(1);
$D_LOG->autoflush(1);

$line1=<$LOG>;
$line2=<$D_LOG>;

print "1:$line1 2:$line2";

-Original Message-
From: Mark Goland [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 7:40 PM
To: [EMAIL PROTECTED]
Subject: Re: Reading files


Sorry for not being more clear. The problem is that it doesnt seem to be
able to read of the duped handle { $line2 is empty on }.

- Original Message - 
From: "Tom Kinzer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 4:15 PM
Subject: RE: Reading files


> I don't see $LOG being set...strict would catch that.
>
> -Tom Kinzer
>
>
>
> > Hello All,
> > I am trying to open a file once , and then duplicate it's
> > File Handle. I am trying to workout example straight from
> > FAQ5, with no luck. I will basicly trying to open a file, dup
> > off a few handles and spread them across other processes.
> > Here is the code
> >
>
> Try use strict; and use warnings;(or -w) right off and see what it tells.
> What exatcly is happening that you think shouldn't?
> I guess I didn't see a question?
>
>
> > #!/usr/bin/perl -w
> >
> > $file="./text";
> > $|=1;
> > use Fcntl;
> > use IO::Handle;
> >
> > $D_LOG = $ENV{MHCONTEXTFD};
> >
> > open($LOG, "< logfile");
> > open($D_LOG, "<& LOG");
> > $LOG->autoflush(1);
> > $D_LOG->autoflush(1);
> >
> > $line1=<$LOG>;
> > $line2=<$D_LOG>;
> >
> > print "1:$line1 2:$line2";
> >
> > Thanks in Advance,
> > Mark G.
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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


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



Re: Reading files

2003-12-02 Thread Mark Goland
Sorry for not being more clear. The problem is that it doesnt seem to be
able to read of the duped handle { $line2 is empty on }.

- Original Message - 
From: "Tom Kinzer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 4:15 PM
Subject: RE: Reading files


> I don't see $LOG being set...strict would catch that.
>
> -Tom Kinzer
>
>
>
> > Hello All,
> > I am trying to open a file once , and then duplicate it's
> > File Handle. I am trying to workout example straight from
> > FAQ5, with no luck. I will basicly trying to open a file, dup
> > off a few handles and spread them across other processes.
> > Here is the code
> >
>
> Try use strict; and use warnings;(or -w) right off and see what it tells.
> What exatcly is happening that you think shouldn't?
> I guess I didn't see a question?
>
>
> > #!/usr/bin/perl -w
> >
> > $file="./text";
> > $|=1;
> > use Fcntl;
> > use IO::Handle;
> >
> > $D_LOG = $ENV{MHCONTEXTFD};
> >
> > open($LOG, "< logfile");
> > open($D_LOG, "<& LOG");
> > $LOG->autoflush(1);
> > $D_LOG->autoflush(1);
> >
> > $line1=<$LOG>;
> > $line2=<$D_LOG>;
> >
> > print "1:$line1 2:$line2";
> >
> > Thanks in Advance,
> > Mark G.
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: Upgrade to 5.8 breaks IIS?

2003-12-02 Thread drieux
On Dec 2, 2003, at 4:26 PM, Clinton wrote:
[..]
Upgraded my version of Perl (and the relevant modules) but it brings  
IIS down when I call a PerlScript via the net. Reverted to 5.6 and no  
problems. It's not critical. But if anybody has any ideas?

ActiveState 5.8
on WinNT Server 6a
[..]

Have you contacted ActiveState?
They have a bug tracking Feature



there is a reference to an MSI Installer 2.0 or better.

You did follow the instructions and not try to install
over a 500 or 600 series build???
For the $495 a year licensing fee you might want
to check with Active State Directly to get your dollars worth.
{ which was only 305quid  back in May, but that same
305 quid is now worth $524... 8-) }
ciao
drieux
---

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


Re: Perl underreporting bytes to write?

2003-12-02 Thread drieux
On Dec 2, 2003, at 6:17 AM, Marco Gazzetta wrote:
[..]
I am using cdbkup to (what else?) backup my system on CD. It is quite 
the
reliable program, and I was very surprised to find it had a nasty bug.

In short, whenever I tried to perform a backup that didn't fit on one 
CD, the
program would create ISO images that were consistently too large for 
my CDs.
[..]

like dan I am not familiar with this app,
but I Google, and I presume you mean the
version from sourceforge:


which then leads us to the question as to what arguments
are you passing it, since you are clearlying getting
some strange mojo in the cdsplit command that will
change how it is dealing with:
sub netsize {
if ($iso) {
$size = (2047 + shift) & ~2047;
return $slack + $fixatepad + ($size > $minsize ? $size : $minsize);
} else {
$size = shift;
return $size;
}
}
ciao
drieux
---

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


Re: CGI - DBI

2003-12-02 Thread R. Joseph Newton
Jerry Rocteur wrote:

> Hi,
>
> I'm enjoying writing scripts using DBI, I'm doing it with Sybase and
> MySQL and it is a whole lot of fun.
>
> I'd like to stick some stuff on the web and I've started playing with
> CGI but I hate this, almost as much as I hate creating HTML docs ;-)
>
> Anyway, I decided not to re-invent the wheel and to search the web for
> some sample scripts, especially data entry stuff and I came across
> phpMyAdmin.. But of course I don't want to do PHP I want to do Perl, my
> ISP says, use Perl for all your scripts but if you want to do Web stuff
> just use PHP.. I don't want to do that, I saw a post from Jose and he
> talks about Mason, but my ISP doesn't have Mason.. Anyway, I've just
> tested and my ISP does have CGI and it works..
>
> I was wondering, can anyone point me to some precooked Perl CGI scripts
> that already do data entry, I can browse and search my tables already
> in CGI and DBD but I loathe to make what I've done look reasonable and
> even worse, starting to create forms etc for data edit and data entry
> would make my hair even more grey than it is now..
>
> Of course I don't mind modifying already working scripts and I
> certainly don't need anything too fancy ..
>
> Thanks in advance for any help.
>
> Jerry.
>
> P.S. if someone can ask how to do a search and replace in Perl and
> people answer, I figure I can ask this  And I'm sure many of you
> have done it, send me your scripts ;-)

Hi Jerry,

Well, I'm not going to point anyone toward precooked scripts, but... I will
gladly show you how easy it can be to get information thyrough the CGI.
Actually, it is highly unlikely that you will find a precooked script to do
the whole job for you.  Effective use of modules though can help take the
esoterica of the interface protocols out of the picture.

If you have already mastered DBI, then this should be a snap.  Every field
in your db tables has a name, right?  That means you're already ahlfway
there.  Each input in an html form also can have a name attribute.  With
fairly small effort, you should be able to grab th value entered into any
form field by its name, and pipe it right into the db field of the same
name.
Here is a quick-and-dirty working example of getting data with CGIYou
should be able to reproduce and run these on your localhost web server:

cgi_test.html:



 Enter Name 




  Name:




cgi_test.cgi

#!perl -w

use strict;
use warnings;

use CGI;

my $cgi = CGI->new;

my $name = $cgi->param('name');

print $cgi->header, "\n",
  $cgi->start_html('Return the Name'), "\n",
  $cgi->h1('Returning Your Name'), "\n";
print $cgi->p($name), "\n";
print $cgi->end_html;


If these don't run, you may need to do some configuration with your web
server.  Once you can run them, you pretty much ave the key for getting
data out of html pages.

Also, don't forget that there is an entire group devoted to supporting you
in your efforts to master CGI, [EMAIL PROTECTED]

Joseph



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



Re: using perl in a c code

2003-12-02 Thread drieux
On Dec 2, 2003, at 3:40 PM, Dan Muey wrote:
[..]
What Id' really like to be able to do is compile
it as simplepage.cgi and see if I can get it to do me a little page:
http://www.whatever.com/simplepage.cgi
Or
http://www.whatever.com/simplepage.cgi?name=waldo
This is a very cool idea, I'd love to be able to make it work!

Am I way off or any ideas??
Well I'm still not seeing what sort of 'gain'
you would get with the 'c code' stuff when you
already have two really good Perl based routes
to take
	a. classical perl cgi code the old fashion way

	b. mod_perl for those who are more hip

Or do you think that only 'c code' can work as cgi

I have some rantings and Ravings on a web-tool that
I built up at:


If you have not taken the time to download the source
for 'cupsd' you might want to peek at it for one of
the better open sourced 'all singing, all dancing'
all 'c coded' CGI interfaced print manager. It was one
of several projects I rummaged through when looking at
which way I wanted to go with doing a 'web tool' - and
well, opted for Perl. Given that one of the targetted
OS Platforms HAS a mechanism for building perl5.8.1 for
it, but no JVM to run java, the options became, well,
sobering as to what could be done... Given the
JackBootedFascistThuggery of the Most Blessed and Divine,
all loving, all caring, all wise and all knowing,
Project Manager and Chief Architect, the option of
going with mod_perl was SHOT in the head for operational
reasons that Are Most Blessed And Hollowed
{ for those of you who have never had the fun of coding
for a technical manager who HAS technical insights
may you find the time to enjoy that luxury... }
You might also want to check out the web-min project
 for some serious over the top
way tooo wicked cool perl based administration tools
that are done with perl and cgi.
So unless you REALLY are merely thrashing about for some
reason to Leap off the Deep End into embedding perl in c...
Please! Feel Free! empack what ever code into what ever
other code makes the abcyss fonder...
Now as for the code fragment:

my $perlcode = <
printf eval_pv($perldoc);
what happens when the simple.cgi is called without arguments?
eg: if there is no 'name' in the parameter list???
More importantly, how are you planning to differenciate
between say a 'POST' request, a 'HEAD' request, and a 'GET' request.


ciao
drieux
---

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


RE: Perl underreporting bytes to write?

2003-12-02 Thread Dan Muey
> Greetings!
> 
> I am using cdbkup to (what else?) backup my system on CD. It 

I'm not familiar with cdbkup. Is it doen in Perl?
Perhaps a link to info about it would be helpful.

> is quite the 
> reliable program, and I was very surprised to find it had a nasty bug.
> 
> In short, whenever I tried to perform a backup that didn't 
> fit on one CD, the 
> program would create ISO images that were consistently too 
> large for my CDs.
> 
> I dug around and found the problem, but have no clue as to 
> the cause. In the 
> section that gathers the data to be backed up, the program 
> invokes gtar as 
> such:
> 
> open (INPUT, "(cd / && /bin/gtar -f - -cSlz 
> --listed-incremental=/tmp/cdbkup-root --label=root-2003-11-30-0 
> --exclude=./home/backup --exclude=./root/root-2003-11-30-0.tar.gz 
> --exclude=./tmp/cdbkup-root .)|");
> 

It actually has the date two days ago hardcoded in it? That seems odd, 
is somethgin else going on there?
And what id my gtar is in /usr/bin or soemthing? Sum ting wong.

> Later, the application reads from the pipe as such:
> 
> $imgsize = 0;
> open( TMPIMG, ">$tmpimg") || die "Can't open '$tmpimg': $!\n";
> while( $rc = read( INPUT, $data, $increment)) {
> $imgsize += $rc;
> print TMPIMG $data || die "Can't write data 
> to tmp file: 
> $!\n";
> last if( netsize($imgsize + $increment) > $maxsize);
> }
> 
> Now, the $imgsize variable is consistently smaller than the 
> real file size as 
> reported by ls.
> 
> I checked as many FAQs as I could, and found a reference to 
> 'use bytes' vs 'no 
> bytes'. I tried both, and it made no difference.

Seems like an apples to oranges comparison that can happen 
when comparing bit, bytes and sixe values form different program 
and functions.

What is netszie();

I guess more info would be helpful, perhaos a link to/about this script?

Thanks

Dmuey

> 
> I am sure this is something trivial, but really need help.
> 
> Thanks
> Marco

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



Upgrade to 5.8 breaks IIS?

2003-12-02 Thread Clinton
 Hi
Upgraded my version of Perl (and the relevant modules) but it brings IIS down when I 
call a PerlScript via the net. Reverted to 5.6 and no problems. It's not critical. But 
if anybody has any ideas?

ActiveState 5.8
on WinNT Server 6a

Application Log Reports:
An object call caused an exception.   (IID: 
{51372AEF-CAE7-11CF-BE81-00AA00A2FA25}) (Method: 3)  (Microsoft Transaction Server 
Internals Information: File: i:\viper\src\runtime\mtxex\activity.cpp, Line: 889) 
(Exception: C005) (Address: 0x090321a1) OLE!CreatePerlObject + 0x45
PerlSE + 0x54B3
PerlSE + 0x733B
PerlSE + 0x518F
PerlSE + 0x24F4

My PerlScript uses:
use DBI;
use Data::Dumper;
use Win32::ASP;
use Mail::Sender;
use LWP::UserAgent;

Regards
Clinton


Perl underreporting bytes to write?

2003-12-02 Thread Marco Gazzetta
Greetings!

I am using cdbkup to (what else?) backup my system on CD. It is quite the 
reliable program, and I was very surprised to find it had a nasty bug.

In short, whenever I tried to perform a backup that didn't fit on one CD, the 
program would create ISO images that were consistently too large for my CDs.

I dug around and found the problem, but have no clue as to the cause. In the 
section that gathers the data to be backed up, the program invokes gtar as 
such:

open (INPUT, "(cd / && /bin/gtar -f - -cSlz 
--listed-incremental=/tmp/cdbkup-root --label=root-2003-11-30-0 
--exclude=./home/backup --exclude=./root/root-2003-11-30-0.tar.gz 
--exclude=./tmp/cdbkup-root .)|");

Later, the application reads from the pipe as such:

$imgsize = 0;
open( TMPIMG, ">$tmpimg") || die "Can't open '$tmpimg': $!\n";
while( $rc = read( INPUT, $data, $increment)) {
$imgsize += $rc;
print TMPIMG $data || die "Can't write data to tmp file: 
$!\n";
last if( netsize($imgsize + $increment) > $maxsize);
}

Now, the $imgsize variable is consistently smaller than the real file size as 
reported by ls.

I checked as many FAQs as I could, and found a reference to 'use bytes' vs 'no 
bytes'. I tried both, and it made no difference.

I am sure this is something trivial, but really need help.

Thanks
Marco



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



RE: using perl in a c code

2003-12-02 Thread Dan Muey
> On Dec 1, 2003, at 6:22 AM, Ramprasad A Padmanabhan wrote:
> [..]
> > Instead Can I just embed this perl code  in my c program
> > I will be happy if someone can give some links to examples 
> on the net
> 
> 


That is very very sexxy! I was reading the part at:
http://www.perldoc.com/perl5.6/pod/perlembed.html#Adding-a-Perl-interpreter-to-your-C-program

Which will let you run perl code/file containing perl code supplied as an argument.
Very cool.

What I was wondering about was how to execute some perl code *inside* the c program 
instead of takign it via ARGV.
I  think eval_pv and eval_sv have somethgin to do with it but I'm a bit cloudy there.
Since I don't know hardly anythgin about C I'll illustarte it in Perl.

my $perlcode = 

Re: network programming?

2003-12-02 Thread Wiggins d Anconia


> 
> 
> Hello... 
>   I'm starting to encounter a number of pretty sophisticated network
> thingies of all descriptions, and I'd be interested in anyone's experience
> writing network sniffers, drivers, test harnesses, or other frobnabulators
> in Perl. 
>   In particular, I just discovered IO::Socket::Multicast on CPAN which
> looks very interesting, along with the rest of the IO::Socket family. 
>   I've got a little experience with TCP/IP servers in Perl, and I've
> been surfing ntop output on the corporate network for the last couple of
> months, so I'm not a complete newbie (but close).  
>   I'd be interested in any descriptions, stories, warnings, links, or
> snippets about Useful Perl Network Stuff.  If it's too OT, feel free to
> email me off the list.  
>   Thanks... 
> -Chris

This is where I interject http://poe.perl.org and then hop on my ski's
to hit the learning curve slope that it provides But boy swishing
down those slopes can be fun!

http://danconia.org


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



Re: network programming?

2003-12-02 Thread James Edward Gray II
On Dec 2, 2003, at 3:22 PM, McMahon, Chris wrote:

Hello...
Howdy.

[snip background]

I'd be interested in any descriptions, stories, warnings, links, or
snippets about Useful Perl Network Stuff.  If it's too OT, feel free to
email me off the list.
Network Programming with Perl is the book I learned it all from.  I 
think it's terrific.

James

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


Re: network programming?

2003-12-02 Thread drieux
On Dec 2, 2003, at 1:22 PM, McMahon, Chris wrote:
[..]
	In particular, I just discovered IO::Socket::Multicast on CPAN which
looks very interesting, along with the rest of the IO::Socket family.
	I've got a little experience with TCP/IP servers in Perl, and I've
been surfing ntop output on the corporate network for the last couple 
of
months, so I'm not a complete newbie (but close).
[..]

First off
RUN AWAY! JUST SAY NO! DO NOT DO THIS!
right, so much for the obligatory warning.
{ this way I can later on say, "i tried to warn you."}
ok, first off, you will want to get the
two volumes of Steven's Network Programming
( 2nd editions, vol 1 & 2 )
cf

as a basic starter since it is just worth it in
the long run to have them for later on as you
start having to get 'more technical'.
Accept the fact that there are some known bugs
in his demonstration code, but that too is
survivable, since you want to read it for ideas
and implement your own code. Much of which can
be as badly written in Perl as in 'c', caveat emptor.
Then you can wander into the ugly world either
directly, and code up your own madness, or decide
to have that sobriety moment, and opt to find
ways to use Perl to parse the output of things
like ntop and send you warnings, alerts, heads ups,
etc, etc, etc.
Or do you want to get into the frobnobulation of
writing client/server applications based upon your
own network protocol? If so, I started today's
rant about learning to do one's own header/payload
approach to doing client/server wacka-doo-dell-age:


Is this my Bad Kharma coming back to me or What?

Oh yes, there is that minor set of issues with
Multi-Cast that you may want to worry about now,
namely the delta between ucp v. tcp - but I'm
sure you will want to think more about that after
you have decided if 'sane and sober' is a lifestyle
choice you want to make
8-)

HTH.

ciao
drieux
---

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


network programming?

2003-12-02 Thread McMahon, Chris


Hello... 
I'm starting to encounter a number of pretty sophisticated network
thingies of all descriptions, and I'd be interested in anyone's experience
writing network sniffers, drivers, test harnesses, or other frobnabulators
in Perl. 
In particular, I just discovered IO::Socket::Multicast on CPAN which
looks very interesting, along with the rest of the IO::Socket family. 
I've got a little experience with TCP/IP servers in Perl, and I've
been surfing ntop output on the corporate network for the last couple of
months, so I'm not a complete newbie (but close).  
I'd be interested in any descriptions, stories, warnings, links, or
snippets about Useful Perl Network Stuff.  If it's too OT, feel free to
email me off the list.  
Thanks... 
-Chris


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



Re: search and replace using regex

2003-12-02 Thread drieux
On Dec 3, 2003, at 12:25 PM, Saskia van der Elst wrote:

I have trouble executing a search and replace through all files in a 
certain
directory.

I want to replace " _

Can I match a white-space?

I have tried the following regex:

s/ _\[..]

I agree with Tom that you get better
mileage by putting your delimiters to
something OTHER than a token in the
pattern that you are matching.
but there is also the little detail
of putting that "\" in the right place.
	$_ =~ s/"_\

should ahve been

	$_ =~ s/_<\/pat/<\/pat/gi; #g for every occurrence, i for

target what you WANT to target and no more.

remember that those double quotes will allow things
to be 'interpolated' - which is not what you want.
but also if you had adopted Tom's strategy that line
would be a bit more readable as:
	$_ =~ s|_

If you wanted to merely remove the "_" that preceded
an angle that closed you could tighten that down with
	$_ =~ s|_

you did I think mention perldoc perlre, yes?

you might also want to check out

perldoc perlrequick
perldoc perlretut
but some of it is merely 'art' and not science...

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


RE: Reading files

2003-12-02 Thread Tom Kinzer
I don't see $LOG being set...strict would catch that.

-Tom Kinzer



> Hello All,
> I am trying to open a file once , and then duplicate it's 
> File Handle. I am trying to workout example straight from 
> FAQ5, with no luck. I will basicly trying to open a file, dup 
> off a few handles and spread them across other processes. 
> Here is the code
> 

Try use strict; and use warnings;(or -w) right off and see what it tells.
What exatcly is happening that you think shouldn't?
I guess I didn't see a question?


> #!/usr/bin/perl -w
> 
> $file="./text";
> $|=1;
> use Fcntl;
> use IO::Handle;
> 
> $D_LOG = $ENV{MHCONTEXTFD};
> 
> open($LOG, "< logfile");
> open($D_LOG, "<& LOG");
> $LOG->autoflush(1);
> $D_LOG->autoflush(1);
> 
> $line1=<$LOG>;
> $line2=<$D_LOG>;
> 
> print "1:$line1 2:$line2";
> 
> Thanks in Advance,
> Mark G.


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



RE: Reading files

2003-12-02 Thread Dan Muey
> Hello All,
> I am trying to open a file once , and then duplicate it's 
> File Handle. I am trying to workout example straight from 
> FAQ5, with no luck. I will basicly trying to open a file, dup 
> off a few handles and spread them across other processes. 
> Here is the code
> 

Try use strict; and use warnings;(or -w) right off and see what it tells.
What exatcly is happening that you think shouldn't?
I guess I didn't see a question?


> #!/usr/bin/perl -w
> 
> $file="./text";
> $|=1;
> use Fcntl;
> use IO::Handle;
> 
> $D_LOG = $ENV{MHCONTEXTFD};
> 
> open($LOG, "< logfile");
> open($D_LOG, "<& LOG");
> $LOG->autoflush(1);
> $D_LOG->autoflush(1);
> 
> $line1=<$LOG>;
> $line2=<$D_LOG>;
> 
> print "1:$line1 2:$line2";
> 
> Thanks in Advance,
> Mark G.

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



RE: Reading files

2003-12-02 Thread Tom Kinzer
start off by putting some "or die"s on those file opens.

where are you breaking or what is the error message?

not sure what the problem is exactly.

-Tom Kinzer


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 9:53 AM
To: [EMAIL PROTECTED]
Subject: Reading files


Hello All,
I am trying to open a file once , and then duplicate it's File Handle. I am
trying to workout example straight from FAQ5, with no luck. I will basicly
trying to open a file, dup off a few handles and spread them across other
processes. Here is the code

#!/usr/bin/perl -w

$file="./text";
$|=1;
use Fcntl;
use IO::Handle;

$D_LOG = $ENV{MHCONTEXTFD};

open($LOG, "< logfile");
open($D_LOG, "<& LOG");
$LOG->autoflush(1);
$D_LOG->autoflush(1);

$line1=<$LOG>;
$line2=<$D_LOG>;

print "1:$line1 2:$line2";

Thanks in Advance,
Mark G.


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


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



Reading files

2003-12-02 Thread mgoland
Hello All,
I am trying to open a file once , and then duplicate it's File Handle. I am trying to 
workout example straight from FAQ5, with no luck. I will basicly trying to open a 
file, dup off a few handles and spread them across other processes. Here is the code

#!/usr/bin/perl -w

$file="./text";
$|=1;
use Fcntl;
use IO::Handle;

$D_LOG = $ENV{MHCONTEXTFD};

open($LOG, "< logfile");
open($D_LOG, "<& LOG");
$LOG->autoflush(1);
$D_LOG->autoflush(1);

$line1=<$LOG>;
$line2=<$D_LOG>;

print "1:$line1 2:$line2";

Thanks in Advance,
Mark G.


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



RE: search and replace using regex

2003-12-02 Thread Tom Kinzer
You may want to start looking at some XML parsing modules, but assuming this
is a quickie, I can point out that your problem is starting with the use of
forward slash.

Remember: your forward slash is your separator for the regular exp.

Try replacing it with something else like | or % and go from there - You can
do it!

Like this:
s| _\mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: search and replace using regex


I have trouble executing a search and replace through all files in a certain
directory.

I want to replace " _A_Z.new") || die "Couldn't open file.new
for writing!\n";
while(){
$_ =~ s/"_\
}

The docs don't answer all my questions. Any help will be highly appreciated.
I wish there was an absolute-beginners list...

Saskia

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


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



search and replace using regex

2003-12-02 Thread Saskia van der Elst
I have trouble executing a search and replace through all files in a certain 
directory.

I want to replace " _A_Z.new") || die "Couldn't open file.new
for writing!\n";
while(){
$_ =~ s/"_\
}

The docs don't answer all my questions. Any help will be highly appreciated.
I wish there was an absolute-beginners list...

Saskia

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



Re: perl -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

2003-12-02 Thread John W. Krahn
Jerry Rocteur wrote:
> 
> Hi,

Hello,

> I'm trying to use perl for most shell stuff and this is some of the
> stuff I'm using for grep ..
> 
> perl -ne 'print "$ARGV: $_" if /jerry/i ' *
> perl -ne 'print  if /jer{1,}y/i ' *
> perl -ne 'print  unless /jer{1,}y/i ' *
> 
> I'm enjoying this as I can do a lot more than I can with the old egrep
> on our Solaris boxes..
> 
> What I'd like to do is to make a simple change NOT to check in binary
> files and directories..
> 
> I've toyed with all sorts of variations and started like this.
> 
> perl -ne '-f &&print  if /satreq/ ' * # Don't laugh this is one of very
> many attempts ;-((
> 
> Then I tried this:
> 
> perl  -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *
> 
> Which seems to do the trick but this is just excluding directories I
> think..
> 
> But this gives me the same:
> 
> perl  -ne 'if(/.it/) {print "$ARGV: $_" unless -f}' *
> 
> How do I improve it to ONLY look in text files ?
> 
> I don't want to use the grep.pl's around or the grep from power tools,
> I want to impress the ladies by typing these on the CLI ;-)) Seriously,
> I love one liners..

Something like this might work (untested):

perl -ne' close ARGV unless -f ARGV && -T _; print if /jer+y/i ' *



John
-- 
use Perl;
program
fulfillment

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



Re: perl -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

2003-12-02 Thread david
Jerry Rocteur wrote:

> Hi,
> 
> I'm trying to use perl for most shell stuff and this is some of the
> stuff I'm using for grep ..
> 
> perl -ne 'print "$ARGV: $_" if /jerry/i ' *
> perl -ne 'print  if /jer{1,}y/i ' *
> perl -ne 'print  unless /jer{1,}y/i ' *
> 
> I'm enjoying this as I can do a lot more than I can with the old egrep
> on our Solaris boxes..
> 
> What I'd like to do is to make a simple change NOT to check in binary
> files and directories..
> 

have you try:

[panda]# perl -ne 'print unless -B $ARGV' *

which is not very efficient because of the stat on every line. a more 
efficient approach is to isolate the binary files first and then print the 
rest like:

[panda]# perl -pe1 `perl -le '-B or print for @ARGV' *`
[panda]# perl -e '-B or open(F,$_) && print for @ARGV' *

which is bit longer but much faster.

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: breaking lines with perl

2003-12-02 Thread Tom Kinzer
QA checks out, it does work with the data supplied.  (Naivete will have to
checked with the real data.)

You could add some nice indent formatting if you like by adding a tab to
Jame's expression:

s/\),\s*/),\n\t/



-Tom Kinzer



-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 8:52 AM
To: David T-G
Cc: '[EMAIL PROTECTED]' List
Subject: Re: breaking lines with perl


On Dec 2, 2003, at 10:44 AM, David T-G wrote:

> Hi, all --
>
> I have some database sql dumps that look like
>
>   insert into table (f1,f2,f3) values (v1a,v2a,v3a),(v1b,v2b,v3b),...
>
> where of course the insert lines are whopping long.  I would like to
> break these lines at the commas like
>
>   insert into table (f1,f2,f3) values (v1a,v2a,v3a),
>   (v1b,v2b,v3b),
>   ...
>
> (and in fact split after 'values ' but that will just be an exercise on
> the first solution) but can't figure out how to spit out the newline.
> This *should* be a quick oneliner like
>
>   cat file | perl -ew ' ... ' > file.mod
>
> but I just can't get it :-)

Try:

perl -pe 's/\),\s*/),\n/' old_file.txt > file.mod

It's pretty naive, but I may get lucky.  ;)

James


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


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



Re: Config file

2003-12-02 Thread Wiggins d Anconia


> 
> On Dec 2, 2003, at 7:55 AM, Rod wrote:

> 
> Do you need to have complex configuration stuff,
> if so why not lookt at the LibXml approach...
> 

Particularly I suggest XML::Simple it allows you to both create your
config file and read in your config file using standard Perl data
constructs and is reasonably quick for smaller purposes.  I have also
had luck with AppConfig since it hasn't been mentioned yet, at least I
don't think. I have found XML the best bet for arbitrarily deep nested
config files though...

Whatever you decide, use a module!

http://danconia.org


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



perl -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

2003-12-02 Thread Jerry Rocteur
Hi,

I'm trying to use perl for most shell stuff and this is some of the 
stuff I'm using for grep ..

perl -ne 'print "$ARGV: $_" if /jerry/i ' *
perl -ne 'print  if /jer{1,}y/i ' *
perl -ne 'print  unless /jer{1,}y/i ' *
I'm enjoying this as I can do a lot more than I can with the old egrep 
on our Solaris boxes..

What I'd like to do is to make a simple change NOT to check in binary 
files and directories..

I've toyed with all sorts of variations and started like this.

perl -ne '-f &&print  if /satreq/ ' * # Don't laugh this is one of very 
many attempts ;-((

Then I tried this:

perl  -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

Which seems to do the trick but this is just excluding directories I 
think..

But this gives me the same:

perl  -ne 'if(/.it/) {print "$ARGV: $_" unless -f}' *

How do I improve it to ONLY look in text files ?

I don't want to use the grep.pl's around or the grep from power tools, 
I want to impress the ladies by typing these on the CLI ;-)) Seriously, 
I love one liners..

Thanks in advance,

Jerry 

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


Re: New Folder Creation

2003-12-02 Thread Rob Dixon
Bob Showalter wrote:
>
> Browning, James wrote:
> > Can someone point me in the right direction to find a simple script
> > that will automate the creation of folders as needed?
>
> See also the standard File::Path module.

Of course you're probably right Bob. 'As needed' is likely
to mean the creation of an entire tree of directories. A lot
of Unix mkdir calls will do this anyway (but can this be
accessed through Perl, anybody?). But on VMS, Mac and Windows
File::Path::mkpath' does the job excellently.

This thread is the horse I'm backing :)

Rob



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



Re: New Folder Creation

2003-12-02 Thread drieux
On Dec 2, 2003, at 8:46 AM, Browning, James wrote:

Can someone point me in the right direction to find a simple script 
that
will automate the creation of folders as needed?
how exactly are you defining

	'as needed'???

I have a cron job that I use to traverse where
my blog has plonked stuff, and do sym-links to
the blog_archive so that they can be found by
web-bots: cf


I run it from cron.

ciao
drieux
---

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


Law of Kharma - was Re: using perl in a c code

2003-12-02 Thread drieux
On Dec 2, 2003, at 6:58 AM, Andrew Gaffney wrote:

Ramprasad A Padmanabhan wrote:
I choose to write code in perl , unless I am forced to write it in C ,
either because  my system just hangs if I use perl ( like some 
threaded
applications ) or because my BOSS wants so ;-)
That's why its nice to have a not-too-techie boss.
I just throw all sorts of jargon at him until
his head is about to explode, and then he just
tells me to do whatever I want.
I hate to remind folks of fleet maxims:

	What goes around, comes around.

Nothing was more fun than watching my former
unterStumpenFumbler find himself being the guy
who had to explain that while the new c99 code
was all hot, slick and groovey, until the underlying
vendor supplied vendor supported code up-rev'd from
c89, it would be more work to try to hack and slash
the project so that it all built in c99, rather than
code their extensions in c89...
or as cj had said nearly a decade before

"i use to worry about management reading my
postings to talk.bizarre, till I started to
worry about my subordinates"
So folks might want to actually read Ferlinghetti's
"Karma Repair Kit" and work on that 'plan b' - since
it is possible you may live fast, and forget to die young.
Your mileage may vary, void where

ciao
drieux
---

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


RE: Script Exit Status

2003-12-02 Thread Tim Johnson

Perldoc -f exit 



-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 02, 2003 9:32 AM
To: [EMAIL PROTECTED]
Subject: Script Exit Status

Is there a way to have a perl script exit with a status code?


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



RE: Script Exit Status

2003-12-02 Thread Kipp, James
> 
> 
> Is there a way to have a perl script exit with a status code?
> 
> For instance I have ascript that calls another script via
> system("somescript"); 
> 
> I want to then be able to get the exit status of that script.
> 
> Paul

Have you seen the perldoc for system ?


The return value is the exit status of the program as returned
by the "wait" call. To get the actual exit value divide by 256.
See also the exec entry elsewhere in this document. This is
*not* what you want to use to capture the output from a command,
for that you should use merely backticks or "qx//", as described
in the section on "`STRING`" in the perlop manpage. Return value
of -1 indicates a failure to start the program (inspect $! for
the reason).

Like "exec", "system" allows you to lie to a program about its
name if you use the "system PROGRAM LIST" syntax. Again, see the
exec entry elsewhere in this document.

Because "system" and backticks block "SIGINT" and "SIGQUIT",
killing the program they're running doesn't actually interrupt
your program.

@args = ("command", "arg1", "arg2");
system(@args) == 0
 or die "system @args failed: $?"

You can check all the failure possibilities by inspecting "$?"
like this:

$exit_value  = $? >> 8;
$signal_num  = $? & 127;
$dumped_core = $? & 128;

When the arguments get executed via the system shell, results
and return codes will be subject to its quirks and capabilities.
See the section on "`STRING`" in the perlop manpage and the exec
entry elsewhere in this document for details. 


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



Re: Config file

2003-12-02 Thread drieux
On Dec 2, 2003, at 7:55 AM, Rod wrote:

What is the best way to read a config file for a perl script.
I have some very ugly code that can do it, but I would like
to find something cleaner.
I like the Config::General module someone has recommended,
amongst the trade offs that one will have to resolve is how
much Stuff do you need, and how to access that stuff, and
how much 'generic parsing' as opposed to tailered parsing.
remember that 'art is in the eye of the beholder'.

My favorite way is in an OO'ish form where I start with
something on the order of
	my $web_config = new Dtk::...::ToolConf;

Then actually read them with

#
#
sub set_values
{
my ($me) = @_;

my $error = $me->webadmin_conf_file_name() unless $me->{file};
return $error if (ref($error) eq 'HASH');

open(FD, $me->{file}) or return({runtime_error =>
"unable to open config file $me->{file} : $!\n"});
while()
{
chomp;
s/#.*//;# strip comments
next if /^\s*$/;
if (/=/ ) {
s/\s+=/=/; # clean spaces before =
s/=\s+/=/; # clean spaces after =
s/\s+$//;  # clean trailing spaces
s/^\s+//;  # clean leading spaces
my ($k, $v) = split(/=/);
$me->{$k} = $v;
}   
}
close(FD);
$me->{values_set} = 1;

0;
} # end of set_values
And of course have a list of named accessors:

#
# The Accessors
#
sub config_sufix { $_[0]->{config_sufix} }
sub config_dir   { $_[0]->{config_dir} }
sub bin_dir  { $_[0]->{bin_dir} }
sub webmin_root  { $_[0]->{web_admin_root} }
sub webmin_port  { $_[0]->{web_admin_port} }
sub db_url   { $_[0]->{db_url} }
and some other junk that has to do with sanity checking,
and displaying them so that the config file can be
edited and updated, and yada-yada-yada.
{ yes, could have used AutoLoader - tried that,
it didn't take me where I wanted to go }
A part of the question you really want to ask
is how complex a config file do you want to begin
with, and can you live with the issues that come
from using a hash where the 'key/value' pairs are
accessed directly by the calling code.
Do you need to have complex configuration stuff,
if so why not lookt at the LibXml approach...
ciao
drieux
---

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


Script Exit Status

2003-12-02 Thread Paul Kraus
Is there a way to have a perl script exit with a status code?

For instance I have ascript that calls another script via
system("somescript");   

I want to then be able to get the exit status of that script.

Paul


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



Re: breaking lines with perl

2003-12-02 Thread David T-G
James, et al --

...and then James Edward Gray II said...
% 
% On Dec 2, 2003, at 10:44 AM, David T-G wrote:
% 
% >  insert into table (f1,f2,f3) values (v1a,v2a,v3a),(v1b,v2b,v3b),...
...
% >break these lines at the commas like
% >
% >  insert into table (f1,f2,f3) values (v1a,v2a,v3a),
% >  (v1b,v2b,v3b),
% >  ...
...
% >but I just can't get it :-)
% 
% Try:
% 
% perl -pe 's/\),\s*/),\n/' old_file.txt > file.mod

Perfect!  I had forgotten about -p and so was busy spending all of my
time with the spaceship operator and $_.


% 
% It's pretty naive, but I may get lucky.  ;)

Not at all; I should have been able to figure it out myself :-)


% 
% James


Thanks again & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


RE: New Folder Creation

2003-12-02 Thread Bob Showalter
Browning, James wrote:
> Can someone point me in the right direction to find a simple script
> that will automate the creation of folders as needed?

See also the standard File::Path module.

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



Re: New Folder Creation

2003-12-02 Thread Rob Dixon
James Browning wrote:
>
> Can someone point me in the right direction to find a simple script that
> will automate the creation of folders as needed?
>
> I've looked but can't find what I need.

Hi James.

Well, it depends on what you mean by 'as needed'. The 'mkdir'
built-in will create a directory for you.

  perldoc -f mkdir

Beyond that I can't help without more details.

Cheers,

Rob



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



Re: breaking lines with perl

2003-12-02 Thread James Edward Gray II
On Dec 2, 2003, at 10:44 AM, David T-G wrote:

Hi, all --

I have some database sql dumps that look like

  insert into table (f1,f2,f3) values (v1a,v2a,v3a),(v1b,v2b,v3b),...

where of course the insert lines are whopping long.  I would like to
break these lines at the commas like
  insert into table (f1,f2,f3) values (v1a,v2a,v3a),
  (v1b,v2b,v3b),
  ...
(and in fact split after 'values ' but that will just be an exercise on
the first solution) but can't figure out how to spit out the newline.
This *should* be a quick oneliner like
  cat file | perl -ew ' ... ' > file.mod

but I just can't get it :-)
Try:

perl -pe 's/\),\s*/),\n/' old_file.txt > file.mod

It's pretty naive, but I may get lucky.  ;)

James

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


New Folder Creation

2003-12-02 Thread Browning, James
Can someone point me in the right direction to find a simple script that
will automate the creation of folders as needed?

I've looked but can't find what I need.

Pardon my ignorance,
James


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



breaking lines with perl

2003-12-02 Thread David T-G
Hi, all --

I have some database sql dumps that look like

  insert into table (f1,f2,f3) values (v1a,v2a,v3a),(v1b,v2b,v3b),...

where of course the insert lines are whopping long.  I would like to
break these lines at the commas like

  insert into table (f1,f2,f3) values (v1a,v2a,v3a),
  (v1b,v2b,v3b),
  ...

(and in fact split after 'values ' but that will just be an exercise on
the first solution) but can't figure out how to spit out the newline.
This *should* be a quick oneliner like

  cat file | perl -ew ' ... ' > file.mod

but I just can't get it :-)


TIA & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


RE: Config file

2003-12-02 Thread Dan Muey
> What is the best way to read a config file for a perl script.  I have 
> some very ugly code that can do it, but I would like to find 
> something 
> cleaner.

That depends very very much on the format of the config file.
You could use open() to read the file and parse it's contents 
into some kind of useable data structure (variables, array, hash,...) 

One of my favorite ways though is to put the goods I use in lots and 
lots of places into a module and import the goods I need:


use lib '/home/me/myperlmodules';
use MySuperProgramConfig; # has all the stuff I want in @EXPORT

Sorry I couldn't be more specific, I have no idea what your config 
file is like or what kind of info you're trying to get into the program
:)

Dmuey

> 
> Thanks,
> Rod.

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



RE: Mechanize 500 connect failed

2003-12-02 Thread Paul Kraus
This is really annoying I get the same issue when I run the script from
a Linux server as I do an a windows xp workstation.



> -Original Message-
> From: Paul Kraus [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 02, 2003 8:31 AM
> To: [EMAIL PROTECTED]
> Subject: Mechanize 500 connect failed
> 
> 
> We discussed this some in an earlier thread but I have yet to 
> resolve the issue. About 15% of them I run my script it will 
> fail with this error.
> 
> 500 Connect failed: Unknown error, Unknown Error at line ...
> 
> The script is sound as it runs fine the rest of the time.
> 
> I thought maybe its because the site is unstable but I get 
> the same issue with another script that does a similar thing 
> to another website.
> 
> I have wrapped my connect calls in while loops as a temporary 
> fix. However I plan to have this script run as a cron job and 
> the thought have it hanging has occurred. I could set it to 
> try only so many times but this is still just a work around 
> rather then a fix.
> 
> Here is one page call that goes to the login page.
> 
> TIA
> Paul 
> 
> sub login{
>   my ( $login, $password, $url ) = ( 'XX', 
> 'XXX','https://www.merchantconnect.com/merchant_tools/inde
> x.asp' );
>   my $statementurl = 
> 'https://www.merchantconnect.com/merchant_tools/statement_fund
ing/printr
ecent.asp?p1=undefined';

  # Continue to try and connect untill a connection is established.
  my $flag = 0;
  while ( $flag == 0 ){
$merchant -> get ( $url ); 
warn "Can't even get the login page: ", $merchant -> response ->
status_line unless $merchant -> success;
$flag = 1 if ($merchant -> success );
  }
  $merchant -> field( 'uid', $login );
  $merchant -> field( 'pwd', $password );
  $merchant -> submit();
  die "Can't submit login form: ", $merchant -> response -> status_line
unless $merchant -> success;

  $merchant -> get ( $statementurl );
  die "Can't even get the statement page: ", $merchant -> response ->
status_line unless $merchant -> success; }


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


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



Re: fixed width variable

2003-12-02 Thread Rob Dixon
Jeff Tillotson wrote:
>
> I have been searching for a way to do this and have not had any luck.
>
> I am using localtime() to determine the day of the month.  I need to
> make sure the variable it returns will always be 2 digits and padded
> with zeros.  For example currently it is like:
> $var = (localtime)[3];
> $var would be 5.
>
> I would like $var to be 05 in that case.  However if it were 13 then
> $var would be 13.
>

Just for the sake of being different,

  my $var = substr ((localtime)[3] + 100, 1)

Rob




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



RE: Config file

2003-12-02 Thread Bakken, Luke
> What is the best way to read a config file for a perl script.  I have 
> some very ugly code that can do it, but I would like to find 
> something 
> cleaner.

I've used Config::General for several production projects and it works
quite well.

Luke

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



RE: Config file

2003-12-02 Thread Tom Kinzer
I've used Config::IniFiles before and it works very nice, especially nice if
you do a tie into a hash for all your values.

http://search.cpan.org/~wadg/Config-IniFiles-2.38/IniFiles.pm

-Tom Kinzer




-Original Message-
From: Rod [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 7:55 AM
To: beginners
Subject: Config file


What is the best way to read a config file for a perl script.  I have
some very ugly code that can do it, but I would like to find something
cleaner.

Thanks,
Rod.



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


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



RE: Config file

2003-12-02 Thread Darbesio Eugenio

>>-Original Message-
>>From: Rod [mailto:[EMAIL PROTECTED]
>>Sent: martedì 2 dicembre 2003 16.55
>>To: beginners
>>Subject: Config file
>>
>>
>>What is the best way to read a config file for a perl script.  I have 
>>some very ugly code that can do it, but I would like to find something 
>>cleaner.
>>
>>Thanks,
>>Rod.
>>

## configuration file example 
debug = 1
mailerFlag = 1 
mailServer = "mailhost.drh.it"
mailDir = "hpi9670\\c\$\\inetpub\\mailroot\\pickup"
mailDirTemp = "D:\\VoxNauta\\temp"  
t1 = 600
#t2 = 60
t2 = 0  
#tempiLog = "cache" 
logRun = "cache"

Try this simple code for reading the above configuration file:

open FILE_CONF,"clientMaster.ini" || die;
while () {
next if (/^#/ || /^;/ || /^$/ || /^\s/);
eval("\$$_");
}
close FILE_CONF;

# verifying variables read from configuration file
print "debug = $debug\nt1 = $t1\nt2 = $t2\nmailServer = $mailServer\nmailDir = 
$mailDir\nmailDirTemp = $mailDirTemp\n";
print "tempiLog = $tempiLog\nlogRun = $logRun\n";

E.


LOQUENDO S.p.A. 
Vocal Technology and Services 
www.loquendo.it 
[EMAIL PROTECTED]  
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons
above and may contain confidential information. If you have received
the message in error, be informed that any use of the content hereof
is prohibited. Please return it immediately to the sender and delete
the message. Should you have any questions, please contact us by
replying to [EMAIL PROTECTED] Thank you


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



Re: precompiled regular expressions

2003-12-02 Thread Rob Dixon
<[EMAIL PROTECTED]> wrote:
>
> Hi, whats the right way to precompile a regular expression
> that gets used multiple times without changing.
>
> I don't think I can use /o, because the specific line of code
> which performs the pattern match is used to check various
> patterns against various values at various times.  None the
> less, the patterns themselves don't change, once established,
> and it seems I should be able to save a precompiled regular
> expression in a variable and use it when it's time to match
> the corresponding pattern.
>
> The code as it stands looks like this:
>
>if( defined($addr) and $addr =~ /$self->{_rule}/i ) {
>  $retval = $self->{_confidence};
>}
>
> which is an object method used with multiple object instances
> each having its own value for $self->{_rule}, which is why I
> can't use /o.

Hi.

Presumably $self->{_rule} is a character string compilable as a
regex. Using qr// will force an immediate compilation, so you could say

  $self->{_regex} = qr/$self->{_rule}/i

in the objext constructor. There's also no need to keep
the plain text regex so, depending on what your code looks like
to build $self->{_rule}, you could just store a compiled regex
into the object's value.

HTH,

Rob



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



Config file

2003-12-02 Thread Rod
What is the best way to read a config file for a perl script.  I have 
some very ugly code that can do it, but I would like to find something 
cleaner.

Thanks,
Rod.


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


RE: Net::SSH and Net::FTP?

2003-12-02 Thread Dan Muey
> > 
> > I would like to use SSH to login to a remote system, then 
> using FTP, 
> > upload a file from the remote machine to another machine which will 
> > display the data. If I can automate this process, I think 
> I'll be in 
> > great shape, tell me does this code seem like it would work 
> for this?

Just a thought, if you're having trouble with the ssh part.

You could just use ftp for both servers?

use Net::FTP;

$ftpa = Net::FTP->new("a.host.name", Debug => 0)
  or die "Cannot connect to a.host.name: $@";
$ftpb = Net::FTP->new("b.host.name", Debug => 0)
  or die "Cannot connect to b.host.name: $@";
 
$ftpa->login($usera,$passa)
  or die "Cannot login to A", $ftp->message;
$ftpb->login($userb,$passb)
  or die "Cannot login to B", $ftp->message;

$ftpa->cwd("/files/blah")
  or die "Cannot change working directory A", $ftp->message;
$ftpb->cwd("/foo/monkey")
  or die "Cannot change working directory B", $ftp->message;

for(@filestotransfer) {
# then use $ftpa->read() and $ftpb->write() to xfr them between each other, 
# sorry for lack of example I'm a bit busy!
}

$ftpa->quit;
$ftpb->quit;

Transfer files back and forth between the 2 Net::FTP objects. I'm not 
saying it's better or anythgin, just another way to do it that may help 
if ssh is being tricky as it some times can.

HTH

DMuey

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



RE: using perl in a c code

2003-12-02 Thread Dan Muey
> Ramprasad A Padmanabhan wrote:
> > I choose to write code in perl , unless I am forced to 
> write it in C , 
> > either because  my system just hangs if I use perl ( like some 
> > threaded applications ) or because my BOSS wants so ;-)
> 
> That's why its nice to have a not-too-techie boss. I just 
> throw all sorts of jargon at him 
> until his head is about to explode, and then he just tells me 
> to do whatever I want.
> 

That one put a smile on my face, thanks Andrew for that wonderful truth!
:)
DMuey

> -- 
> Andrew Gaffney

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



Re: using perl in a c code

2003-12-02 Thread Andrew Gaffney
Ramprasad A Padmanabhan wrote:
I choose to write code in perl , unless I am forced to write it in C ,
either because  my system just hangs if I use perl ( like some threaded
applications ) or because my BOSS wants so ;-)
That's why its nice to have a not-too-techie boss. I just throw all sorts of jargon at him 
until his head is about to explode, and then he just tells me to do whatever I want.

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


RE: Encrypting PERL source code...

2003-12-02 Thread Jenda Krynicky
From: "Ichim, Adrian N." <[EMAIL PROTECTED]>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > 
> > Can anyone suggest where I might be able to find (hopefully a
> > freeware or shareware script..) a program that runs either on a
> > windows system or a PERL script that would "encrypt" a perl script
> > by doing such things as removing whitespace, etc. so that it is much
> > more difficult to read but yet will execute as if "unencrypted"??
> > I'd like to make the source code as difficult to pirate as I can for
> > a program that I'm developing. Thanks!
> 
> A pretty decent way to hide your code may be this one: 
> try a "perl-to-exe" transformation, followed by a compression
> of the resulting executable (in the UPX style).
> 
> NOTE: perl2exe programs are not free, AFAIK. The executables
> made by certain trialware perl2exe programs attempt to read 
> data from their own executable image files stored on disk. 
> This kind of executables are not good candidates for "on the fly"
> compression/decompression. 

PAR is free
http://search.cpan.org/search?query=PAR&mode=module

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


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



Re: CGI - DBI

2003-12-02 Thread Todd W.

"Jerry Rocteur" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>

>
> I was wondering, can anyone point me to some precooked Perl CGI scripts
> that already do data entry, I can browse and search my tables already
> in CGI and DBD but I loathe to make what I've done look reasonable and
> even worse, starting to create forms etc for data edit and data entry
> would make my hair even more grey than it is now..
>
I use MySQLMan, a free web based mysql client:

http://www.gossamer-threads.com/scripts/mysqlman/index.htm

works great.

Todd W.



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



precompiled regular expressions

2003-12-02 Thread mcdavis941
Hi, whats the right way to precompile a regular expression that gets used multiple 
times without changing.  

I don't think I can use /o, because the specific line of code which performs the 
pattern match is used to check various patterns against various values at various 
times.  None the less, the patterns themselves don't change, once established, and it 
seems I should be able to save a precompiled regular expression in a variable and use 
it when it's time to match the corresponding pattern.

The code as it stands looks like this:

   if( defined($addr) and $addr =~ /$self->{_rule}/i ) {
   $retval = $self->{_confidence};
   }

which is an object method used with multiple object instances each having its own 
value for $self->{_rule}, which is why I can't use /o.

Any help very much appreciated, and yes I am now rereading the documentation.



__
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

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



Mechanize 500 connect failed

2003-12-02 Thread Paul Kraus
We discussed this some in an earlier thread but I have yet to resolve
the issue.
About 15% of them I run my script it will fail with this error.

500 Connect failed: Unknown error, Unknown Error at line ...

The script is sound as it runs fine the rest of the time.

I thought maybe its because the site is unstable but I get the same
issue with another script that does a similar thing to another website.

I have wrapped my connect calls in while loops as a temporary fix.
However I plan to have this script run as a cron job and the thought
have it hanging has occurred. I could set it to try only so many times
but this is still just a work around rather then a fix.

Here is one page call that goes to the login page.

TIA
Paul 

sub login{
  my ( $login, $password, $url ) = ( 'XX',
'XXX','https://www.merchantconnect.com/merchant_tools/index.asp' );
  my $statementurl =
'https://www.merchantconnect.com/merchant_tools/statement_funding/printr
ecent.asp?p1=undefined';

  # Continue to try and connect untill a connection is established.
  my $flag = 0;
  while ( $flag == 0 ){
$merchant -> get ( $url ); 
warn "Can't even get the login page: ", $merchant -> response ->
status_line unless $merchant -> success;
$flag = 1 if ($merchant -> success );
  }
  $merchant -> field( 'uid', $login );
  $merchant -> field( 'pwd', $password );
  $merchant -> submit();
  die "Can't submit login form: ", $merchant -> response -> status_line
unless $merchant -> success;

  $merchant -> get ( $statementurl );
  die "Can't even get the statement page: ", $merchant -> response ->
status_line unless $merchant -> success;
}


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



RE: Can' t read all bytes from Socket

2003-12-02 Thread Kipp, James
 
>   I happened to be working on a TCP/IP server when this 
> hit my desk
> and having Programming Perl open to the correct page, thought 
> I might as
> well quote the "select..." line from the client code... 
> 
> select ((select(Server), $| = 1)[0];
> print Server "Howdy\n"; 
> $answer = ;  
> 

Thanks. I will give it a shot. 


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



RE: Encrypting PERL source code...

2003-12-02 Thread Ichim, Adrian N.
> -Original Message-
> From: [EMAIL PROTECTED]
> 
> Can anyone suggest where I might be able to find (hopefully a freeware 
> or shareware script..) a program that runs either on a windows system 
> or a PERL script that would "encrypt" a perl script by doing
> such things as
> removing whitespace, etc. so that it is much more difficult 
> to read but
> yet will execute as if "unencrypted"?? I'd like to make the 
> source code
> as difficult to pirate as I can for a program that I'm developing.
> Thanks!

A pretty decent way to hide your code may be this one: 
try a "perl-to-exe" transformation, followed by a compression
of the resulting executable (in the UPX style).

NOTE: perl2exe programs are not free, AFAIK. The executables
made by certain trialware perl2exe programs attempt to read 
data from their own executable image files stored on disk. 
This kind of executables are not good candidates for "on the fly" 
compression/decompression. 

Of course, this is not a bulletproof encryption, but only 
a weak method to hide your code. Feel free to experiment ...


**
PLEASE NOTE: The above email address has recently changed from a previous naming 
standard -- if this does not match your records, please update them to use this new 
name in future email addressed to this individual.

This message and any attachments are intended for the 
individual or entity named above. If you are not the intended
recipient, please do not forward, copy, print, use or disclose this 
communication to others; also please notify the sender by 
replying to this message, and then delete it from your system. 

The Timken Company
**


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



Re: using perl in a c code

2003-12-02 Thread Ramprasad A Padmanabhan
On Tue, 2003-12-02 at 15:56, Manish Uskaikar wrote:

> I am a student of perl, who is amazed by the power of perl, when it comes to
> regular expressions. I have learned Omnimark / flex and many other tools,
> but found that Perl is better than all(This is my personal opinion). Let me
> assure the group that it is not for any harmful use. I am trying to parse a
> big data file. Please provide the correct information.
> 
> Thanking U in advance.
> 
> Regards
> Manish U.


Perl is a great language no doubt  in parsing large files. 
If you are parsing a big data file , no matter how big , There is no
reason why you should not use perl  Unless your process is time critical
, and there are a queue of processes that are waiting for your process
to finish at run time

I choose to write code in perl , unless I am forced to write it in C ,
either because  my system just hangs if I use perl ( like some threaded
applications ) or because my BOSS wants so ;-)

Ram



NETCORE SOLUTIONS *** Ph: +91 22 5662 8000 Fax: +91 22 5662 8134

MailServ and FlexiMail: Messaging Solutions: http://netcore.co.in

Pragatee: Integrated Server-Software Suite: http://www.pragatee.com

Emergic Freedom: Server-centric Computing: http://www.emergic.com

BlogStreet: Blog Profiles and RSS Ecosystem: http://blogstreet.com

Deeshaa: Rural Development: http://www.deeshaa.com

Rajesh Jain's Weblog on Technology: http://www.emergic.org




[Fwd: log file parser into a database]

2003-12-02 Thread Thorsten Scherler

--- Begin Message ---
Hello,
I am looking for information about reporting of different log-files.
Something like http://www.logreport.org/ or  
http://www.mrunix.net/webalizer/.
It should be able to analysis FTP, LDAP, http, Sendmail...

To get started I am looking for a "parser" that reads the logs and store 
the input into a database. Is there a something? I am totaly new to Perl 
so if this a stupid question I am sorry!

At http://logreport.org/doc/gen/email/sendmail.php is the structure of
thus a log pretty good described(sendmail):
Jul 15 17:11:21 thor.foo.com sendmail[22398]: e6FFBLP22398:
from=, size=589, class=0, nrcpts=1,
msgid=<27151510.e6FFAC316448(a)odin.foo.com>, proto=ESMTP,
daemon=MTA, relay=jan(a)odin.foo.com [192.168.1.1]
and (LDAP) [http://tille.soti.org/training/ldap/ldapbasics-c1135.html]
Jul 17 16:53:53 server1 slapd[1010]: daemon: conn=7448 fd=43 connection
from IP=127.0.0.1:40629 (IP=:: 389) accepted.
Jul 17 16:53:53 server1 slapd[1010]: conn=7448 op=0 BIND dn="" method=128
Jul 17 16:53:53 server1 slapd[1010]: conn=7448 op=0 RESULT tag=97 err=0
text=
This log should be uploaded to a data base. The problem that I see is 
that the logs have different formats that means that you have to keep 
different tabels and different upload "parser".

Any help, links, ready to use scripts are really welcome!
King regards
Thorsten

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

Calling a program in win32 with spaces in the path to the .exe

2003-12-02 Thread PerlDiscuss - Perl Newsgroups and mailing lists
How do you handle spaces in a system call to an .exe


@args = (C:/Program Files/Total War/Medieval - Total War/Medieval_TW.exe");



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



Re: using perl in a c code

2003-12-02 Thread Manish Uskaikar
I am a student of perl, who is amazed by the power of perl, when it comes to
regular expressions. I have learned Omnimark / flex and many other tools,
but found that Perl is better than all(This is my personal opinion). Let me
assure the group that it is not for any harmful use. I am trying to parse a
big data file. Please provide the correct information.

Thanking U in advance.

Regards
Manish U.
--
The information contained in this message is confidential and proprietary to
KnowledgeWorks Global Limited, Mumbai, India. It is intended only for the
use of the individual or entity to whom it is addressed. If you are not the
intended recipient, or the authorized agent thereof, you are hereby notified
that any disclosure, use, distribution, dissemination or copying in any form
of any information contained in this message is strictly prohibited. If you
have received this message by mistake or error, please notify us immediately
by return email to the sender or by fax on number +91-22-28291673 and delete
all copies of the original message.

Phone : 91-22-56971177  Ext 323
- Original Message -
From: "Ramprasad A Padmanabhan" <[EMAIL PROTECTED]>
To: "Robert Brown" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 11:33 AM
Subject: Re: using perl in a c code


> On Mon, 2003-12-01 at 22:02, Robert Brown wrote:
>
> > Sounds like you are trying to write a harvesting tool to build a
> > spammer's email address list to me.  Since you want to do it in C, I
> > suspect that either you have a huge amount of text to parse, probably
> > from web pages and news group postings, or you need to write a tool
> > that will run inside of a worm or virus to extract email addresses
> > from an address list of a machine you just hacked.  Please explain to
> > the list why it would be beneficial to help you.  For one, you could
> > just write it in perl and then use one of the perl2c tools out there
> > to translate it into C.
>
>
> Oops , I am sorry , If I sounded like a spammer.  But What I actually
> want to do is find out the recipients in a email in a milter program (
> from the headers , and not from rcpt callback ) . This milter plugs in
> to the SMTP server  , ie sendmail and now I can do a whole lot of
> validation and email redirection  depending on the headers, which is the
> real requirement.
>
> There is actually a perl module for milter  Sendmail::Milter, But it
> uses some untested thread functions and simply hangs most unpredictably
> ( I am using perl5.6.1 with threads on redhat 7.2) . Also A milter in
> perl is inherently very slow as compared to one in C.
>
> So I translated most of code into C and this script runs very well.
> But I miss my favorite regex's in C
>
>
> BTW , I cant see any reason Why a spammer wouldinsist on using C
> against perl  for his database
>
> Thanks
> Ram
>
>
>
>
> 
>
> NETCORE SOLUTIONS *** Ph: +91 22 5662 8000 Fax: +91 22 5662 8134
>
> MailServ and FlexiMail: Messaging Solutions: http://netcore.co.in
>
> Pragatee: Integrated Server-Software Suite: http://www.pragatee.com
>
> Emergic Freedom: Server-centric Computing: http://www.emergic.com
>
> BlogStreet: Blog Profiles and RSS Ecosystem: http://blogstreet.com
>
> Deeshaa: Rural Development: http://www.deeshaa.com
>
> Rajesh Jain's Weblog on Technology: http://www.emergic.org
> 
>
>



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