beginners@perl.org

2003-12-30 Thread Tim
Hey,

When I run the following programme:

#! c:\Perl\bin\perl.exe -w -i

use strict;
use warnings;
use Bio::Perl;
use Bio::SeqIO;

my $seq_object= get_sequence('swissprot',"EAEA_HAFAL");
write_sequence("intimin.fasta",'fasta',$seq_object);

I receive the following error:
Undefined subroutine &IO::String called at
C:/perl/site/lib/Bio/DB/WebDBSeqI.pm line 482.

Anybody any idea how to solve this problem?

Kind regards
Tim




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




beginners@perl.org

2003-12-30 Thread Randy W. Sims
On 12/30/2003 3:42 AM, Tim wrote:

Hey,

When I run the following programme:

#! c:\Perl\bin\perl.exe -w -i

use strict;
use warnings;
use Bio::Perl;
use Bio::SeqIO;
my $seq_object= get_sequence('swissprot',"EAEA_HAFAL");
write_sequence("intimin.fasta",'fasta',$seq_object);
I receive the following error:
Undefined subroutine &IO::String called at
C:/perl/site/lib/Bio/DB/WebDBSeqI.pm line 482.
Anybody any idea how to solve this problem?

I'm not real familiar with bioperl; I think you may have better luck on 
the bioperl mailing list. See:



specifically:

Regards,
Randy.


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



perlTk/inquiry

2003-12-30 Thread awongxi
I am running linux redhat ver 8. perl v5.8.0. I downloaded perltk from: 
http://xbeams.chem.yale.edu/~loria/perltk.html and rpm it. I then tried 
to run the example script from http://www.pconline.com/~erc/perltk.htm 
but I am getting this error msg:

Can't locate auto/Tk/findINC.al in @INC (@INC contains: 
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at 
/usr/lib/perl5/5.8.0/Tk.pm line 51
Compilation failed in require at tkmenu.pl line 5.
BEGIN failed--compilation aborted at tkmenu.pl line 5.

I guess it has to do with the creation of the dinamic loadable 
libraries... but I am not sure, and I do not knwo how to get this to 
work, if some one could please tell me what am I doing wrong? how to 
correct it.. cheers.

zentara wrote:

On Fri, 9 May 2003 10:13:16 +0200 , [EMAIL PROTECTED] (Ruben
Montes) wrote:
 

HI, 
I want to write a simple script to generate a pop-up window that should
beclicked to get it closed... Where should I start?
Thanks,
   

Here's a start:
##
#!/usr/bin/perl
# test prg for notification window
use Tk;
use strict;
my $mw_bdw = 2;  #mainwindow border width
### Create a Mainwindow ###
my $main = new MainWindow(-borderwidth=>$mw_bdw,
 -relief=>'ridge',
 -bg => "#FF");
$main->geometry("150x100+0+0"); # displaying at top left on any
resolution
$main->overrideredirect(1); # Remove window decorations and keep on all
screens
### create a text widget ###
my $imstr = "THIS IS A TEST NOTIFICTION LONG ENOUGH TO WRAP";
my $TEXT = $main->Text(
  -foreground=> 'white',
  -background=> '#FF',
  -wrap => 'word',
  -height => 7,
  -width => 50)->pack;
$TEXT->insert('end', "$imstr", );

#$main-> after(5000, \&exitprg); # autoclose in 5000 milisecs
$main->bind('',sub{$main->destroy}); #or sub exitprg
MainLoop; 

 FUNCTIONS 
sub exitprg {
print STDERR "CALLED EXIT\n";
$main-> destroy; # to kill the window and exit from prog
}




 




Re: perlTk/inquiry

2003-12-30 Thread denis

I know that RH 9 has major problems running TK. Something to do with the 
way the lib's where linked. Try a google search for more info.

HTH..

Denis

On Wed, 31 Dec 2003, awongxi wrote:

> I am running linux redhat ver 8. perl v5.8.0. I downloaded perltk from: 
> http://xbeams.chem.yale.edu/~loria/perltk.html and rpm it. I then tried 
> to run the example script from http://www.pconline.com/~erc/perltk.htm 
> but I am getting this error msg:
> 
> Can't locate auto/Tk/findINC.al in @INC (@INC contains: 
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at 
> /usr/lib/perl5/5.8.0/Tk.pm line 51
> Compilation failed in require at tkmenu.pl line 5.
> BEGIN failed--compilation aborted at tkmenu.pl line 5.
> 
> I guess it has to do with the creation of the dinamic loadable 
> libraries... but I am not sure, and I do not knwo how to get this to 
> work, if some one could please tell me what am I doing wrong? how to 
> correct it.. cheers.
> 
> 
> zentara wrote:
> 
> >On Fri, 9 May 2003 10:13:16 +0200 , [EMAIL PROTECTED] (Ruben
> >Montes) wrote:
> >
> >  
> >
> >>HI, 
> >>I want to write a simple script to generate a pop-up window that should
> >>beclicked to get it closed... Where should I start?
> >>Thanks,
> >>
> >>
> >
> >Here's a start:
> >##
> >#!/usr/bin/perl
> ># test prg for notification window
> >use Tk;
> >use strict;
> >
> >my $mw_bdw = 2;  #mainwindow border width
> >### Create a Mainwindow ###
> >my $main = new MainWindow(-borderwidth=>$mw_bdw,
> >  -relief=>'ridge',
> >  -bg => "#FF");
> >
> >$main->geometry("150x100+0+0"); # displaying at top left on any
> >resolution
> >$main->overrideredirect(1); # Remove window decorations and keep on all
> >screens
> >### create a text widget ###
> >my $imstr = "THIS IS A TEST NOTIFICTION LONG ENOUGH TO WRAP";
> >my $TEXT = $main->Text(
> >   -foreground=> 'white',
> >   -background=> '#FF',
> >   -wrap => 'word',
> >   -height => 7,
> >   -width => 50)->pack;
> >
> >$TEXT->insert('end', "$imstr", );
> >
> >#$main-> after(5000, \&exitprg); # autoclose in 5000 milisecs
> >$main->bind('',sub{$main->destroy}); #or sub exitprg
> >
> >MainLoop; 
> >
> > FUNCTIONS 
> >sub exitprg {
> >print STDERR "CALLED EXIT\n";
> >$main-> destroy; # to kill the window and exit from prog
> >}
> >
> >
> >
> >
> >
> >  
> >
> 
> 


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




$_

2003-12-30 Thread Eric Walker
I am going through a file and when I enter a certain routine, I am
entering a while loop with the  construct.  Is there a way to back
the counter up or back up one line before I go into the while loop?

a
b
c
d

Instead of seeing b when I enter the while loop, adjust some option and
see the a.

perlknucklehead





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




mass-replacing large block of text

2003-12-30 Thread Andrew Gaffney
I have ~97 HTML documents that I need to strip the footer (about 15 lines) from and 
replace with a different block of text. The footer is formatted differently in some of the 
HTML files, but they all start with the line:



How can I replace everything after that particular line with a custom block of text? Thanks.

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



Re: $_

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:

I am going through a file and when I enter a certain routine, I am
entering a while loop with the  construct.  Is there a way to back
the counter up or back up one line before I go into the while loop?
a
b
c
d
Instead of seeing b when I enter the while loop, adjust some option and
see the a.
How about adding:

my $last;
while () {
	# use $last here, but watch for undef on the first iteration, for 
example:
	do_something( $last ) if defined $last;

$last = $_;
}
Hope that helps.

James

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



Re: $_

2003-12-30 Thread Eric Walker
The lines will always be defined but I need to process that previous
line.  I am still kinda in the closet on what you mean.

..
On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:

> I am going through a file and when I enter a certain routine, I am
> entering a while loop with the  construct.  Is there a way to back
> the counter up or back up one line before I go into the while loop?
>
> a
> b
> c
> d
>
> Instead of seeing b when I enter the while loop, adjust some option and
> see the a.

How about adding:

my $last;
while () {
# use $last here, but watch for undef on the first iteration, for 
example:
do_something( $last ) if defined $last;

$last = $_;
}

Hope that helps.

James





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




Cosolidate multiple regular expression

2003-12-30 Thread Kevin Old
Hello everyone,

I have the following regular expressions that I'm performing on a block
of text and was wondering if anyone saw a way to consolidate the 9
regex's into a few?

$ko =~ s/\r/\\page/g; # change returns to \page
$ko =~ s/\f//g; # remove formfeeds
$ko =~ s/\t/\\tab/g; # change tabs to \tab
$ko =~ s//\\/g; # escape backslashes
$ko =~ s/{/\\{/g; # escape left curly
$ko =~ s/}/\\}/g; # escape right curly
$ko =~ s/\n/\n\\par /g; # replace newlines with \n\par
$ko =~ s/\\par\s+\n\\par\s+\n\\par\s+\n+/\\par \n/migs; # cosolidate
"blank" lines
$ko =~ s/\\f0\\fs22\n\\page/\\f0\\fs22\n\\par /migs; # remove first page
break

This is not so much for laziness, but is more for learning what/how to
consolidate.

Any suggestions are appreciated.

Kevin
-- 
Kevin Old <[EMAIL PROTECTED]>


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




Re: $_

2003-12-30 Thread Eric Walker
Once I get into the while loop the previous line I had is lost.  As this
while is underneath another while that I am using in another routine.

thanks
On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:

> I am going through a file and when I enter a certain routine, I am
> entering a while loop with the  construct.  Is there a way to back
> the counter up or back up one line before I go into the while loop?
>
> a
> b
> c
> d
>
> Instead of seeing b when I enter the while loop, adjust some option and
> see the a.

How about adding:

my $last;
while () {
# use $last here, but watch for undef on the first iteration, for 
example:
do_something( $last ) if defined $last;

$last = $_;
}

Hope that helps.

James





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




RE: $_

2003-12-30 Thread Dan Muey
> The lines will always be defined but I need to process that 
> previous line.  I am still kinda in the closet on what you mean.
> 

He means the variable $last he used. I've tried to do an exqample that may help clear 
it up for you:

my $prev;
for(qw(a b c d e f g)) {
print "Previous item was $prev\n" if defined $prev;
print "Current item is $_\n";
$prev = $_;
}

HTH

DMuey

> ..
> On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
> On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
> 
> > I am going through a file and when I enter a certain 
> routine, I am
> > entering a while loop with the  construct.  Is 
> there a way to back
> > the counter up or back up one line before I go into the 
> while loop?
> >
> > a
> > b
> > c
> > d
> >
> > Instead of seeing b when I enter the while loop, adjust 
> some option and
> > see the a.
> 
> How about adding:
> 
> my $last;
> while () {
>   # use $last here, but watch for undef on the first 
> iteration, for 
> example:
>   do_something( $last ) if defined $last;
> 
>   $last = $_;
> }
> 
> Hope that helps.
> 
> 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: $_

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 10:45 AM, Eric Walker wrote:

The lines will always be defined but I need to process that previous
line.  I am still kinda in the closet on what you mean.
my $current = $_;
# process $current here...
Other choices:  If file size isn't an issue, just slurp the whole think 
into an array and use indexing.  If it is, use Tie::File.

Good luck.

James

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



RE: $_

2003-12-30 Thread Eric Walker
ok with that can I still continue through the loop and process the next
line?

will I not loose the second line now?

On Tue, 2003-12-30 at 09:49, Dan Muey wrote:
> The lines will always be defined but I need to process that 
> previous line.  I am still kinda in the closet on what you mean.
> 

He means the variable $last he used. I've tried to do an exqample that may help 
clear it up for you:

my $prev;
for(qw(a b c d e f g)) {
print "Previous item was $prev\n" if defined $prev;
print "Current item is $_\n";
$prev = $_;
}

HTH

DMuey

> ..
> On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
> On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
> 
> > I am going through a file and when I enter a certain 
> routine, I am
> > entering a while loop with the  construct.  Is 
> there a way to back
> > the counter up or back up one line before I go into the 
> while loop?
> >
> > a
> > b
> > c
> > d
> >
> > Instead of seeing b when I enter the while loop, adjust 
> some option and
> > see the a.
> 
> How about adding:
> 
> my $last;
> while () {
>   # use $last here, but watch for undef on the first 
> iteration, for 
> example:
>   do_something( $last ) if defined $last;
> 
>   $last = $_;
> }
> 
> Hope that helps.
> 
> 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]
 






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




Re: $_

2003-12-30 Thread Eric Walker
No size is not an issue.  I am writing a compare routine and the file
has different sections that all need to be split up differently
depending on the section to parse out the key value pairs so I can
compare.   

Thanks for the suggestions.


On Tue, 2003-12-30 at 09:53, James Edward Gray II wrote:
On Dec 30, 2003, at 10:45 AM, Eric Walker wrote:

> The lines will always be defined but I need to process that previous
> line.  I am still kinda in the closet on what you mean.

my $current = $_;
# process $current here...

Other choices:  If file size isn't an issue, just slurp the whole think 
into an array and use indexing.  If it is, use Tie::File.

Good luck.

James







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




RE: $_

2003-12-30 Thread Dan Muey
> Once I get into the while loop the previous line I had is lost.  As this 
> while is underneath another while that I am using in another routine.

It doesn't make any sense to read.
Why?
Please don't top post.

:)

I was using an array and for() in my example so you could see the principle in action.
Using your file handle with while() will work the same way. (Just don't do an array 
with while, that could make for a long running program!)
No matter how many loops within loops you have you need to save the current 
item in a variable inside the current block and use 
the variable inside you loop, like we did in the examples given.

Dmuey

> > The lines will always be defined but I need to process that
> > previous line.  I am still kinda in the closet on what you mean.
> > 
> 
> He means the variable $last he used. I've tried to do an 
> exqample that may help clear it up for you:
> 
> my $prev;
> for(qw(a b c d e f g)) {
>   print "Previous item was $prev\n" if defined $prev;
>   print "Current item is $_\n";
>   $prev = $_;
> }
> 
> HTH
> 
> DMuey
> 
> > ..
> > On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
> > On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
> > 
> > > I am going through a file and when I enter a certain 
> > routine, I am
> > > entering a while loop with the  construct.  Is 
> > there a way to back
> > > the counter up or back up one line before I go into the 
> > while loop?
> > >
> > > a
> > > b
> > > c
> > > d
> > >
> > > Instead of seeing b when I enter the while loop, adjust 
> > some option and
> > > see the a.
> > 
> > How about adding:
> > 
> > my $last;
> > while () {
> > # use $last here, but watch for undef on the first 
> > iteration, for 
> > example:
> > do_something( $last ) if defined $last;
> > 
> > $last = $_;
> > }
> > 
> > Hope that helps.
> > 
> > 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]
>  
> 
> 
> 

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




Re: $_

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 10:55 AM, Eric Walker wrote:

No size is not an issue.  I am writing a compare routine and the file
has different sections that all need to be split up differently
depending on the section to parse out the key value pairs so I can
compare.
I bet that if you post a sample of this file and what you want to do 
with it, we can do good things.

my $last;
while (<>) {
my $current = $_;
# use $current and $last here
# $last will be undef on first iteration
$last = $_;
}
Should work fine though, even if you're changing the values in $current 
and $last.

James

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



RE: $_

2003-12-30 Thread Dan Muey
> 
> ok with that can I still continue through the loop and 
> process the next line?
> 
You can use $_ :
for(qw(1 2 3)) {
print "Processing files - iteration number $_\n";
my @files = qw(foo.txt bar.html);
for(@files) {
open(FH,"<$_") or die "Can not open $_ : $!;
my $prev;
while(FH) { 
print "Previous item was $prev\n" if defined $prev;
print "Current item is $_\n";
$prev = $_;
}
close(FH);
}
}

What happens when you do something like that?


> will I not loose the second line now?
> 
> On Tue, 2003-12-30 at 09:49, Dan Muey wrote:
> > The lines will always be defined but I need to process that 
> > previous line.  I am still kinda in the closet on what you mean.
> > 
> 
> He means the variable $last he used. I've tried to do an 
> exqample that may help clear it up for you:
> 
> my $prev;
> for(qw(a b c d e f g)) {
>   print "Previous item was $prev\n" if defined $prev;
>   print "Current item is $_\n";
>   $prev = $_;
> }
> 
> HTH
> 
> DMuey
> 
> > ..
> > On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
> > On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
> > 
> > > I am going through a file and when I enter a certain 
> > routine, I am
> > > entering a while loop with the  construct.  Is 
> > there a way to back
> > > the counter up or back up one line before I go into the 
> > while loop?
> > >
> > > a
> > > b
> > > c
> > > d
> > >
> > > Instead of seeing b when I enter the while loop, adjust 
> > some option and
> > > see the a.
> > 
> > How about adding:
> > 
> > my $last;
> > while () {
> > # use $last here, but watch for undef on the first 
> > iteration, for 
> > example:
> > do_something( $last ) if defined $last;
> > 
> > $last = $_;
> > }
> > 
> > Hope that helps.
> > 
> > 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]
>  
> 
> 
> 
> 
> 
> 

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




RE: mass-replacing large block of text

2003-12-30 Thread Dan Muey
> I have ~97 HTML documents that I need to strip the footer 
> (about 15 lines) from and 
> replace with a different block of text. The footer is 
> formatted differently in some of the 
> HTML files, but they all start with the line:
> 
> 
> 
> How can I replace everything after that particular line with 
> a custom block of text? Thanks.

Here's one way, you say the files are html so slurping shouldn't hurt:

[untested - for principle demo only]
#!/usr/bin/perl -w
use strict;
use File::Slurp;

my $newhtml = '';
my $split = '';
my @files = qw(index.html contact.html); # populate this by hand or automatially if 
you want

my $count = 0;
for(@files) {
print "Starting $_ ...";
my $html = read_file($_);

my ($firstpart) = split $split, $html; # may need to tweak around with this

write_file($_, "$firstpart$split$newhtml");
print "Done!\n";
$count++;
}

print "\nFinished : $count files processed.\n";

> 
> -- 
> Andrew Gaffney
> 
> 
> -- 
> 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]
 




Escape regex harmful characters

2003-12-30 Thread Kevin Old
Hello everyone,

I found the subroutine below from a script that takes a string of text
and builds a regular expression out of it and incorporates that into a
rule for SpamAssassin.  It's worked quite well for my needs, but the
script has led to a few questions about the code and regex's.

My questions are:

1) Are the characters escaped in the subroutine *all* the characters
that *should* be escaped in a regex?

2) The author seems to think "this is crap code, there will be a better
way to do this".thoughts, comments, suggestion on other ways this
can be done?


#escape stuff that would otherwise be regexp special
#this is crap code, there will be a better way to do this
sub escapebad {
my $string = $_[0];
$string =~ s/([\\\/[EMAIL PROTECTED](\)\<\>])/\\$&/g;
#bad cha
rs turned good
return ($string);
}

Also anyone interested in the script for generating SpamAssasin rules,
let me know and I'll send you a copy.

Thanks for any help,
Kevin
-- 
Kevin Old <[EMAIL PROTECTED]>


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




Re: mass-replacing large block of text

2003-12-30 Thread Randy W. Sims
On 12/30/2003 11:30 AM, Andrew Gaffney wrote:
I have ~97 HTML documents that I need to strip the footer (about 15 
lines) from and replace with a different block of text. The footer is 
formatted differently in some of the HTML files, but they all start with 
the line:



How can I replace everything after that particular line with a custom 
block of text? Thanks.

a small hint:

$ cat testdata
one
two
three
four
five
six
seven
eight
nine
ten
$ perl -nle 'print unless /six/..eof' test
one
two
three
four
five
I.e. Write everything out to your new copy except the old footer: 
'unless /pattern/ .. eof'

then write out your new footer.

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



Re: Escape regex harmful characters

2003-12-30 Thread Randy W. Sims
On 12/30/2003 12:22 PM, Kevin Old wrote:

Hello everyone,

I found the subroutine below from a script that takes a string of text
and builds a regular expression out of it and incorporates that into a
rule for SpamAssassin.  It's worked quite well for my needs, but the
script has led to a few questions about the code and regex's.
My questions are:

1) Are the characters escaped in the subroutine *all* the characters
that *should* be escaped in a regex?
2) The author seems to think "this is crap code, there will be a better
way to do this".thoughts, comments, suggestion on other ways this
can be done?
#escape stuff that would otherwise be regexp special
#this is crap code, there will be a better way to do this
sub escapebad {
my $string = $_[0];
$string =~ s/([\\\/[EMAIL PROTECTED](\)\<\>])/\\$&/g;
#bad cha
rs turned good
return ($string);
}

Also anyone interested in the script for generating SpamAssasin rules,
let me know and I'll send you a copy.
Thanks for any help,
Kevin
If you have a string that is going to need escaping, consider using 
/\Q$string\U/ to handle quoting regex special chars.

Regards,
Randy.


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



RE: mass-replacing large block of text

2003-12-30 Thread Charles K. Clarkson
Dan Muey <[EMAIL PROTECTED]> wrote:
: 
: Andrew Gaffney <[EMAIL PROTECTED]> wrote:
:
: > I have ~97 HTML documents that I need to strip the
: > footer (about 15 lines) from and replace with a
: > different block of text. The footer is formatted
: > differently in some of the HTML files, but they all
: > start with the line:
: > 
: > 
: > 
: > How can I replace everything after that particular
: > line with a custom block of text? Thanks.
: 
: Here's one way, you say the files are html so
: slurping shouldn't hurt:
: 
: [untested - for principle demo only]
: #!/usr/bin/perl -w
: use strict;
: use File::Slurp;
: 
: my $newhtml = '';
: my $split = '';
: my @files = qw(index.html contact.html); # populate this by 
: hand or automatially if you want
: 
: my $count = 0;
: for(@files) {
:   print "Starting $_ ...";
:   my $html = read_file($_);
: 
:   my ($firstpart) = split $split, $html; # may need to 
: tweak around with this
: 
:   write_file($_, "$firstpart$split$newhtml");
:   print "Done!\n";
:   $count++;
: }
: 
: print "\nFinished : $count files processed.\n";

Andrew,

If your server is SSI (or ASP) enabled, you might
consider replacing the existing footer with an included
file. That way you will only have to change one file in
the future. And it can be adjusted more often.


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328





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




RE: mass-replacing large block of text

2003-12-30 Thread Kipp, James
> 
> 
> 
> How can I replace everything after that particular line with 
> a custom block of text? Thanks.
> 
 
Maybe using tell() and truncate() on the file?, then an inline edit/insert.

--

$file = 'yourfile';
open (FH, "+< $file")   or die "can't edit $file: $!";
while (  ) {
$pos = tell(FH) if $_ =~ /table border/; # your regex here
}
truncate(FH, $pos + 1)or die "can't truncate $file: $!";
-

# then figure out how to insert your new text block. ask again if you 
#  have trouble





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




Re: mass-replacing large block of text

2003-12-30 Thread Andrew Gaffney
Charles K. Clarkson wrote:
Dan Muey <[EMAIL PROTECTED]> wrote:
: 
: Andrew Gaffney <[EMAIL PROTECTED]> wrote:
:
: > I have ~97 HTML documents that I need to strip the
: > footer (about 15 lines) from and replace with a
: > different block of text. The footer is formatted
: > differently in some of the HTML files, but they all
: > start with the line:
: > 
: > 
: > 
: > How can I replace everything after that particular
: > line with a custom block of text? Thanks.
: 
: Here's one way, you say the files are html so
: slurping shouldn't hurt:
: 
: [untested - for principle demo only]
: #!/usr/bin/perl -w
: use strict;
: use File::Slurp;
: 
: my $newhtml = '';
: my $split = '';
: my @files = qw(index.html contact.html); # populate this by 
: hand or automatially if you want
: 
: my $count = 0;
: for(@files) {
: 	print "Starting $_ ...";
: 	my $html = read_file($_);
: 
: 	my ($firstpart) = split $split, $html; # may need to 
: tweak around with this
: 
: 	write_file($_, "$firstpart$split$newhtml");
: 	print "Done!\n";
: 	$count++;
: }
: 
: print "\nFinished : $count files processed.\n";

Andrew,

If your server is SSI (or ASP) enabled, you might
consider replacing the existing footer with an included
file. That way you will only have to change one file in
the future. And it can be adjusted more often.
I am already using mod_perl with Apache in Linux to run most of my perl CGI scripts. I 
have yet to actually re-write them in mod_perl. I'm just using Apache::Registry. I'm 
thinking about using HTML::Mason to do this kind of thing already. Its still in the 
planning stages for now, but it is an option.

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



Re: Escape regex harmful characters

2003-12-30 Thread Steve Grazzini
On Dec 30, 2003, at 12:30 PM, Randy W. Sims wrote:
If you have a string that is going to need escaping, consider
using /\Q$string\U/ to handle quoting regex special chars.
Right -- but that should be \E (for "end") instead of \U (the
mnemonic for which is "uppercase", not "unquote").
% perl -le 'print "\Qxxx\Uyyy"'
xxxYYY
--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



inquiry-perltk

2003-12-30 Thread awongxi
I am running linux redhat ver 8. perl v5.8.0. I downloaded perltk from: 
http://xbeams.chem.yale.edu/~loria/perltk.html and rpm it. I then tried 
to run the example script from http://www.pconline.com/~erc/perltk.htm 
but I am getting this error msg:

Can't locate auto/Tk/findINC.al in @INC (@INC contains: 
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at 
/usr/lib/perl5/5.8.0/Tk.pm line 51
Compilation failed in require at tkmenu.pl line 5.
BEGIN failed--compilation aborted at tkmenu.pl line 5.

I guess it has to do with the creation of the dinamic loadable 
libraries... but I am not sure, and I do not knwo how to get this to 
work, if some one could please tell me what am I doing wrong? how to 
correct it.. cheers.

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



My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Dan Muey
> > > The thing is I get "Sending...Done" everytime but never a
> > dleivery and
> > > no hinf tof it in the logs. On one server I needed to use smtp 
> > > authentication but that set $@ and said connection

This part of it was completely stupid on my part:

I was doing if($@) { ...

I added if($@ || $Mail::Sender::Error) { ...

And guess what? It gave me the error message. Duh, what a moron!

So now it said "Connection not established" for 
the local sending to remote, which I would think would 
be the easiest one, especially since:

Local to local is ok.
Remote to local is ok.
I'm not doing any remote to remote.

But authentication made my mail servers start sending it but I'm still not sure why my 
mail server would insist on authentication in one case but not the other.

Oh well, whaddayado!

Dan

> couldn't be made.
> > > 
> > > Any ideas what I'm missing would be awesome!
> > 
> > By default Mail::Sender does not raise exceptions. It returns 
> > negative error codes.
> > 
> 
> Right on! I'll take a look at your cpan page again and redo
> my problem handling angle.
> 
> As usual you rock!
> 
> > Jenda

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




Re: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Daniel Staal
--As off Tuesday, December 30, 2003 11:58 AM -0600, Dan Muey is 
alleged to have said:

So now it said "Connection not established" for
the local sending to remote, which I would think would
be the easiest one, especially since:
Local to local is ok.
Remote to local is ok.
I'm not doing any remote to remote.
But authentication made my mail servers start sending it but I'm
still not sure why my  mail server would insist on authentication
in one case but not the other.
--As for the rest, it is mine.

They are doing the Right Thing and not being an open relay. 
Basically the server says *one* of the persons involved has to be 
known to it.  If the email is for a local user it knows that person. 
If it isn't, you have to authenticate as someone it knows.  Otherwise 
Joe Spammer can come and ask the server to please deliver these 10k 
messages to random people.

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: $_

2003-12-30 Thread Eric Walker
On Tue, 2003-12-30 at 10:04, Dan Muey wrote:
> 
> ok with that can I still continue through the loop and 
> process the next line?
> 
You can use $_ :
for(qw(1 2 3)) {
print "Processing files - iteration number $_\n";
my @files = qw(foo.txt bar.html);
for(@files) {
open(FH,"<$_") or die "Can not open $_ : $!;
my $prev;
while(FH) { 
print "Previous item was $prev\n" if defined $prev;
print "Current item is $_\n";
$prev = $_;
}
close(FH);
}
}

What happens when you do something like that?


> will I not loose the second line now?
> 
> On Tue, 2003-12-30 at 09:49, Dan Muey wrote:
> > The lines will always be defined but I need to process that 
> > previous line.  I am still kinda in the closet on what you mean.
> > 
> 
> He means the variable $last he used. I've tried to do an 
> exqample that may help clear it up for you:
> 
> my $prev;
> for(qw(a b c d e f g)) {
>   print "Previous item was $prev\n" if defined $prev;
>   print "Current item is $_\n";
>   $prev = $_;
> }
> 
> HTH
> 
> DMuey
> 
> > ..
> > On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
> > On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
> > 
> > > I am going through a file and when I enter a certain 
> > routine, I am
> > > entering a while loop with the  construct.  Is 
> > there a way to back
> > > the counter up or back up one line before I go into the 
> > while loop?
> > >
> > > a
> > > b
> > > c
> > > d
> > >
> > > Instead of seeing b when I enter the while loop, adjust 
> > some option and
> > > see the a.
> > 
> > How about adding:
> > 
> > my $last;
> > while () {
> > # use $last here, but watch for undef on the first 
> > iteration, for 
> > example:
> > do_something( $last ) if defined $last;
> > 
> > $last = $_;
> > }
> > 
> > Hope that helps.
> > 
> > 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]
>  
> 
> 
> 
> 
> 
> 
Sorry for the Top post its my default reply setting. Np.  Ok I kinda of see what 
you guys/girls are talking about.  Let me try something and if it
doesn't work I will post up some code.

Thanks
Knucklehead



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




RE: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Dan Muey
>
> 
> They are doing the Right Thing and not being an open relay. 
> Basically the server says *one* of the persons involved has to be 

In both cases one is always a local user. But only in one case is authentication 
required.

> known to it.  If the email is for a local user it knows that person. 
> If it isn't, you have to authenticate as someone it knows.  Otherwise 
> Joe Spammer can come and ask the server to please deliver these 10k 
> messages to random people.

Right, but my question is why do I need to authenticate local 
to remote and not remote to local not why do I have to authenticate at all.
I'm well aware of the spam relay fun! :)

I could spam all the local users as [EMAIL PROTECTED] 
all day long without any knowledge of there settings.
So I guess, why not authenticate both ways? Just a pondering, no big 
deal since they'd have to get a scirpt on the server and that'd 
make them trackable pretty quick.

> Daniel T. Staal

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




Re: mass-replacing large block of text

2003-12-30 Thread Andrew Gaffney
Dan Muey wrote:
I have ~97 HTML documents that I need to strip the footer 
(about 15 lines) from and 
replace with a different block of text. The footer is 
formatted differently in some of the 
HTML files, but they all start with the line:



How can I replace everything after that particular line with 
a custom block of text? Thanks.


Here's one way, you say the files are html so slurping shouldn't hurt:

[untested - for principle demo only]
#!/usr/bin/perl -w
use strict;
use File::Slurp;
my $newhtml = '';
my $split = '';
my @files = qw(index.html contact.html); # populate this by hand or automatially if 
you want
my $count = 0;
for(@files) {
print "Starting $_ ...";
my $html = read_file($_);
	my ($firstpart) = split $split, $html; # may need to tweak around with this

write_file($_, "$firstpart$split$newhtml");
print "Done!\n";
$count++;
}
print "\nFinished : $count files processed.\n";
This slightly modified version of your script seems to work just fine:

#!/usr/bin/perl -w
use strict;
use File::Slurp;
my $newhtml = '\n';
my $split = '';
my @files = qw(uc.html); # populate this by hand or automatially if you want
for(@files) {
print "Starting $_ ...";
my $html = read_file($_);
my ($firstpart) = split $split, $html; # may need to tweak around with this

#   write_file($_, "$firstpart$split$newhtml");
print "$firstpart$newhtml\n";
print "Done!\n";
}
--
Andrew Gaffney
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: mass-replacing large block of text

2003-12-30 Thread Dan Muey
> Dan Muey wrote:
> >>I have ~97 HTML documents that I need to strip the footer
> >>(about 15 lines) from and 
> >>replace with a different block of text. The footer is 
> >>formatted differently in some of the 
> >>HTML files, but they all start with the line:
> >>
> >>
> >>
> >>How can I replace everything after that particular line with
> >>a custom block of text? Thanks.
> > 
> > 
> > Here's one way, you say the files are html so slurping 
> shouldn't hurt:
> > 
> > [untested - for principle demo only]
> > #!/usr/bin/perl -w
> > use strict;
> > use File::Slurp;
> > 
> > my $newhtml = '';
> > my $split = '';
> > my @files = qw(index.html contact.html); # populate this by hand or 
> > automatially if you want
> > 
> > my $count = 0;
> > for(@files) {
> > print "Starting $_ ...";
> > my $html = read_file($_);
> > 
> > my ($firstpart) = split $split, $html; # may need to 
> tweak around 
> > with this
> > 
> > write_file($_, "$firstpart$split$newhtml");
> > print "Done!\n";
> > $count++;
> > }
> > 
> > print "\nFinished : $count files processed.\n";
> 
> This slightly modified version of your script seems to work just fine:
> 

Cool.

> #!/usr/bin/perl -w
> use strict;
> use File::Slurp;
> 
> my $newhtml = '\n';

The only problem I see here you have enter the same data 
twice leaving room for mistakes you have to fix.

So by leaving it out of $newhtml and using  
print "$firstpart$split$newhtml\n"; # or add some newlines for readability
You gaurantee the same data with no mistakes.

DMuey

> my $split = '';
> my @files = qw(uc.html); # populate this by hand or 
> automatially if you want
> 
> for(@files) {
>  print "Starting $_ ...";
>  my $html = read_file($_);
> 
>  my ($firstpart) = split $split, $html; # may need to 
> tweak around with this
> 
> #   write_file($_, "$firstpart$split$newhtml");
>  print "$firstpart$newhtml\n";
>  print "Done!\n";
> }
> 
> -- 
> Andrew Gaffney

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




RE: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Shawn McKinley

[snip]
 
> Right, but my question is why do I need to authenticate local 
> to remote and not remote to local not why do I have to 
> authenticate at all. I'm well aware of the spam relay fun! :)

[snip]

If you are going to authenticate remote to local, that would mean
every email server trying to send mail to your server would have
to authenticate.  I don't know about your mail server, but mine
would have no way of authenticating the 10K+ remote servers a day
that send emails to me or others on that server...

The idea is to prevent relaying.  If the remote is sending to your
local, your server will not relay it to another.

Shawn



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




RE: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Dan Muey
 
> [snip]
>  
> > Right, but my question is why do I need to authenticate local
> > to remote and not remote to local not why do I have to 
> > authenticate at all. I'm well aware of the spam relay fun! :)
> 
> [snip]
> 
> If you are going to authenticate remote to local, that would 
> mean every email server trying to send mail to your server 
> would have to authenticate.  I don't know about your mail 
> server, but mine would have no way of authenticating the 10K+ 
> remote servers a day that send emails to me or others on that 
> server...
> 
> The idea is to prevent relaying.  If the remote is sending to 
> your local, your server will not relay it to another.
> 

Got it thanks Shawn.

> Shawn
> 
> 
> 

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




RE: Art Gallery Perl Script

2003-12-30 Thread Dan Muey
I have a dandy one I'm developing. Webbased admin, very configurable, fast, etc...
Shall I let you know about it when it's done?

Dan

> -Original Message-
> From: Joe Echavarria [mailto:[EMAIL PROTECTED] 
> Sent: Friday, December 26, 2003 12:32 PM
> To: [EMAIL PROTECTED]
> Subject: Art Gallery Perl Script
> 
> 
> Hi there,
> 
>   I am looking for Art Gallery Perl script available,
> can anyone recomend me one ?, thanks.
> 
> __
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing. 
http://photos.yahoo.com/

-- 
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: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Daniel Staal
--As off Tuesday, December 30, 2003 12:33 PM -0600, Dan Muey is 
alleged to have said:

They are doing the Right Thing and not being an open relay.
Basically the server says *one* of the persons involved has to be
In both cases one is always a local user. But only in one case is
authentication required.
Without authentication, if you are sending, the mail server can't 
tell a local from a remote user.  (It can always tell for receiving: 
it just checks its own delivery tables.)

(There are ways around this.  But they are fairly easy to spoof if 
the mail server is accessible from the internet, and do not work for 
roaming 'local' users or static IP addresses (well, static IPs could 
be used, with a lot of extra work).  Authenication is easier to set 
up and harder to spoof.)

I could spam all the local users as [EMAIL PROTECTED]
all day long without any knowledge of there settings.
So I guess, why not authenticate both ways? Just a pondering, no
big  deal since they'd have to get a scirpt on the server and
that'd  make them trackable pretty quick.
For remote to local: authenticate how?  You don't want to block mail 
coming in from random domains (since you don't know which are spam 
domains and which aren't), so you have to let random people send you 
email.  Otherwise the only email you can handle is local to local, 
and that just isn't very useful.  (Note: joemama is probably a 
registered, legit, and paid-in-full user of remotespamville.com , so 
you can't say people who aren't from that domain.  He *is* from that 
domain.)

And now we are well into anti-spam theology.  (There have been 
several complete systems proposed to handle the 'authenticated guest' 
problem here, none currently is in use.)  And out of Perl. ;-)

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: My stupidity! (WAS RE: Mail::Sender weirdness)

2003-12-30 Thread Dan Muey
> --As off Tuesday, December 30, 2003 12:33 PM -0600, Dan Muey is 
> alleged to have said:
> 
> >> They are doing the Right Thing and not being an open 
> relay. Basically 
> >> the server says *one* of the persons involved has to be
> >
> > In both cases one is always a local user. But only in one case is 
> > authentication required.
> 
> Without authentication, if you are sending, the mail server can't 
> tell a local from a remote user.  (It can always tell for receiving: 
> it just checks its own delivery tables.)
> 
> (There are ways around this.  But they are fairly easy to spoof if 
> the mail server is accessible from the internet, and do not work for 
> roaming 'local' users or static IP addresses (well, static IPs could 
> be used, with a lot of extra work).  Authenication is easier to set 
> up and harder to spoof.)
> 
> > I could spam all the local users as [EMAIL PROTECTED] all 
> > day long without any knowledge of there settings. So I 
> guess, why not 
> > authenticate both ways? Just a pondering, no big  deal since they'd 
> > have to get a scirpt on the server and that'd  make them trackable 
> > pretty quick.
> 
> For remote to local: authenticate how?  You don't want to block mail 
> coming in from random domains (since you don't know which are spam 
> domains and which aren't), so you have to let random people send you 
> email.  Otherwise the only email you can handle is local to local, 
> and that just isn't very useful.  (Note: joemama is probably a 
> registered, legit, and paid-in-full user of remotespamville.com , so 
> you can't say people who aren't from that domain.  He *is* from that 
> domain.)
> 
> And now we are well into anti-spam theology.  (There have been 
> several complete systems proposed to handle the 'authenticated guest' 
> problem here, none currently is in use.)  And out of Perl. ;-)
> 

Cool, good info. 
I was looking at it wrong, after all the subjkect is "My Stupidity!" :)

> 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: mass-replacing large block of text

2003-12-30 Thread Andrew Gaffney
Dan Muey wrote:
Dan Muey wrote:

I have ~97 HTML documents that I need to strip the footer
(about 15 lines) from and 
replace with a different block of text. The footer is 
formatted differently in some of the 
HTML files, but they all start with the line:



How can I replace everything after that particular line with
a custom block of text? Thanks.


Here's one way, you say the files are html so slurping 
shouldn't hurt:

[untested - for principle demo only]
#!/usr/bin/perl -w
use strict;
use File::Slurp;
my $newhtml = '';
my $split = '';
my @files = qw(index.html contact.html); # populate this by hand or 
automatially if you want

my $count = 0;
for(@files) {
print "Starting $_ ...";
my $html = read_file($_);
	my ($firstpart) = split $split, $html; # may need to 
tweak around 

with this

write_file($_, "$firstpart$split$newhtml");
print "Done!\n";
$count++;
}
print "\nFinished : $count files processed.\n";
This slightly modified version of your script seems to work just fine:



Cool.


#!/usr/bin/perl -w
use strict;
use File::Slurp;
my $newhtml = '\n';
		
The only problem I see here you have enter the same data 
twice leaving room for mistakes you have to fix.

So by leaving it out of $newhtml and using  
print "$firstpart$split$newhtml\n"; # or add some newlines for readability
You gaurantee the same data with no mistakes.
I don't understand why you include $split in the new file. The text I want to get replace 
is from and including that line to the end of the file.

my $split = '';
my @files = qw(uc.html); # populate this by hand or 
automatially if you want

for(@files) {
print "Starting $_ ...";
my $html = read_file($_);
my ($firstpart) = split $split, $html; # may need to 
tweak around with this

#   write_file($_, "$firstpart$split$newhtml");
print "$firstpart$newhtml\n";
print "Done!\n";
}
--
Andrew Gaffney




--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548


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



Re: Cosolidate multiple regular expression

2003-12-30 Thread drieux
On Dec 30, 2003, at 8:45 AM, Kevin Old wrote:
[..]
$ko =~ s/\r/\\page/g; # change returns to \page
$ko =~ s/\f//g; # remove formfeeds
$ko =~ s/\t/\\tab/g; # change tabs to \tab
$ko =~ s//\\/g; # escape backslashes
$ko =~ s/{/\\{/g; # escape left curly
$ko =~ s/}/\\}/g; # escape right curly
$ko =~ s/\n/\n\\par /g; # replace newlines with \n\par
$ko =~ s/\\par\s+\n\\par\s+\n\\par\s+\n+/\\par \n/migs; # cosolidate
"blank" lines
$ko =~ s/\\f0\\fs22\n\\page/\\f0\\fs22\n\\par /migs; # remove first 
page
break

This is not so much for laziness, but is more for learning what/how to
consolidate.
Sometimes 'consolidation' does not save the nation.

but the lines that amuse me are

$ko =~ s/\n/\n\\par /g; # replace newlines with \n\par
$ko =~ s/\\par\s+\n\\par\s+\n\\par\s+\n+/\\par \n/migs; # cosolidate
first we put some stuff in and then decide to rip it out...

What if we tried to solve the 'blank line' problem first?

There is also that minor buggaboo about
"\r\n" - our friends 
that first line in the package would take say

	Joe\r\n\r\nBob

and convert it into

	Joe\page\n\page\nBob

and then we hit the \\par packer
and would get to
	Joe\page\n\par\page\n\parBob

and now we do not see our 'empty line'

So I would always start with the

take out what we want to remove
then dither with what is left.
Say something along the line of

	$ko =~ s/\r\n\s*\r\n/\r\n/mig ;

that would take us from our initial state to

	Joe\r\nBob

and perchance a bit more sanity in the process.

Logically the next line would do the remove
of things like the \f and then we start
worrying about the rest of the substitutions.
I presume you have already peeked

	perldoc perlretut

as well as picked up the book on mastering
regular expressions.
ciao
drieux
---

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



Pure Perl df

2003-12-30 Thread James Edward Gray II
Okay, I'm at a loss and need help.  A friend of mine is working with a 
Perl script.  It has a system call to df in it, he would like to 
replace with something a little more portable.

The script is used in a 32 server environment that I know has at least 
four operating systems:  HP-UX, Solaris, Linux, and Windows.  I believe 
df is pretty standard on all of those but Windows, though the options 
vary.

So the questions:  Is there a pure Perl way to handle a df-like call?  
Is there an equivalent program in the Windows world?  Any other tips?

I browsed the CPAN a bit, but wasn't too happy with the choices there, 
aside from the fact that any module installs would pretty much defeat 
the purpose here.

Thanks for any help you can provide.

James

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



RE: mass-replacing large block of text

2003-12-30 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: Dan Muey wrote:
: >> Dan Muey wrote:
: >>> Andrew Gaffney wrote:
: >>>
:  
: 
:  How can I replace everything *after* that
:  particular line with a custom block of text?
[emphasis added]

[snip]

: I don't understand why you include $split in the
: new file. The text I want to get replace is from
: and including that line to the end of the file.

Because you originally said you only wanted to
"replace everything *after* that particular line."


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


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




RE: Pure Perl df

2003-12-30 Thread Bakken, Luke
> Okay, I'm at a loss and need help.  A friend of mine is 
> working with a 
> Perl script.  It has a system call to df in it, he would like to 
> replace with something a little more portable.

Well, looking here at the source to df on OpenBSD:
http://www.openbsd.org/cgi-bin/cvsweb/src/bin/df/df.c?rev=1.37&content-t
ype=text/x-cvsweb-markup

it looks as though it uses getmntinfo() to get information about free
space. This function call may be implemented in some perl module, or you
could be brave and use syscall() to call it. I'll work on that for kicks
and get back to the list. Your friend will have to see if this function
exists on all his unix platforms.
 
> The script is used in a 32 server environment that I know has 
> at least 
> four operating systems:  HP-UX, Solaris, Linux, and Windows.  
> I believe 
> df is pretty standard on all of those but Windows, though the options 
> vary.

On Windows, I'd use Win32::DriveInfo

> So the questions:  Is there a pure Perl way to handle a 
> df-like call?  
> Is there an equivalent program in the Windows world?  Any other tips?
> 
> I browsed the CPAN a bit, but wasn't too happy with the 
> choices there, 
> aside from the fact that any module installs would pretty much defeat 
> the purpose here.

Why is that? That is the point of modules.

Luke

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




Re: mass-replacing large block of text

2003-12-30 Thread Andrew Gaffney
Charles K. Clarkson wrote:
Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: Dan Muey wrote:
: >> Dan Muey wrote:
: >>> Andrew Gaffney wrote:
: >>>
:  
: 
:  How can I replace everything *after* that
:  particular line with a custom block of text?
[emphasis added]

[snip]

: I don't understand why you include $split in the
: new file. The text I want to get replace is from
: and including that line to the end of the file.
Because you originally said you only wanted to
"replace everything *after* that particular line."
I guess that makes sense then :)

--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548


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



RE: Pure Perl df

2003-12-30 Thread Morbus Iff
>> I browsed the CPAN a bit, but wasn't too happy with the
>> aside from the fact that any module installs would pretty much defeat
>> the purpose here.
>
>Why is that? That is the point of modules.
Note that if the module is pure perl without a lot of dependencies, you can
ship it with your final tarbull - that's the approach I use with AmphetaDesk
(http://www.disobey.com/amphetadesk/), where I ship XML::Simple and
Text::Template, even for Linux distributions. Stuff that requires
compilation (like XML::Parser, Compress::Zlib, etc., etc.), I leave
up to the ever easy-to-use CPAN.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Help with extracting text

2003-12-30 Thread Zary Necheva
Hi everyone,
How can I extract the text before the first occurrence of dot (.) or 
single space  from the first field.

This is my file

LB1571 5TH .W43 1993|text1|text1|
FICT. V.12|text2|text2|
FICT.|text3|text3|
HQ806 .B35 1995|text4|text4|
G530.T6B4941988Q|text5|text5|
MPCD11 .B42 P27|text6|text6|
.
C |textn|textn
This is the output  that  I need

LB1571|tex1|text1|
FICT|text2|text2|
FICT|text3|text3|
HQ806|text4|text4|
G530|text5|text5
MPCD11|text6|text6
.
C |textn|textn
Thanks,
Zary Necheva
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



checking duplicates

2003-12-30 Thread SilverFox
Hi all, i'm trying to figure out how I can check for duplicates entries in 
an array and remove the duplicate.

Example:
23,23,39,40,44,44
should result in:
23,39,40,44

I'm reading from a file and assigning it to an array.

Silver Fox

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




modify JPEG on the fly

2003-12-30 Thread Scott Taylor

Hello all,

I'm using Apache 1.3.27, Perl 5.6.1 with DBI->DBD::Interbase on Linux
2.4 machine.

I have a CGI script which display a JPEG from an Interbase Blob.  Now,
what I would like to do is modify the JPEG to make it into a useful
thumbnail.

here is the code that converts the blob (Thanks to Dan Muey, and
others for help with that a few months ago)

# loop through the SQL results
while ( my ($PixData )
= $sth->fetchrow ) {
print header('image/jpeg');
print $PixData;
}

Now I want to send $PixData to a new command that will convert it from
a 640 X 480 @ 100% JPEG to 160 x 120 @ 30% JPEG.

Any ideas?

Cheers.

--
Scott


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




Re: Pure Perl df

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 3:56 PM, Bakken, Luke wrote:

I browsed the CPAN a bit, but wasn't too happy with the
choices there,
aside from the fact that any module installs would pretty much defeat
the purpose here.
Why is that? That is the point of modules.
Well, as I said we're talking about 32 servers running at least 4 
different operating systems here, and we're not comparing versions yet. 
 How many versions of Perl do you think that adds up to?  If we're 
going to install modules under those conditions why not just check the 
OS version and shell out?  I bet there are less combinations that way.

This a professional server environment, with real world serving 
concerns like big uptime, system restores, etc.  The way the sys admins 
keep on top of all that is to stay as in control of those machines as 
humanly possible.  That means they think long and hard before adding 
more software dependancies.  If they add even one module, that means 
they've practically doubled the work of all future Perl upgrades (one 
install to two, plus testing).  If they add 10 modules across 32 
servers, well that's getting crazy pretty fast.

Don't get me wrong.  I love the CPAN and the tons of modules it offers. 
 I'm sure they do too, under the right circumstance.  They've got a job 
to do though and sometimes that makes for hard choices.

James

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



RE: checking duplicates

2003-12-30 Thread Charles K. Clarkson
SilverFox <[EMAIL PROTECTED]> wrote:
: 
: Hi all, i'm trying to figure out how I can check
: for duplicates entries in an array and remove
: the duplicate.
 
Read perlfaq4:

How can I remove duplicate elements from a list or array?

HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


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




RE: Pure Perl df

2003-12-30 Thread Bakken, Luke
> >> I browsed the CPAN a bit, but wasn't too happy with the
> >> choices there,
> >> aside from the fact that any module installs would pretty 
> much defeat
> >> the purpose here.
> >
> > Why is that? That is the point of modules.
> 
> Well, as I said we're talking about 32 servers running at least 4 
> different operating systems here, and we're not comparing 
> versions yet. 
>   How many versions of Perl do you think that adds up to?  If we're 
> going to install modules under those conditions why not just 
> check the 
> OS version and shell out?  I bet there are less combinations that way.

That's your answer. Use $^O and other OS indicators and set up df's args
appropriately then.

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




Re: Pure Perl df

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 4:07 PM, Morbus Iff wrote:

Note that if the module is pure perl without a lot of dependencies, 
you can
ship it with your final tarbull
I looked at three modules.  Two didn't support Windows and I have no 
idea about the third, which I couldn't figure out what it was up to.  
If you guys are seeing a good module I'm missing please do point it 
out.  Heck, if it's "pure Perl", I can just see how it's managing a df 
call...

James

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



Re: Pure Perl df

2003-12-30 Thread James Edward Gray II
On Dec 30, 2003, at 4:30 PM, Bakken, Luke wrote:

That's your answer. Use $^O and other OS indicators and set up df's 
args
appropriately then.
Which gets us back to my other question:  Is there a Windows equivalent?

James

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



RE: modify JPEG on the fly

2003-12-30 Thread Charles K. Clarkson
Scott Taylor <[EMAIL PROTECTED]> wrote:
: 
: I'm using Apache 1.3.27, Perl 5.6.1 with DBI->DBD::Interbase
: on Linux 2.4 machine.
: 
: I have a CGI script which display a JPEG from an Interbase
: Blob.  Now, what I would like to do is modify the JPEG to
: make it into a useful thumbnail.
: 
: here is the code that converts the blob (Thanks to Dan
: Muey, and others for help with that a few months ago)
: 
: # loop through the SQL results
: while ( my ($PixData )
: = $sth->fetchrow ) {
: print header('image/jpeg');
: print $PixData;
: }
: 
: Now I want to send $PixData to a new command that will
: convert it from a 640 X 480 @ 100% JPEG to 160 x 120 @
: 30% JPEG.
: 
: Any ideas?

I think Randal has a couple of articles on making
thumbnails on-the-fly. Have a look at:

  http://www.stonehenge.com/merlyn/


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328




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




RE: Pure Perl df

2003-12-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
James Edward Gray II wrote:
> On Dec 30, 2003, at 4:30 PM, Bakken, Luke wrote:
> 
>> That's your answer. Use $^O and other OS indicators and set up df's
>> args appropriately then.
> 
> Which gets us back to my other question:  Is there a Windows
> equivalent? 
> 
> James

At a command prompt under w2k I get:
C:\PROGRA~1\DRAGST~1>df
C:   (C:/)3111623/15631181
D:   (D:/)8641771/23438771
Z:   (pgmfs1\dwagne01$) 12975360/177807352

Also got:
C:\PROGRA~1\DRAGST~1>help df
df -- display amount of free space remaining on disk
Usage:  df [-kPt] [[device] [filename]] ...

-k  report disk space in 1K units rather than 512-byte blocks
-P  list complete information on disk space
-t  list space used as well as space free

Wags ;)


**
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: Pure Perl df

2003-12-30 Thread Bakken, Luke
> > That's your answer. Use $^O and other OS indicators and set up df's 
> > args
> > appropriately then.
> 
> Which gets us back to my other question:  Is there a Windows 
> equivalent?

Sure, look at the output of the 'dir' command.

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




Re: make problem with xs file (Time::Object)

2003-12-30 Thread drieux
On Dec 29, 2003, at 11:00 AM, Will Glass-Husain wrote:
[..]
P.S.  In case anyone else has hit this error, this was pulled directly 
from
cpan "install Time::Object".

[EMAIL PROTECTED] Time-Object-1.00]# make
gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING 
-fno-str
ict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64
 -I/usr/include/gdbm -DPERL_POLLUTE  -O2 -march=i386 -mcpu=i686 -g   
-DVERSI
ON=\"1.00\" -DXS_VERSION=\"1.00\" -fPIC
"-I/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE"   Object.c
Object.xs:34: parse error before '(' token
[..]

folks are probably not going to believe what I think
is the Problem here is a bit convoluted to try to explain.
What seems to have happened in 5.8.X is that now the
embed.h is there and it is being called out by perl.h
and it would be really nice if there were some form of
#ifndef PERL_EMB_H
#define PERL_EMB_H

#endif
then one could modify the Makefile.PL for Time::Object

'XSPROTOARG' => ' -prototypes',
'DEFINE' => '-D PERL_EMB_H',
and it would prevent the compiler from picking up where
it is re-defining bouth init_tm() and mini_mktime()
meatbop: 65:] grep init_tm *.h
embed.h:#define init_tm Perl_init_tm
embed.h:#define init_tm(a)  Perl_init_tm(aTHX_ a)
proto.h:PERL_CALLCONV void  Perl_init_tm(pTHX_ struct tm *ptm);
meatbop: 66:] grep mini_mktime *.h
embed.h:#define mini_mktime Perl_mini_mktime
embed.h:#define mini_mktime(a)  Perl_mini_mktime(aTHX_ a)
proto.h:PERL_CALLCONV void  Perl_mini_mktime(pTHX_ struct tm *pm);
meatbop: 67:] pwd
/usr/lib/perl5/5.8.1/i586-linux-thread-multi/CORE
meatbop: 68:]
so the trick is to edit the Object.xs file so that
one commits the two tolks to being really the ones
that are local to the code that it will be creating
1,$s/init_tm/time_object_init_tm/g
1,$s/mini_mktime/time_object_mini_mktime/g
and now your code will not have function names that will
get into an argument. I have cc'd matt into this, in the
hope that he may have a better fix.
ciao
drieux


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



Re: $_

2003-12-30 Thread Rob Dixon
Eric Walker wrote:
>
> I am going through a file and when I enter a certain routine, I am
> entering a while loop with the  construct.  Is there a way to back
> the counter up or back up one line before I go into the while loop?
>
> a
> b
> c
> d
>
> Instead of seeing b when I enter the while loop, adjust some option and
> see the a.

Forgive me, but what a disappointing thread this has turned out to be!

I was drawn by the subject line, which turned out to be irrelevant, and
met a series of speculative answers.

My fault really, for letting my hopes be raised.

Rob



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




piped system commands

2003-12-30 Thread deb
Happy Almost New Year!

I want to run a command inside a script.  From the shell, here's the command:

% ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}'
19460

What is returned is the pid of the process being grep'd.

But, when I put this into a test script, 

my $pid = `ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk 
'{print $2}'`;
print "\$pid is: $pid \n";

here's what I'm seeing ,

$pid is:  root 19460 1  0   Dec 18 ?0:08 /usr/lib/sendmail -bd -q15m

--

It seems to be only going as far as dropping off the grep, and not doing the
awk '{print $2}'.   I've tried this with the system() call, with the same
results.  

What am I missing?   :-(

deb



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




Re: piped system commands

2003-12-30 Thread Andrew Gaffney
deb wrote:
Happy Almost New Year!

I want to run a command inside a script.  From the shell, here's the command:

% ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}'
19460
What is returned is the pid of the process being grep'd.

But, when I put this into a test script, 

my $pid = `ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk 
'{print $2}'`;
print "\$pid is: $pid \n";
here's what I'm seeing ,

$pid is:  root 19460 1  0   Dec 18 ?0:08 /usr/lib/sendmail -bd -q15m

--

It seems to be only going as far as dropping off the grep, and not doing the
awk '{print $2}'.   I've tried this with the system() call, with the same
results.  
Try changing the $2 to \$2. Perl is interpolating $2 before it gets to bash, so bash sees 
"/bin/awk '{print }'".

--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548


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



RE: piped system commands

2003-12-30 Thread Bakken, Luke
> I want to run a command inside a script.  From the shell, 
> here's the command:
> 
> % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep 
> | /bin/awk '{print $2}'
> 19460

Instead of the useless 'grep -v grep', do this:

% ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}'

> But, when I put this into a test script, 

Might I suggest finding the 'pid' file for sendmail and reading that
instead? It should be under /var/run or some such directory...

Luke

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




Re: Help with extracting text

2003-12-30 Thread drieux
On Dec 30, 2003, at 1:35 PM, Zary Necheva wrote:
[..]
How can I extract the text before the first occurrence
of dot (.) or single space  from the first field.
This is my file

LB1571 5TH .W43 1993|text1|text1|
FICT. V.12|text2|text2|
FICT.|text3|text3|
HQ806 .B35 1995|text4|text4|
G530.T6B4941988Q|text5|text5|
MPCD11 .B42 P27|text6|text6|
[..]

you might want you want is to "clean" out
the stuff between the 'first "word"' and the
first | you are in the land of crazy RegEx Voodoo
say something like:

	s/[\s\.]+[^\|]*//;

we need to see a "space" or a "." - at least one of
them, and then any number of things that are NOT a "|"
and we then just RIP them out of the pattern space.
HTH.

ciao
drieux
---

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



Re: piped system commands

2003-12-30 Thread drieux
On Dec 30, 2003, at 3:54 PM, deb wrote:

Happy Almost New Year!
[..]
It seems to be only going as far as dropping off the grep, and not 
doing the
awk '{print $2}'.   I've tried this with the system() call, with the 
same
results.

What am I missing?   :-(
you have a shell interpret who to which problem.

vladimir: 65:] perl junk.plx
$pid is: 192
vladimir: 66:] sed 's/^/### /' junk.plx
### #!/usr/bin/perl -w
### use strict;
###
### my $cmd = q!ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}' 
!;
###
### my $pid = `$cmd`;
### print "\$pid is: $pid \n";
###
###
vladimir: 67:]

Andrew's suggestion of guarding the "$2" will also work.
I thought I would base my variant on Luke's somewhat tighter
general solution.
ciao
drieux
---

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



wannabie asks Mail::POP3Client && Mail::Audit

2003-12-30 Thread wolf blaum
Hi, 
Im new (here|to perl) and would like to start of with that:

My script should replace attachmends in mails: however, i cant find any atts.

Script first:
 --
#! /usr/bin/perl

use strict;
use warnings;
use Mail::POP3Client;
use Mail::Audit qw(Attach);

my $pop=new Mail::POP3Client(USER => "you",
  PASSWORD => "youpass",
  HOST => "your.server");

for (my $i=1; $i<= $pop->Count();$i++) {
   my @mail = $pop->Retrieve($i);
   my $mailref = [EMAIL PROTECTED];
   my $mail = Mail::Audit->new(data => $mailref);   
   print "From: ", $mail->from,"\nSubject: ",$mail->subject, "\n";

#try to find Content-type: multipart/mixed; boundary= in mail header 
#manually
   foreach (@$mailref){ 
 /^(Content-type:)\s+/i and print "$_\n";
   }

#let Mail::Audit:Attachments try
   print "Att-no: ", $mail->num_attachments, "\n";
   my $atts = $mail->attachments;
   foreach (@$atts){
 print "size: ",$_->size,"\nfilename: ",$_->filename,"\n";
   }


} #for all mails in inbox

$pop->Close();

---

Since I dont want the Mail::Audit object to use my local inbox but the pop 
retrieved data I pass the array ref to it.

The problem:
even though a print join ("\n",[EMAIL PROTECTED]); shows me there are "Content-type: 
multipart\mixed" headers my first attempt to find them manually fails and 
gives me only the "Content-type: text/plain" or "..application/blabla" lines 
from the mail body of multi part mails.

Second attempt to identify atts via Mail::Audit::Attachment fails too.

All mail headers of the retrieved messages do carry a "MIME-version: 1.0" line 
as required by Mail::Audit::Attachment.

All the other print froms and so work fine 

What am I doing wrong?
Better solutions?

Thanks a lot, Wolf


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




Re: $_

2003-12-30 Thread Eric Walker
On Tue, 2003-12-30 at 16:39, Rob Dixon wrote:
Eric Walker wrote:
>
> I am going through a file and when I enter a certain routine, I am
> entering a while loop with the  construct.  Is there a way to back
> the counter up or back up one line before I go into the while loop?
>
> a
> b
> c
> d
>
> Instead of seeing b when I enter the while loop, adjust some option and
> see the a.

Forgive me, but what a disappointing thread this has turned out to be!

I was drawn by the subject line, which turned out to be irrelevant, and
met a series of speculative answers.

My fault really, for letting my hopes be raised.

Rob



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

sorry I didn't really phrase the question properly and didn't provide any example 
code.I will
do better next time.

Thanks
Knucklehead





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




command line search and replace

2003-12-30 Thread Randy Brown
Hi all,

When I try the following, perl reads the * as a literal character, instead of my 
intent as a global value. Anyone see what I am missing?

 perl -pi -e "s/file:*<\/provider-url>/REPLACED/g" testfile.txt


In the file testfile.txt, the line will be something like this: 
file:/opt/usr/bin/somewhere

I want to replace /opt/usr/bin/somewhere with something else, but I cannot assume what 
the value between file: and  will be.

Thanks for any advice.

Randy


-

The information contained in this message is proprietary of Amdocs,

protected from disclosure, and may be privileged.

The information is intended to be conveyed only to the designated recipient(s)

of the message. If the reader of this message is not the intended recipient,

you are hereby notified that any dissemination, use, distribution or copying of 

this communication is strictly prohibited and may be unlawful. 

If you have received this communication in error, please notify us immediately

by replying to the message and deleting it from your computer.

Thank you.

-

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


Compiling problem with Math-GMP-2.03

2003-12-30 Thread Mike Bernhardt
I have a Sun Enterprise running Solaris 2.9. I installed Perl 5.8. I am now
trying to compile Math-GMP-2.03 and I get the following output on "make":
cp lib/Math/GMP.pm blib/lib/Math/GMP.pm
AutoSplitting blib/lib/Math/GMP.pm (blib/lib/auto/Math/GMP)
/usr/local/bin/perl /usr/local/lib/perl5/5.8.0/ExtUtils/xsubpp  -typemap
/usr/local/lib/perl5/5.8.0/ExtUtils/typemap -typemap typemap  GMP.xs >
GMP.xsc && mv GMP.xsc GMP.c
gcc -B/usr/ccs/bin/ -c-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_O
FFSET_BITS=64 -O-DVERSION=\"2.03\"  -DXS_VERSION=\"2.03\" -fPIC
"-I/usr/local/lib/perl5/5.8.0/sun4-solaris/CORE"   GMP.c
Running Mkbootstrap for Math::GMP ()
chmod 644 GMP.bs
rm -f blib/arch/auto/Math/GMP/GMP.so
LD_RUN_PATH="/usr/local/lib" gcc -B/usr/ccs/bin/  -G -L/usr/local/lib
MP.o  -o blib/arch/auto/Math/GMP/GMP.so   -lgmp
ld: fatal: file /usr/local/lib/libgmp.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to
blib/arch/auto/Math/GMP/GMP.so
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target
`blib/arch/auto/Math/GMP/GMP.so'


I did successfully install gmp-4.1.2, although maybe I need to specify some
options I don't understand? What the heck is ELF and ELFCLASS64, and what do
I do about them? I can't figure out what the problem is. The same problem
occurs with less info, using MCPAN.

Thanks for any help!


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




Re: command line search and replace

2003-12-30 Thread drieux
On Dec 30, 2003, at 4:51 PM, Randy Brown wrote:

When I try the following, perl reads the * as a literal character, 
instead of my intent as a global value. Anyone see what I am missing?

 perl -pi -e "s/file:*<\/provider-url>/REPLACED/g" 
testfile.txt
you might want to revisit

	perldoc perlretut

since what you are in the midst of is a regular expression
and it is not clear to me that you really wanted to assert
	zero or more ":"

rather than say

	zero or more "any characters"

which would have been

	perl -pi -e "s/file:.*<\/provider-url>/REPLACED/g" 
testfile.txt

"." is the "wild card" character, which you want to have
zero or more of, yes?
ciao
drieux
---

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



Re: Compiling problem with Math-GMP-2.03

2003-12-30 Thread drieux
On Dec 30, 2003, at 4:53 PM, Mike Bernhardt wrote:
[..]
 ELF and ELFCLASS64,
[..]

ELF _ Executable and Linkable Format

It appears that your library that you are trying to
link to was build with solaris64, and you are trying
to build in the 32 bit mode - they all need to be
one or the other...
cf:



ciao
drieux
---

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



Re: wannabie asks Mail::POP3Client && Mail::Audit

2003-12-30 Thread wolf blaum
Follow-up:

> The problem:
> even though a print join ("\n",[EMAIL PROTECTED]); shows me there are
> "Content-type: multipart\mixed" headers my first attempt to find them
> manually fails and gives me only the "Content-type: text/plain" or
> "..application/blabla" lines from the mail body of multi part mails.

ok, i solved that one: 
my $mail = Mail::Audit->new(data => $mailref);
strangely eats the array up so I dont have anything for my manual attempt 
left.
The strange thing: It only eats the header, the body is still there: couldnt 
find anything in the docu of Mail::Audit that mentions that.
So droping the construction of that object (and its use) lets me identify the 
Content-type  option in the header manually or  by using the Mail::Header 
object, which parses the header and makes it accessible in standariezed form.


However:

> Second attempt to identify atts via Mail::Audit::Attachment fails too.
>

That still holds valid: I cant the heck use te Mail::Audit class as I would 
like to: seems like I cant use it at all...
Whats wrong here? My code? My understanding? My carma?

Thanks, Wolf


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




Problem with READDIR

2003-12-30 Thread Perl
I have a problem with the following block of code. It works fine when
there isn't a *.log file in the same directory as the script  but when
there is, it always returns that log as the newest file and ignores the
list of files it retrieves from the remote server. 

I debugged this and found that the READDIR is working but the last
element in the list is the log file that is in the script directory. 

What can I do to make sure I get the list of *.log files on the remote
machine regardless of what exists in my working local directory?



$iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1';
opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS:  $!\n";

my @files = grep /\.log$/, readdir LOGS;
@files = sort { -M $a <=> -M $b } @files;
$active_log = $files[-1];  # this should be the newest file rather than
a log in the local directory that the script is running from.


--Paul


Re: Escape regex harmful characters

2003-12-30 Thread R. Joseph Newton
Steve Grazzini wrote:

> On Dec 30, 2003, at 12:30 PM, Randy W. Sims wrote:
> > If you have a string that is going to need escaping, consider
> > using /\Q$string\U/ to handle quoting regex special chars.
>
> Right -- but that should be \E (for "end") instead of \U (the
> mnemonic for which is "uppercase", not "unquote").
>
>  % perl -le 'print "\Qxxx\Uyyy"'
>  xxxYYY

Which all makes a very good argument for the clearly named
quotemeta:

Greetings! E:\d_drive\perlStuff>perl -w
print "What's on your mind?\n";
my $input_line = ;
chomp $input_line;
my $escaped_string = quotemeta $input_line;
print "That's pretty bloody cryptic, y'know.  Howzabout a complete
sentence?\n";
my $full_line = ;
if ($full_line =~ /$escaped_string/) {
   print"the escaped string worked\n";
} else {
   print "escaping didn't help, dangitall!\n";
}

if ($full_line =~ /$input_line/) {
   print "The input line worked all on its lonely, anyway.\n";
} else {
   print "Maybe the escaped one did it?\n";
}

^Z
What's on your mind?
$5.00 to [EMAIL PROTECTED]
That's pretty bloody cryptic, y'know.  Howzabout a complete
sentence?
I owe $5.00 to [EMAIL PROTECTED], and I don't have it.
the escaped string worked
Maybe the escaped one did it?

Joseph


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




Re: Can I set '$!' ?

2003-12-30 Thread R. Joseph Newton
Dan Muey wrote:

> > I want to be able to return a true or false value from a
> > function in a module and populate the $! variable with the
> > specific errors. Is this possible? Is there documentation on
> > how to do this? I can find docs on how to use $! but not how
> > to set it. Thanks for any help -Ken
>
> Did anyone ever reply to this post?

Yes.  There was actually an extensive thread.

>
> I couldn't find it in the archives and I thinnk it's a pretty good question.
>
> For instance would it be 'safe' and 'proper', and 'ok', etc... to do somethign like:
>
> sub whatever {
> my $foo = shift;
> undef $!;
> if($foo eq 'bar') { return 1; }
> else { $! = "Foo must equal bar";return 0; }
> }
>
> TIA
>
> Dan

I agree that a close localization can be relatively harmless, maybe even useful.  Still
I would not recommend getting into the habit, since it could mask much more valuable
information from the interpreter, and since there are tons of other ways to communicate
custom errors.

Joseph


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




Dinesh Kumar/NCE/AMADEUS is out of the office.

2003-12-30 Thread Dinesh Kumar




I will be out of the office starting  22/12/2003 and will not return until
19/01/2004.

I am on vacation and will respond to your message when I return. For all
urgent matters please contact Fabien FELIX.

Thanks


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




Re: Problem with READDIR

2003-12-30 Thread Ramprasad A Padmanabhan
Perl wrote:
I have a problem with the following block of code. It works fine when
there isn't a *.log file in the same directory as the script  but when
there is, it always returns that log as the newest file and ignores the
list of files it retrieves from the remote server. 

I debugged this and found that the READDIR is working but the last
element in the list is the log file that is in the script directory. 

Never heard of such a thing.
readdir gets only files in the directory which you have opened

What can I do to make sure I get the list of *.log files on the remote
machine regardless of what exists in my working local directory?


Just try adding these line

$iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1';
opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS:  $!\n";
my @files = grep /\.log$/, readdir LOGS;


# -M $a would work only if you are already in that dir  so
chdir $iisdir;
@files = sort { -M $a <=> -M $b } @files;  
# if you dont like that give the full path in $a and $b

# I think it is reverse sorted
$active_log = $files[-1];  # this should be the newest file rather than
$active_log = $files[0];

a log in the local directory that the script is running from.

--Paul



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



Re: Problem with READDIR

2003-12-30 Thread Owen
On Tue, 30 Dec 2003 19:07:26 -0800
"Perl" <[EMAIL PROTECTED]> wrote:

> $iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1';
> opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS:  $!\n";
> 
> my @files = grep /\.log$/, readdir LOGS;
> @files = sort { -M $a <=> -M $b } @files;
> $active_log = $files[-1];  # this should be the newest file rather than
> a log in the local directory that the script is running from.



I was unable to duplicate your problem. Made 5 files 1.log .. 5.log  that order and in 
a faraway directory, and then 6.log in the working directory. 

"5.log" came up every time


-- 
Owen


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