RE: Formatting integer input: use the sprintf() in perlfunc - Perl builtin functions

2003-08-26 Thread Shaw, Matthew

 whenever you need to do any special formatting like this, 
 especially numbers, use the sprintf() in  perlfunc - Perl 
 builtin functions for your case, try this:
 
 print sprintf(%05.02f\n, 4.5 );
 04.50

Why not just use 'printf()' for this? Makes it somewhat less confusing
while doing essentially the same thing in the background:

printf %05.02f\n, 4.5;

The difference lies in if the '$\' ($OUTPUT_RECORD_SEPERATOR) is set
when you use the first example it will add an extra newline that you
probably would not intend (given the \n in the format). printf() will
ignore the value of $\ and format only according to your format
argument.

Just a suggestion.

Matt



 
 -Original Message-
 From: Sara [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, August 20, 2003 1:21 PM
 To: beginperl
 Subject: Formatting integer input
 
 
 $one = 2.5;
 $two = 2;
 $three = $one + $two;
 
 print $three; # prints 4.5
 
 I want 4.5 in proper format as 04.05
 
 Any ideas?
 
 Thanks,
 Sara.
 
 
 
 -- 
 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: Counter triggered on download

2003-08-26 Thread fliptop
On Sun, 24 Aug 2003 at 03:04, zsdc opined:

z:fliptop wrote:
z:
z: merrill - i'm a little late on this thread, and the other suggestions are
z: valid, but here's one way to serve up files w/o using a direct link by
z: taking advantage of CGI.pm's header() function:
z: 
z: my $cgi = new CGI;
z: print $cgi-header('application/pdf');
z:
z:Actually, it's the same as just:
z:
z:   print Content-Type: application/pdf\n\n;
z:
z:CGI.pm is great but it's an overkill for just printing HTTP Content-Type 
z:header.

that is true, however i cut the code out of a script i had handy.  the
params are passed in as such:

/cgi-bin/mime.cgi?filename=whatevermime_type=application%02Fpdf

so the full file looked something like this:


use CGI;

my $cgi = new CGI;
my $filename = $cgi-param('filename');
my $mime_type = $cgi-param('mime_type');

print $cgi-header($mime_type);

open OUT, $filename;
my $buffer;

while (my $read = read(OUT, $buffer, 4096)) {
  print $buffer;
}

close OUT;




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



Re: Counter triggered on download

2003-08-26 Thread fliptop
On Tue, 26 Aug 2003 at 00:31, Octavian Rasnita opined:

OR:This is a pretty good method, but it is not so good because the
OR:visitors won't be able to use a Download manager to download the file.
OR:Or better said, they won't be able to resume the download.

true, however the original poster asked how to increment a counter when a
file is downloaded.  they did not pose the question of how to do it *and*
allow the user to use download manager or resume the download if it became
interrupted.

OR:I am not sure, I will be testing this soon, but maybe a solution for
OR:this problem could be specifying the Content-length of this file as a
OR:HTTP header.
OR:
OR:This way the browsers and the download managers will be able to send
OR:the Range HTTP header and the web server will accept it.

be sure to share your results.


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



Net::FTP or similar

2003-08-26 Thread Andrew Brosnan
Hello,

Has anyone used Net::FTP to create a browser based FTP client? (I assume
that's one use for it) 

I have a client that needs to let their clients transfer files to and
from their server. Some of the files may be big (30-40MB) and using a
regular FTP client isn't an option, unfortunately.

I'm interested to hear peoples experience or suggestions.

Andrew

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



Installing/Uninstalling CPAN modules

2003-08-26 Thread Greenhalgh David
This may be the wrong forum to ask this...

How do I uninstall a module downloaded from CPAN? Specifically, I 
cannot get the DBD::MySQL driver to install under OS X. It refuses to 
find the mysql_config file, and when I run Makefile again with the -L 
and -I switches it won't work after install.

I am running the Complete MySQL distribution which has worked before, 
but since this installs into /usr/Library and not /usr/local, I am 
wondering if the module ignores symlinks to /usr/local. Hence I want to 
pull everything out and reload the MySQL AB distribution and try again. 
A quick search shows DBD in dozens of places, in perl/ in DBI/ in 
mySQL/ etc etc, which ones do I trash?

Dave

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


RE: Net::FTP or similar

2003-08-26 Thread wiggins


On Tue, 26 Aug 2003 15:06:08 -0400, Andrew Brosnan [EMAIL PROTECTED] wrote:

 Hello,
 
 Has anyone used Net::FTP to create a browser based FTP client? (I assume
 that's one use for it) 
 
 I have a client that needs to let their clients transfer files to and
 from their server. Some of the files may be big (30-40MB) and using a
 regular FTP client isn't an option, unfortunately.
 
 I'm interested to hear peoples experience or suggestions.
 

I am not sure I take your meaning??  I have used CGI to allow someone to upload files, 
and I have used Net::FTP to transfer files between servers, but I am not sure I know 
what you mean by a browser based FTP client.  Presumably you have a web server at your 
disposal which can take uploads, but then I am at a loss as to why you need FTP? If 
you mean to act as a proxy, so the file gets transferred to the web server, and then 
routed from there somewhere else, then basically you have a proxy and the underlying 
technology could be anything that allows file transfers, aka SSH, NFS, FTP, etc. But 
at that point the technologies are in effect not linked, so you would be better off 
dividing the tasks. In other words, have a CGI that just stores a file locally, then 
have another process watch/poll/scheduled to check for new uploads, in the event one 
exists, then do whatever it is you do when a new file is present, if that is FTP so 
be it. 

The one problem I can definitely see you running into, especially based on the file 
size you mentioned, is timeouts both on the server and client side.

There is also another HTTP protocol request type specifically for this, but I can't 
remember what it is right now (because it is almost never used for anything...) that 
essentially just allows a file to be stored to the server, but yikes

Unless you mean something along the lines of Mozilla and XPI? But then you are talking 
about Net::FTP installed on the client side...

http://danconia.org

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



Re: Installing/Uninstalling CPAN modules

2003-08-26 Thread Greenhalgh David
You may have better luck in the [EMAIL PROTECTED] list since OS X likes 
to do all kinds of weird things with its Perl, and with regards to 
DBI/DBD in [EMAIL PROTECTED]  Typically removing a Perl module is 
not as easy as installing them, removing the associated files is only 
one step...

Sorry I can't provide specifics I haven't tried this and don't have my 
PB with me

http://danconia.org


Thanks for that macosx link, that list passed me by somehow. I will ask 
there.

Dave

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


RE: Installing/Uninstalling CPAN modules

2003-08-26 Thread wiggins


On Tue, 26 Aug 2003 19:20:03 +, Greenhalgh David [EMAIL PROTECTED] wrote:

 This may be the wrong forum to ask this...
 
 How do I uninstall a module downloaded from CPAN? Specifically, I 
 cannot get the DBD::MySQL driver to install under OS X. It refuses to 
 find the mysql_config file, and when I run Makefile again with the -L 
 and -I switches it won't work after install.
 
 I am running the Complete MySQL distribution which has worked before, 
 but since this installs into /usr/Library and not /usr/local, I am 
 wondering if the module ignores symlinks to /usr/local. Hence I want to 
 pull everything out and reload the MySQL AB distribution and try again. 
 A quick search shows DBD in dozens of places, in perl/ in DBI/ in 
 mySQL/ etc etc, which ones do I trash?
 

You may have better luck in the [EMAIL PROTECTED] list since OS X likes to do all 
kinds of weird things with its Perl, and with regards to DBI/DBD in [EMAIL PROTECTED]  
Typically removing a Perl module is not as easy as installing them, removing the 
associated files is only one step...

Sorry I can't provide specifics I haven't tried this and don't have my PB with me

http://danconia.org

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



Re: Perl 5.6 Installation for Windows 2003 Server

2003-08-26 Thread zsdc
Smith Jeff D wrote:

I've been looking for help on installing Perl 5.6 for Windows 2003.
I downloaded Activestate's MSI executable but it gets hung up on the Wrong
OS since Acitvestate provides a Windows 2000 but not a 2003 version.  Has
anyone else had this issue and worked around the standard installation from
Activestate? I've posed this to the Activestate support desk too.
You can get the source from CPAN and build it yourself:
http://www.cpan.org/src/README.html
Or you can get prebuilt binaries from many places other than ActiveState:
http://www.cpan.org/ports/index.html#win32
-zsdc.

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


Form Paragraph

2003-08-26 Thread Whippo, Ryan K
I have a form paragraph that once it has more than 1975 characters in
it, the submit button on the form will not work. Any ideas? 

Thank you in advance,
 Ryan Whippo


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



Re: Perl Codes Written in Windows Env

2003-08-26 Thread Bob Showalter
Hanson, Rob wrote:
 ...  Unix uses the sh'bang to determine
 where the Perl binary is, and Unix (not Perl) can't understand the
 carriage-return character.

A minor nit: UNIX understands the CR character perfectly; it simply treats
it as part of the file name, since it's a legal character.



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



Re: rearrange text

2003-08-26 Thread David Wall


--On Monday, August 25, 2003 6:50 PM -0400 Mike Robeson 
[EMAIL PROTECTED] wrote:

OK, I feel like an idiot. When I initially asked for help with this I
just realized that I forgot two little details. I was supposed to add
the number of sequences as well as the length of the sequences at the
top of the output file.
That is this file:

dog
agatagatcgcatcga
cat
acgcttcgatacgctagctta
mouse
agatatacgggtt

is relly supposed to be:

3 22
a g a t a g a t c g c a t c g a - - - - - -dog
a c g c t t c g a t a c g c t a g c t t a -cat
a g a t a t a c g g g t t - - - - - - - - -mouse
The '3' represents the number of individual sequences in the file (i.e.
dog, cat, mouse). And the 22 is the number of letters and dashes there
are. The length is already in the script as $len. I am able to get the
length listed at the top. However, I cannot find a way to have the
number of sequences (the 3 in this case) printed to the top.
Here's one way (slightly altering John's solution), but it will use lots of 
memory if the sequences are long.

#!/usr/bin/perl
use warnings;
use strict;
my ($name, $num_seq, @seq);
my $len = 30;
while ( DATA ) {
   unless ( /^\s*$/ or s/^\s*(\S+)// ) {
   my $name = $1;
   my @char = ( /[acgt]/g, ( '-' ) x $len )[ 0 .. $len - 1 ];
   push @seq, @char$name;
   $num_seq++;
   }
}
{
   local $ =\n;
   print [EMAIL PROTECTED];
}
__DATA__
 dog
agatagatcgcatcga
 cat
acgcttcgatacgctagctta
 mouse
agatatacgggt


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


filling an array

2003-08-26 Thread Anthony J Segelhorst
I am working on script to kill a process if it have been running for 45 
minutes or more.

I am using a pstool called pslist to gather the data on the process.  This 
out put looks like:

C:\Tivoli\lcf\bin\w32-ix86\toolspslist EXCEL

PsList 1.23 - Process Information Lister
Copyright (C) 1999-2002 Mark Russinovich
Sysinternals - www.sysinternals.com

Process information for CRP-DAY1-M73183:

Name  Pid Pri Thd  HndMemUser Time   Kernel Time   Elapsed 
Time
EXCEL4060   8   4  182  15640  0:00:00.190   0:00:00.220 
0:11:22.721

C:\Tivoli\lcf\bin\w32-ix86\tools


I started to build my array by doing:

@temparry = `$lcf_tools\\pslist EXCEL`;
foreach $temp (@temparray){
 ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) = 
split( ,$temp);

This is all wrong though, how I skip down to the line beginning with EXCEL 
to start build my array.


Anthony J Segelhorst
Enterprise Systems Management Team
Email: [EMAIL PROTECTED]


This email has been scanned for all viruses by the MessageLabs SkyScan
service.___

Note:  Please update your email address for this user to reflect the
new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
are in the format of [EMAIL PROTECTED] 

This electronic message contains information from MeadWestvaco
Corporation or subsidiary companies, which may be confidential,
privileged or otherwise protected from disclosure.  The
information is intended to be used solely by the recipient(s)
named.  If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this
transmission or its contents is prohibited.  If you have
received this transmission in error, please notify MeadWestvaco
immediately at [EMAIL PROTECTED]
___

Re: Software Design - Software Management - Project Management

2003-08-26 Thread David Wall


--On Tuesday, August 26, 2003 12:36 AM +0200 Paul Johnson [EMAIL PROTECTED] 
wrote:

You might like to take a look at some of the ideas from XP (that's
extreme programming).  Type that into google and poke around for a bit.
They have some interesting ideas on these topics.  Things that many
people have been doing for years, but are now becoming formalised and
recognised (by some) as good practice.
Here's an interesting place to get lost in: 
http://c2.com/cgi/wiki?ExtremeProgramming

There's a Perl page there, too: http://c2.com/cgi/wiki?PerlLanguage

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


Match min and max chars

2003-08-26 Thread Anthony English
I want to set a minimum and maximum number of characters to a field. I can't
seem to get any value to get the maximum to check.
On the perlretut I read
a{n,m} = match at least n times, but not more than m times. 
If I type in a year of 12345678 I still seem to find a match:
print What year? ; 
$year=;
chomp ($year);   
 # make sure year is at least 2 but not more # than 4 digits
if ($year =~ /\d{2,4}/) {
print year is between 2 and 4 digits\n;
 } else { 
print Error: year should be between 2 and 4 digits.\n;
 }
Anthony English

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



nested parenthesis in regex and launching a new process

2003-08-26 Thread Bryan Harris


Two quick questions for the gurus:

1.  How are nested parenthesis in a match m// backreferenced?  I have a
folder full of files:

file_3.0
file_3.0.1
file_3.0.1a
file_3.0.1b
file_3.0.10
file_3.1
file_3.1.1
file_3.2a

And I want the last one without any letters in the number (not an
alpha/beta).  I have something like this:

$files = join  , file*;
while ( m|(file_\d+(\.\d+)\b)|g ) { $thefile = $1; }

... which seems to work (correctly returns file_3.1.1), but I'm not sure how
the nested parenthesis are supposed to be referenced.  How would I get what
was matched by the inner set?  Is this the best way to do this?

2.  How do I set off a new process, not waiting or caring about any return
values?

$myApp = /proj/mycoolexecutable;
$myOptions = -f -n2 file1 file2;
# execute $myApp. .$myOptions here, and do not wait for any return values


Thanks!

- Bryan



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



MailSender Quotes Problem

2003-08-26 Thread Pablo Fischer
Hi!

I was in a final test of my script and well it fails :-), however I found that 
it fails in the form that Im creating the 'mail sender' object. 

If I do this:
smtp = '$this-{SMTP_SERVER}' (single quotes for elements) 

I get this error when Closing the message:
Can't call method Open without a package or object reference at DemoMail.pm 
line 218. (I have the $sender-Open in line 218)

However, If I do this:

smtp = $this-{SMTP_SERVER} (double quotes for elements)

I dont get error.. but it 'hangs' in the 'Open'  and never send message. I 
need to stop my program with C-c (Linux).

So, what other solutions?

And Example:

my $sender = new Mail::Sender ({
smtp = $this-{SERVER_IP},
from = pablin [EMAIL PROTECTED],
to = $nombre $correo,
subject = $this-{MENSAJE_TITULO},
debug = errores3.txt,
}) or die(chale);
$sender-Open({
encoding = 7bit,
ctype = $tipo,
}) or die(chale);
$sender-SendLineEnc($mensaje) or die($Mail::Sender::Error\n);
$sender-Close() or die($Mail::Sender::Error\n);

Thanks!
Cya!
Pablo
-- 
Pablo Fischer Sandoval ([EMAIL PROTECTED])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

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



Re: MailSender Quotes Problem

2003-08-26 Thread Oliver Schnarchendorf
On Mon, 25 Aug 2003 23:51:47 +, Pablo Fischer wrote: 
   my $sender = new Mail::Sender ({
   smtp = $this-{SERVER_IP},
   from = pablin [EMAIL PROTECTED],
   to = $nombre $correo,
   subject = $this-{MENSAJE_TITULO},
   debug = errores3.txt,
   }) or die(chale);
Hello Pablo,

I have so no idea what is wrong with your example... but you have an extra 
pair of paranthesis around the hash ref that you use for the object initialization 
that isn't shown in any of the examples of the Mail::Sender documentation.

Please give the following a try:

my $sender = new Mail::Sender {
smtp = $this-{SERVER_IP},
from = pablin [EMAIL PROTECTED],
to = $nombre $correo,
subject = $this-{MENSAJE_TITULO},
debug = errores3.txt,
} or die chale;

thanks
/oliver/


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



Re: Match min and max chars

2003-08-26 Thread Oliver Schnarchendorf
On Tue, 26 Aug 2003 14:23:07 +1000, Anthony English wrote:
  # make sure year is at least 2 but not more # than 4 digits
   if ($year =~ /\d{2,4}/) {
Hello Anthony,

it is clear while your regex does match numbers bigger than 4 characters. 
There isn't a minimum set for the maximum value. You are testing for 4 digits. This is 
true even if there are 5, 6 or even 7 digits.

In your case you just need to put boundaries up and everything is fine:

---+++---
#!/usr/bin/perl

use warnings;
use diagnostics;
use strict;

print What year? ; 
chomp (my $year = );

if ($year =~ /^\d{2,4}$/) 
{
print year is between 2 and 4 digits\n;
} 
else 
{ 
print Error: year should be between 2 and 4 digits.\n;
}
---+++---

^ symbolizes the beginning of a string.
$ symbolizes the end of a string.

thanks
/oliver/


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



Re: MailSender Quotes Problem

2003-08-26 Thread Janek Schleicher
Pablo Fischer wrote at Mon, 25 Aug 2003 23:51:47 +:

 I was in a final test of my script and well it fails :-), however I found that 
 it fails in the form that Im creating the 'mail sender' object. 
 
 If I do this:
 smtp = '$this-{SMTP_SERVER}' (single quotes for elements) 
 
 I get this error when Closing the message:
 Can't call method Open without a package or object reference at DemoMail.pm 
 line 218. (I have the $sender-Open in line 218)
 
 However, If I do this:
 
 smtp = $this-{SMTP_SERVER} (double quotes for elements)

I'm not sure what's going on,
but mainly I don't understand why you you quote at all.
What about the simple

   smtp = $this-{SMTP_SERVER}


Greetings,
Janek

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



Re: Perl Codes Written in Windows Env

2003-08-26 Thread SiyandaK
I restored my windows 2000 advanced server, active perl 5.6 and apache 1.3.
After restorating, my post-news script are working but the view_news script
is not working.
When i execute the htm page (on which the view_news script is suppose to
display the news headings) in the browser, the page is blank without any
error message.


Re: Form Paragraph

2003-08-26 Thread Ramprasad A Padmanabhan
Ryan K Whippo wrote:
I have a form paragraph that once it has more than 1975 characters in
it, the submit button on the form will not work. Any ideas? 

Thank you in advance,
 Ryan Whippo
Not a perl question. Do it with Javascript. If you do it after the form 
is submitted It will irritate the users

Ram

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


Re: Changing case of the first letter of words in string

2003-08-26 Thread bis
--- zsdc [EMAIL PROTECTED] wrote:  *Please* CC the mailing
list when you answer. I'm
 writing it so everyone 
 on the list could learn something, not just to fix
 your program or solve 
 your particular problem.
 

thanks for the reminder zsdc - i should have
remembered to cc the list when replying to you.

 bis wrote:
 
  Tnaks zsdc and JEGII.
  
   --- zsdc [EMAIL PROTECTED] wrote:
  
 It gives a syntax error. Maybe try this:
 
#!/usr/bin/perl -p
s/(\s)(.)/$1\u$2/g if/SCTN:/;
  
  This capitalises the first letter of every word in
 the
  whole document.
 
 No, it doesn't. Only the lines containing SCTN:
 Have you run it?

yes i have run it and below is the kind of output i
get (original input all lower case except capitalised
tags and for SCTN: line which is mixed case):

DOCB: 
SRCE: Marketing Week
SCTN: Special Report:pRoMotIons And Incentives
PGNO: 5
HDLN: What
TEXT: 
This Is Text This Is Text This Is Text These Are
Double Spaces This Is Text This Is Text This Is Text
These Are Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
DOCE:

DOCB:
SRCE: Marketing Week
SCTN: Special Report:pRoMotIons And Incentives
PGNO: 5
HDLN: What
TEXT: 
This Is Text This Is Text This Is Text These Are
Double Spaces This Is Text This Is Text This Is Text
These Are Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
This Is Text This Is Text This Is Text These Are
Double Spaces
DOCE:
 
 or instead of /SCTN:/ use /^SCTN:/ 
  
  This doesn't do anything.
  
  or /^\s*SCTN:/ 
  
  Nor does this.
 
 Well... Yes, it does. How did you run it, anyway?

I have the script in the Perl/bin directory because it
does not run if I have it anywhere else. Also I run it
as #!/usr/bin/perl -w because #!/usr/bin/perl -p
freezes my MS-DOS prompt.

The original input is a file called test1.txt and the
output is a file called test3.txt

The whole program is as follows:

#1. path to input and output file
$inputfile = C:/My Documents/Programming/Perl
exercises/test/test1.txt;
$outputfile = C:/My Documents/Programming/Perl
exercises/test/test3.txt;

#2. filehandles
open (INPUT, $inputfile) || die can't open
$testfile;
open (OUTPUT, $outputfile) || die can't open
$testfile;

#initialise $text
$text = ;

#3. read input file into $text
while (INPUT){
$text = $text . $_;
}

# 4) split document by DOCE: string into array of
tags
@stories = split (/DOCB:/, $text);
[EMAIL PROTECTED] is array of each story

for (@stories){
# 5) general substitutions

#Marketing Week substitutions
if (/SRCE:\s*Marketing Week/i) {
#put substitutions here

s/(\s)(.)/$1\u$2/g if/SCTN:/; #uppercases everything

# 6) now put back DOCE: tag into joined up array
$text = join (DOCB:, @stories)
}

# 7) now output file

print OUTPUT $text; 

#close filehandles
close (INPUT);
close (OUTPUT);




 
  I think the title of my query was misleading -
 what I
  maybe should have said was Uppercasing the first
  letter and lowercasing all the other letters of
 every
  word in a mixed case part of a string?
 
 This is much harder. It's easy to make the output
 like this:
 
I'Ve Been Reading O'Reilly Books
 
 OR:
 
I've Been Reading O'reilly Books
 
 but not:
 
I've Been Reading O'Reilly Books
 
 which is correct. I suggest you to only uppercase
 characters, but if you 
 have to also lowercase the other ones then try:
 
#!/usr/bin/perl -p
s/(\s)(\S+)/$1\L\u$2/g if/^\s*SCTN:/;
 
 or
 
#!/usr/bin/perl -p
s/\b(\w+)/\L\u$1/g if/^\s*SCTN:/;
 
 (and maybe add:
 
use locale;

I get no result with any of this.

 
 at the beginning) and see which suits your needs
 better. You might find 
 better examples in the Cookbook.

Thank you. I'll take a look.

-bis
 
 -zsdc.
  


Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/

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



Re: Perl Codes Written in Windows Env

2003-08-26 Thread zsdc
Chuck Fox wrote:

BTW, there is a nifty little program called dos2unix (not sure 
if this is standard for all (*nix)), that removes extraneous carriage 
returns from files.
To remove every CR, use:

  perl -pe 's/\r//'

or even just tr:

  tr -d '\r'

-zsdc.



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


beginner trying to parse a piece of mail

2003-08-26 Thread nntp.perl.org
I have had success now using Mail::MboxParser for all my basic mail parsing
needs, like getting subject, from, to.  Now bossman wants me to do more
extensive regex filtering and grabbing weird data in the email body.

I wrote a little test script, shown below.  I am able to get the
appointment date data, contained in the message body, that I am looking
for, but only for the first record.  The while loop keeps looping back to
that record.  Also, I cannot get to the next line that has the comments
section for each email.  I know this has got to be something stupid I am
not seeing, but after looking at this for so long, everything is starting to
blur together.  Would anyone have any insight as to my mistake?
Thanks, Joan

#!/usr/bin/perl
use Mail::MboxParser;
my $mb=Mail::MboxParser-new('MyMailbox', decode = 'ALL');

#grab data from the body of the message
  while (my $msg = $mb-next_message) {
  $test = $msg-body($msg-find_body) ;
 while (defined($_=$test)) {
  if ($test =~ /App:.*Date:\s+(.{0,8})\s+Time:/) {
 #looking for appointment data here
 print I see the appointment date is $1, \n;
  } elsif ($test =~ /Comments/) {
 while (($test=) !~ /(Notification|XEDB)/) {
 $comments .= $_;
 chop($comments);
 $comments .=  ;
 print The comments are, $comments;
 }#end while ($test=)
  }#end elsif
  }#end while (defined($_=$test)) {
  }#while (my $msg = $mb-next_message)




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



RE: filling an array

2003-08-26 Thread Marcos . Rebelo
try

@temparry = `$lcf_tools\\pslist EXCEL`;
foreach $temp (@temparray){
  next if $temp !~ /EXCEL/;
 ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) = 
split( ,$temp);
...
}


for avoiding errors, use 'strict' module

at beggining of the script do
use strict and define all variables.

MArcos
-Original Message-
From: Anthony J Segelhorst [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 2:32 AM
To: [EMAIL PROTECTED]
Subject: filling an array


I am working on script to kill a process if it have been running for 45 
minutes or more.

I am using a pstool called pslist to gather the data on the process.  This 
out put looks like:

C:\Tivoli\lcf\bin\w32-ix86\toolspslist EXCEL

PsList 1.23 - Process Information Lister
Copyright (C) 1999-2002 Mark Russinovich
Sysinternals - www.sysinternals.com

Process information for CRP-DAY1-M73183:

Name  Pid Pri Thd  HndMemUser Time   Kernel Time   Elapsed 
Time
EXCEL4060   8   4  182  15640  0:00:00.190   0:00:00.220 
0:11:22.721

C:\Tivoli\lcf\bin\w32-ix86\tools


I started to build my array by doing:

@temparry = `$lcf_tools\\pslist EXCEL`;
foreach $temp (@temparray){
 ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) = 
split( ,$temp);

This is all wrong though, how I skip down to the line beginning with EXCEL 
to start build my array.


Anthony J Segelhorst
Enterprise Systems Management Team
Email: [EMAIL PROTECTED]


This email has been scanned for all viruses by the MessageLabs SkyScan
service.___

Note:  Please update your email address for this user to reflect the
new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
are in the format of [EMAIL PROTECTED] 

This electronic message contains information from MeadWestvaco
Corporation or subsidiary companies, which may be confidential,
privileged or otherwise protected from disclosure.  The
information is intended to be used solely by the recipient(s)
named.  If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this
transmission or its contents is prohibited.  If you have
received this transmission in error, please notify MeadWestvaco
immediately at [EMAIL PROTECTED]
___

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



Re: filling an array

2003-08-26 Thread zsdc
Anthony J Segelhorst wrote:

I am working on script to kill a process if it have been running for 45 
minutes or more.

I am using a pstool called pslist to gather the data on the process.  This 
out put looks like:
(...)

I started to build my array by doing:

@temparry = `$lcf_tools\\pslist EXCEL`;
foreach $temp (@temparray){
 ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) = 
split( ,$temp);
Maybe try:

  /^EXCEL/ and @fields = split for `$lcf_tools/pslist EXCEL`;

Also, take a look at Proc::ProcessTable module on CPAN.

-zsdc.



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


Re: beginner trying to parse a piece of mail

2003-08-26 Thread Ramprasad A Padmanabhan
Nntp.Perl.Org wrote:
I have had success now using Mail::MboxParser for all my basic mail parsing
needs, like getting subject, from, to.  Now bossman wants me to do more
extensive regex filtering and grabbing weird data in the email body.
I wrote a little test script, shown below.  I am able to get the
appointment date data, contained in the message body, that I am looking
for, but only for the first record.  The while loop keeps looping back to
that record.  Also, I cannot get to the next line that has the comments
section for each email.  I know this has got to be something stupid I am
not seeing, but after looking at this for so long, everything is starting to
blur together.  Would anyone have any insight as to my mistake?
Thanks, Joan
Not a grave mistake you have just mixed up 'while' and 'if'


#!/usr/bin/perl
use Mail::MboxParser;
my $mb=Mail::MboxParser-new('MyMailbox', decode = 'ALL');
#grab data from the body of the message
  while (my $msg = $mb-next_message) {
  $test = $msg-body($msg-find_body) ;

 while (defined($_=$test)) {
if(defined($_=$test)) {   # This will work But it seems pretty useless
  # Where are u using $_
  #  If just wanted to check $test do that

  if ($test =~ /App:.*Date:\s+(.{0,8})\s+Time:/) {
 #looking for appointment data here
 print I see the appointment date is $1, \n;
  } elsif ($test =~ /Comments/) {
 while (($test=) !~ /(Notification|XEDB)/) {
 $comments .= $_;
 chop($comments);
 $comments .=  ;
 print The comments are, $comments;
 }#end while ($test=)
  }#end elsif
  }#end while (defined($_=$test)) {
# There is your endless loop



  }#while (my $msg = $mb-next_message)





Hope that helps
Ram
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: filling an array

2003-08-26 Thread Rob Dixon

Anthony J Segelhorst [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am working on script to kill a process if it have been running for 45
 minutes or more.

 I am using a pstool called pslist to gather the data on the process.  This
 out put looks like:

 C:\Tivoli\lcf\bin\w32-ix86\toolspslist EXCEL

 PsList 1.23 - Process Information Lister
 Copyright (C) 1999-2002 Mark Russinovich
 Sysinternals - www.sysinternals.com

 Process information for CRP-DAY1-M73183:

 Name  Pid Pri Thd  HndMemUser Time   Kernel Time   Elapsed
 Time
 EXCEL4060   8   4  182  15640  0:00:00.190   0:00:00.220
 0:11:22.721

 C:\Tivoli\lcf\bin\w32-ix86\tools


 I started to build my array by doing:

 @temparry = `$lcf_tools\\pslist EXCEL`;
 foreach $temp (@temparray){
  ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) =
 split( ,$temp);

 This is all wrong though, how I skip down to the line beginning with EXCEL
 to start build my array.

I'm surprised this works at all with double quotes inside your backticks.
Here's how I'd write it.

HTH,

Rob



  use strict;# always
  use warnings;  # usually

  my $lcf_tools;

  my @array = grep /^EXCEL/, `$lcf_tools\\pslist EXCEL`;
  chomp @array;

  foreach (@temparray) {
my ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) = split;
  }




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



Do i run a script with do{} or make it a module? Opinions.

2003-08-26 Thread zanardi2k3
Hello, not a technical problem, i'm just looking for opinions.

Using Archive::Zip, i made a script with the main purpose of making a 
quick backup of a folder and all its subfolders in a zip file.

The script can take a few parameters:
- the main folder backup (mandatory);
- the full path of the destination zip file (mandatory);
- filename pattern (regex) of files to include;
- min or max modified age of files to include;
- a delete flag that tell the script if it has to unlink the files 
after archiving.

Since we have many folders with many small text files, now i want to use 
it to compress older files and delete them from disks, so that they're 
still available for a while, but don't take as much space as before.

That poses the problem of executing my script for several folders, with 
different parameters for each of them. Now i'm wondering if i have to 
include the possibility of multiple backups in the script itself, if i 
better write another script that calls this one with different parameters 
each time, or if i better make a module of my original script (though it 
seems too much, since it's not code reuse but just script relaunching).

I'd like to know your thoughts about this.

-- 
Zanardi2k3

Why do i need you, feet, when i have wings to fly?
(Frida Kahlo)

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



regexp

2003-08-26 Thread Anton Arhipov
Hi,

i've a string like BLAH (guotes included).
i need to control if the BLAH is in uppercase and then if it is in 
uppercase truncate the quotes (), so BLAH becomes BLAH.

any solutions?

Thx



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


Re: filling an array

2003-08-26 Thread Rob Dixon
Zsdc wrote:

 Anthony J Segelhorst wrote:

  I am working on script to kill a process if it have been running for 45
  minutes or more.
 
  I am using a pstool called pslist to gather the data on the process.  This
  out put looks like:
  (...)
 
  I started to build my array by doing:
 
  @temparry = `$lcf_tools\\pslist EXCEL`;
  foreach $temp (@temparray){
   ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) =
  split( ,$temp);

 Maybe try:

/^EXCEL/ and @fields = split for `$lcf_tools/pslist EXCEL`;

This is the same as

  foreach ( `$lcf_tools/pslist EXCEL` ) {
@fields = split if /^EXCEL/;
  }

but IMO less clear.

 Also, take a look at Proc::ProcessTable module on CPAN.

This module is for Unix processes. It looks like Anthony is on Windows
with backslashes in the path.

Cheers,

Rob



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



Re: beginner trying to parse a piece of mail

2003-08-26 Thread Tassilo von Parseval
On Mon, Aug 25, 2003 at 05:19:14PM -0700 nntp.perl.org wrote:

 I have had success now using Mail::MboxParser for all my basic mail parsing
 needs, like getting subject, from, to.  Now bossman wants me to do more
 extensive regex filtering and grabbing weird data in the email body.
 
 I wrote a little test script, shown below.  I am able to get the
 appointment date data, contained in the message body, that I am looking
 for, but only for the first record.  The while loop keeps looping back to
 that record.  Also, I cannot get to the next line that has the comments
 section for each email.  I know this has got to be something stupid I am
 not seeing, but after looking at this for so long, everything is starting to
 blur together.  Would anyone have any insight as to my mistake?

You want to loop over the lines of the body, right?

 #!/usr/bin/perl
 use Mail::MboxParser;
 my $mb=Mail::MboxParser-new('MyMailbox', decode = 'ALL');
 
 #grab data from the body of the message
   while (my $msg = $mb-next_message) {
   $test = $msg-body($msg-find_body) ;
  while (defined($_=$test)) {

That's an infinite loop. If you want to iterate over the lines of a
body, try

for ($test-as_lines) {
# each line now in $_
if (/App:.*Date:\s+(.{0,8})\s+Time:/) {
...
} 
else if (/Comments/) {
...
}

   if ($test =~ /App:.*Date:\s+(.{0,8})\s+Time:/) {
  #looking for appointment data here
  print I see the appointment date is $1, \n;
   } elsif ($test =~ /Comments/) {
  while (($test=) !~ /(Notification|XEDB)/) {

What should this while-loop achieve?  reads from STDIN. I am sure you
don't want that.

  $comments .= $_;
  chop($comments);
  $comments .=  ;
  print The comments are, $comments;
  }#end while ($test=)
   }#end elsif
   }#end while (defined($_=$test)) {
   }#while (my $msg = $mb-next_message)

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


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



redirecting the output of a command to a file

2003-08-26 Thread Ivan Novick
Hi,

does anyone know syntax to run a command and redirect its output directly to
a file?

Equivalent to myCommand  myFile in shell

Thanks,

Ivan


RE: redirecting the output of a command to a file

2003-08-26 Thread Marcos . Rebelo
system(myCommand  myFile);
must work

-Original Message-
From: Ivan Novick [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 1:11 PM
To: [EMAIL PROTECTED]
Subject: redirecting the output of a command to a file


Hi,

does anyone know syntax to run a command and redirect its output directly to
a file?

Equivalent to myCommand  myFile in shell

Thanks,

Ivan

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



Re: regexp

2003-08-26 Thread Ramprasad A Padmanabhan
Anton Arhipov wrote:
Hi,

i've a string like BLAH (guotes included).
i need to control if the BLAH is in uppercase and then if it is in 
uppercase truncate the quotes (), so BLAH becomes BLAH.

any solutions?

Thx


You mean If you find any upper case word within quotes remove quotes right ?

$str = 'abc BLAH aaa eef ';
print $str\n;
$str=~s/\([^\]+)\/{(uc($1) eq $1)?$1:\$1\;}/ge;
print $str\n;
This should work
Ram






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


RE: redirecting the output of a command to a file

2003-08-26 Thread Ivan Novick
Is there no other way some perl syntax to redirect to a file the output of a
command?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 7:14 AM
To: Ivan Novick; [EMAIL PROTECTED]
Subject: RE: redirecting the output of a command to a file


system(myCommand  myFile);
must work

-Original Message-
From: Ivan Novick [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 1:11 PM
To: [EMAIL PROTECTED]
Subject: redirecting the output of a command to a file


Hi,

does anyone know syntax to run a command and redirect its output directly to
a file?

Equivalent to myCommand  myFile in shell

Thanks,

Ivan


RE: redirecting the output of a command to a file

2003-08-26 Thread Marcos . Rebelo
What is your real problem?
 
open(IN, myCommand |);
open(OUT, $outputFileName);
print OUT join(, IN);
close OUT;
close IN;
 
 

-Original Message-
From: Ivan Novick [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 1:47 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: redirecting the output of a command to a file



Is there no other way some perl syntax to redirect to a file the output of a
command? 

-Original Message- 
From: [EMAIL PROTECTED] [ mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ] 
Sent: Tuesday, August 26, 2003 7:14 AM 
To: Ivan Novick; [EMAIL PROTECTED] 
Subject: RE: redirecting the output of a command to a file 


system(myCommand  myFile); 
must work 

-Original Message- 
From: Ivan Novick [ mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ] 
Sent: Tuesday, August 26, 2003 1:11 PM 
To: [EMAIL PROTECTED] 
Subject: redirecting the output of a command to a file 


Hi, 

does anyone know syntax to run a command and redirect its output directly to

a file? 

Equivalent to myCommand  myFile in shell 

Thanks, 

Ivan 


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



Re: filling an array

2003-08-26 Thread Rob Dixon
Marcos Rebelo wrote:
 try

 @temparry = `$lcf_tools\\pslist EXCEL`;
 foreach $temp (@temparray){
   next if $temp !~ /EXCEL/;
  ($name,$pid,$pri,$thd,$hnd,$Mem,$usertime,$kerneltime,$elapsedtime) =
 split( ,$temp);
 ...
 }

Better would be

  next if $temp !~ /^EXCEL/;

which is 'doesn't start with' instead of 'doesn't contain'.

 for avoiding errors, use 'strict' module

Absolutely. Yes. (applause). :)

Rob



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



Re: Do i run a script with do{} or make it a module? Opinions.

2003-08-26 Thread Rob Dixon
Zanardi2k3 wrote:

 Hello, not a technical problem, i'm just looking for opinions.

 Using Archive::Zip, i made a script with the main purpose of making a
 quick backup of a folder and all its subfolders in a zip file.

 The script can take a few parameters:
 - the main folder backup (mandatory);
 - the full path of the destination zip file (mandatory);
 - filename pattern (regex) of files to include;
 - min or max modified age of files to include;
 - a delete flag that tell the script if it has to unlink the files
 after archiving.

 Since we have many folders with many small text files, now i want to use
 it to compress older files and delete them from disks, so that they're
 still available for a while, but don't take as much space as before.

 That poses the problem of executing my script for several folders, with
 different parameters for each of them. Now i'm wondering if i have to
 include the possibility of multiple backups in the script itself, if i
 better write another script that calls this one with different parameters
 each time, or if i better make a module of my original script (though it
 seems too much, since it's not code reuse but just script relaunching).

 I'd like to know your thoughts about this.

Hi Zanardi2k3. :)

Your question is too long. For that reason you will get fewer
answers. My advice is to repost with more code and
environmental details and less explanation. We don't need to know
'why' or 'how' but only 'what' to help :)

My first answer would be to recode what you already have to perform
the new task. I doubt that making modules would help, but I would
discourage calling one Perl script from another.

More help when you can identify a problem!

HTH,

Rob







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



Re: redirecting the output of a command to a file

2003-08-26 Thread Rob Dixon

Marcos Rebelo wrote:

 What is your real problem?


Exactly. Using Perl as an agent to simply run a
program and record its output is misuse. Just
use a shell script.

What are you trying to do?

/R





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



RE: Perl Codes Written in Windows Env

2003-08-26 Thread Dan Muey
 I restored my windows 2000 advanced server, active perl 5.6 
 and apache 1.3. After restorating, my post-news script are 
 working but the view_news script is not working. When i 
 execute the htm page (on which the view_news script is 
 suppose to display the news headings) in the browser, the 
 page is blank without any error message.
 

So you're using ssi then and the script is not executed from an ssi tag?
How about if you run it directly? (assuming it puts out the proper headers)
Is the server configured to use ssi?
What tags does it require?
What extension does it require?
Is your script execuatable/permissions ok?

All questions your server admin will have to answer.

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



Re: MailSender Quotes Problem

2003-08-26 Thread Pablo Fischer
I think it was the hour and time..

Cause now im checking what does $this-{SERVER_IP} contains and it contains an 
ip 192.168.1.43 and I dont have that computer (just from .1 to .4) and thats 
why I was hanging up :-(

Sorry and thanks!
Pablo
El día Monday 25 August 2003 11:51 a Pablo Fischer mandó el siguiente correo:
 Hi!

 I was in a final test of my script and well it fails :-), however I found
 that it fails in the form that Im creating the 'mail sender' object.

 If I do this:
 smtp = '$this-{SMTP_SERVER}' (single quotes for elements)

 I get this error when Closing the message:
 Can't call method Open without a package or object reference at
 DemoMail.pm line 218. (I have the $sender-Open in line 218)

 However, If I do this:

 smtp = $this-{SMTP_SERVER} (double quotes for elements)

 I dont get error.. but it 'hangs' in the 'Open'  and never send message. I
 need to stop my program with C-c (Linux).

 So, what other solutions?

 And Example:

   my $sender = new Mail::Sender ({
   smtp = $this-{SERVER_IP},
   from = pablin [EMAIL PROTECTED],
   to = $nombre $correo,
   subject = $this-{MENSAJE_TITULO},
   debug = errores3.txt,
   }) or die(chale);
   $sender-Open({
   encoding = 7bit,
   ctype = $tipo,
   }) or die(chale);
   $sender-SendLineEnc($mensaje) or die($Mail::Sender::Error\n);
   $sender-Close() or die($Mail::Sender::Error\n);

 Thanks!
 Cya!
 Pablo
 --
 Pablo Fischer Sandoval ([EMAIL PROTECTED])
 http://www.pablo.com.mx
 http://www.debianmexico.org
 GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
 Firma URL: http://www.pablo.com.mx/firmagpg.txt

-- 
Pablo Fischer Sandoval ([EMAIL PROTECTED])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

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



Full path to the perl intrepter

2003-08-26 Thread Marcos . Rebelo
I'm in a very old project and my scripts are calling other scripts. I have 3
or 4 different perl version in the server. I need to call the sub-scripts
with the some version of perl that I'm using in the caller script.

How to find the full path to the perl interpter that is being used?

Thanks
MArcos

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



RE: Full path to the perl intrepter

2003-08-26 Thread Paul Kraus
If its in a UNIX env then just look at the she bang line :)

#!/usr/bin/perl 

Then you could go to usr bin and see where perl is linked to.

If you have scripts that have a different line then just use perl to
search and replace with the correct line.

Paul

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Sent: Tuesday, August 26, 2003 10:13 AM
To: [EMAIL PROTECTED]
Subject: Full path to the perl intrepter


I'm in a very old project and my scripts are calling other scripts. I
have 3 or 4 different perl version in the server. I need to call the
sub-scripts with the some version of perl that I'm using in the caller
script.

How to find the full path to the perl interpter that is being used?

Thanks
MArcos

-- 
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: Full path to the perl interpreter

2003-08-26 Thread Marcos . Rebelo
the script are being called like 

/usr/local/bin/perl5.8.0/bin/perl -w /proj/xpto.pl

I need the /usr/local/bin/perl5.8.0/bin/perl

The usual path is for a older version in this case. The perl path is in a
database that I don't see and I don't want to pass the perl path to the
script. That will be the answer if anything else works.

Marcos

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 4:19 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Full path to the perl intrepter


If its in a UNIX env then just look at the she bang line :)

#!/usr/bin/perl 

Then you could go to usr bin and see where perl is linked to.

If you have scripts that have a different line then just use perl to
search and replace with the correct line.

Paul

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Sent: Tuesday, August 26, 2003 10:13 AM
To: [EMAIL PROTECTED]
Subject: Full path to the perl intrepter


I'm in a very old project and my scripts are calling other scripts. I
have 3 or 4 different perl version in the server. I need to call the
sub-scripts with the some version of perl that I'm using in the caller
script.

How to find the full path to the perl interpter that is being used?

Thanks
MArcos

-- 
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: Full path to the perl intrepter

2003-08-26 Thread Tassilo von Parseval
On Tue, Aug 26, 2003 at 04:12:59PM +0200 [EMAIL PROTECTED] wrote:
 I'm in a very old project and my scripts are calling other scripts. I have 3
 or 4 different perl version in the server. I need to call the sub-scripts
 with the some version of perl that I'm using in the caller script.
 
 How to find the full path to the perl interpter that is being used?

See the entry on $^X in perlvar.pod. Probably this will already do for
you:

use Config;
my $real_perl = $Config{perlpath};

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


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



RE: Full path to the perl intrepter

2003-08-26 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
 I'm in a very old project and my scripts are calling other scripts. I
 have 3 or 4 different perl version in the server. I need to call the
 sub-scripts with the some version of perl that I'm using in the
 caller script. 
 
 How to find the full path to the perl interpter that is being used?

use Config;
my $interpreter = $Config{perlpath};

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



Length() is bits/bytes or neither

2003-08-26 Thread Dan Muey
I know that the number returned by the length function is the number of characters.
With ascii text is that the bits or bytes also?

If not is there a function similar to length() that tells you the bits or bytes of a 
string or a way to figure that with the return value of length?

TIA

Dan

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



RE: pronunciation guide

2003-08-26 Thread McMahon, Christopher x66156

On a Tandem, all processes begin with $.  As in: $WRITER is
writing to the file; $BILL is the process that monitors the bank balance. 
You'll definitely confuse Tandem people if you call the dollar sign
string. 
-Chris

-Original Message-
From: George Schlossnagle [mailto:[EMAIL PROTECTED]
Sent: Monday, August 25, 2003 8:31 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: pronunciation guide


On Monday, August 25, 2003, at 10:28  AM, Paul Kraus wrote:

 Wow. I find that unusual in my 10 years of computer use/programming ..
 I have always referred to $ and heard it referred to as string.

 Not that it matters but I find that definitely unusual :)

I've been to a number of conferences as well and never heard anyone 
refer to $anything as anything other than 'dollar anything'.

George

_
This message and any attachments are intended only for the use of the addressee and
may contain information that is privileged and confidential. If the reader of the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.


RE: Length() is bits/bytes or neither

2003-08-26 Thread Hanson, Rob
length() returns the length in characters, which for ASCII is also the
number of bytes.  To get the bits, just multiply by 8.

If you are using a Unicode character set instead, I'm not too sure what will
be returned, or how you can convert it to bits.

Rob

-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2003 11:30 AM
To: [EMAIL PROTECTED]
Subject: Length() is bits/bytes or neither


I know that the number returned by the length function is the number of
characters.
With ascii text is that the bits or bytes also?

If not is there a function similar to length() that tells you the bits or
bytes of a string or a way to figure that with the return value of length?

TIA

Dan

-- 
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: Length() is bits/bytes or neither

2003-08-26 Thread James Edward Gray II
On Tuesday, August 26, 2003, at 10:29  AM, Dan Muey wrote:

I know that the number returned by the length function is the number 
of characters.
With ascii text is that the bits or bytes also?
Can't fit a character in a 1 or a 0, so I think we can safely rule out 
it being the bits.  I would assume it is the bytes, for ASCII text, yes.

James

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


RE: Length() is bits/bytes or neither

2003-08-26 Thread Dan Muey
Yeah I did a test where I put the data I was using in length() into afile then did 
du-sh on the file.

Where length() gave me 1048576 the du -sh on the file said 1.0 MB

So length() returns bytes and so length() * 8 is the bits and length() / 1024 is the 
Kilobytes I believe.

Thanks for the replies everyone!

Dan

 -Original Message-
 From: Dan Muey 
 Sent: Tuesday, August 26, 2003 10:30 AM
 To: [EMAIL PROTECTED]
 Subject: Length() is bits/bytes or neither
 
 
 I know that the number returned by the length function is the 
 number of characters. With ascii text is that the bits or bytes also?
 
 If not is there a function similar to length() that tells you 
 the bits or bytes of a string or a way to figure that with 
 the return value of length?
 
 TIA
 
 Dan
 
 -- 
 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: Changing case of the first letter of words in string

2003-08-26 Thread zsdc
bis wrote:

 #!/usr/bin/perl -p
 s/(\s)(.)/$1\u$2/g if/SCTN:/;
This capitalises the first letter of every word in 
the whole document.
No, it doesn't. Only the lines containing SCTN:
Have you run it?
yes i have run it and below is the kind of output i
get (original input all lower case except capitalised
tags and for SCTN: line which is mixed case):
[...]

or instead of /SCTN:/ use /^SCTN:/ 
This doesn't do anything.

or /^\s*SCTN:/ 

Nor does this.
Well... Yes, it does. How did you run it, anyway?
I have the script in the Perl/bin directory because it
does not run if I have it anywhere else. Also I run it
as #!/usr/bin/perl -w because #!/usr/bin/perl -p
freezes my MS-DOS prompt.
So you have changed my program, removing the -p switch. Have you read 
about the switch you removed? See perlrun(1) manpage: 
http://www.perldoc.com/perl5.8.0/pod/perlrun.html#-p

   -p   causes Perl to assume the following loop around your
program, which makes it iterate over filename argu­-
ments somewhat like sed:
  LINE:
while () {
... # your program goes here
} continue {
print or die -p destination: $!\n;
}
[...]

I have no experience with Perl under DOS, so it might be related to CRLF 
or some other issues as well, but just in case, did you run my program as:

  program input.txt  output.txt

or in some different way? It's a filter, so it reads its input on STDIN 
or from files given as arguments, and prints the output on STDOUT. Read 
about the diamond operator (the null filehandle) in perlop(1) manpage:
http://www.perldoc.com/perl5.8.0/pod/perlop.html#I-O-Operators

The original input is a file called test1.txt and the
output is a file called test3.txt
The whole program is as follows:
[...]
You can't put part of my program anywhere into your code to make it do 
whatever you want (even Perl has a DWIM-wise limit). It only works in 
the same context, i.e. when it's executed for every line of input, 
having a single line of input in $_ every time it is run.

I suggest you to only uppercase
characters, but if you 
have to also lowercase the other ones then try:

  #!/usr/bin/perl -p
  s/(\s)(\S+)/$1\L\u$2/g if/^\s*SCTN:/;
or

  #!/usr/bin/perl -p
  s/\b(\w+)/\L\u$1/g if/^\s*SCTN:/;
(and maybe add:

  use locale;
I get no result with any of this.
Of course you don't get any results if you remove the -p switch which is 
absolutely essential for such a filter. Every program I wrote for you is 
correct, but when you change them, they obviously might stop being 
correct any more.

-zsdc.



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


Re: Do i run a script with do{} or make it a module? Opinions.

2003-08-26 Thread Jenda Krynicky
From: zanardi2k3 [EMAIL PROTECTED]
 That poses the problem of executing my script for several folders,
 with different parameters for each of them. Now i'm wondering if i
 have to include the possibility of multiple backups in the script
 itself, if i better write another script that calls this one with
 different parameters each time, or if i better make a module of my
 original script (though it seems too much, since it's not code reuse
 but just script relaunching).

IMHO it'd be best to wrap the code of the script in a subroutine that 
gets the info from its parameters instead of ARGV and then call this 
subroutine either once (so that you get the old behaviour) or several 
times with different parameters.

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: MailSender Quotes Problem

2003-08-26 Thread Jenda Krynicky
To: Pablo Fischer [EMAIL PROTECTED]
 On Mon, 25 Aug 2003 23:51:47 +, Pablo Fischer wrote: 
  my $sender = new Mail::Sender ({
  smtp = $this-{SERVER_IP},
  from = pablin [EMAIL PROTECTED],
  to = $nombre $correo,
  subject = $this-{MENSAJE_TITULO},
  debug = errores3.txt,
  }) or die(chale);
 Hello Pablo,
 
  I have so no idea what is wrong with your example... but you have an
  extra pair of paranthesis around the hash ref that you use for the
  object initialization that isn't shown in any of the examples of the
  Mail::Sender documentation.
 
  Please give the following a try:
 
 my $sender = new Mail::Sender {
  smtp = $this-{SERVER_IP},
   from = pablin [EMAIL PROTECTED],
   to = $nombre $correo,
   subject = $this-{MENSAJE_TITULO},
   debug = errores3.txt,
 } or die chale;

Those parens make no difference.

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: nested parenthesis in regex and launching a new process

2003-08-26 Thread zsdc
Bryan Harris wrote:

... which seems to work (correctly returns file_3.1.1), but I'm not sure how
the nested parenthesis are supposed to be referenced.  How would I get what
was matched by the inner set?  Is this the best way to do this?
Everything is captured in $1, $2, $3... in the order of opening 
parenthesis, from left to right.

2.  How do I set off a new process, not waiting or caring about any return
values?
$myApp = /proj/mycoolexecutable;
$myOptions = -f -n2 file1 file2;
# execute $myApp. .$myOptions here, and do not wait for any return values
See:
  perldoc -f fork
  perldoc -f exec
-zsdc.



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


Re: Length() is bits/bytes or neither

2003-08-26 Thread zsdc
Hanson, Rob wrote:

length() returns the length in characters, which for ASCII is also the
number of bytes.  To get the bits, just multiply by 8.
If you are using a Unicode character set instead, I'm not too sure what will
be returned, or how you can convert it to bits.
  #!/usr/bin/perl -wl
  use utf8;
  sub bytes ($) {
  use bytes;
  length $_[0];
  }
  $x = chr 123456;
  print length $x,  chars;
  print bytes $x,  bytes;
-zsdc.



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


Outputting the status while the processes are running

2003-08-26 Thread T.S.Ravi Shankar
Hi all :

 I need to run a process for thousands of (known number) of
combinations  of the settings needed for the process to run. I have the
settings in different arrays  I am running the process as shown below
:  I would like to see the status after every 50 runs in a separate
file.  But the following code doesn't look like outputting any thing to
the statusfile,  when the processes are going on for different
combinations.  How can I achieve that ???  What mistakes I am committing
here ??


open(STATUS,statusfile)
foreach $set1 (@arr1) {
foreach $set2 (@arr2) {
..
..
foreach $set15 (@arr15) {
ENV{xxx} = $set1;
..
.
ENV{ccc} = $set15;
$counter++; # counter for the number of combinations
if (($counter % 50) ==0)  { genstatus; }
$pid = fork;
if($pid == 0) {
  exec(PROCESS);
}else{
  $pid1=wait;
}




sub genstatus {

 Print STATUS  \n $counter iterations over \n;

}


Thanks.
Ravi


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



Re: nested parenthesis in regex and launching a new process

2003-08-26 Thread harrisb

 2.  How do I set off a new process, not waiting or caring about any
 return values?

 $myApp = /proj/mycoolexecutable;
 $myOptions = -f -n2 file1 file2;
 # execute $myApp. .$myOptions here, and do not wait for any return
 values

 See:
   perldoc -f fork
   perldoc -f exec


Thanks for replying zsdc.  The $1,$2 thing makes perfect sense now.

As for the fork/exec thing, those pages are a little over my head.  I
don't understandhow process signals and pipes work.

Really, all I want the perl script to do is the equivalent of typing $myApp.
.$myOptions at the command line, sending its output to STDOUT.  This
script readsin all input files passed to it, determines which executable applies to
each, andlaunches that executable with that file as a parameter.  It may need to
launch 5 or 6processes, but I want it to gracefully exit when it's done launching and
not wait tillthose processes finish.  Does that make sense?  Is that even possible?

Thanks again.

- Bryan






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



Re: Do i run a script with do{} or make it a module? Opinions.

2003-08-26 Thread Rob Dixon
Jenda wrote:

 From: zanardi2k3 [EMAIL PROTECTED]
  That poses the problem of executing my script for several folders,
  with different parameters for each of them. Now i'm wondering if i
  have to include the possibility of multiple backups in the script
  itself, if i better write another script that calls this one with
  different parameters each time, or if i better make a module of my
  original script (though it seems too much, since it's not code reuse
  but just script relaunching).

 IMHO it'd be best to wrap the code of the script in a subroutine that
 gets the info from its parameters instead of ARGV and then call this
 subroutine either once (so that you get the old behaviour) or several
 times with different parameters.


Thanks Jenda.

The old 'wrap or rewrite' problem.

MO is to rewrite. Always. unless you have an 'infinite number of
monkeys' or your source is massive. Most will disagree.

/R





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



Re: Process Timestamp?

2003-08-26 Thread david
Jeremy Jones wrote:

 Hello World!
 
 I'm looking for a way to check a Processes age (how long it's been
 running). Is there a way to do this without installing extra modules?
 I know ps-ef does it, I was hoping for elegance over the hammer 
 chisel...
 

one way of doing that is to interface the /proc process table if you don't 
want to install extra modules. here is a simple example of what you can do 
to get the running time of your script:

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

#--
#-- ask the process table to give me my own process info
#--
open(PROC,'/proc/self/stat') || die(error but why? $!\n);

while(1){

#--
#-- generate some CPU activity
#--
my $p; $p = sqrt($$) * $_ for(1..30);

#--
#-- gets the process time so far. more on that later
#--
my $time = (split(/\s+/,PROC))[13] * 0.01 / 100;

#--
#-- process ID and the how long it has been running in user mode
#--
print $$: $time\n;

#--
#-- rewind and get ready for the next read
#--
seek(PROC,0,0);

#--
#-- just to avoid printing too much too fast to the screen
#--
sleep(1);
}

close(PROC);

__END__

prints:

2845: 0.0065
2845: 0.013
2845: 0.0194
2845: 0.0259
2845: 0.0323
2845: 0.0387
...
^C

note:

* open /proc/self/stat simply ask the kernel for information about the 
current process that's running. 'self' points to its own process and 'stat' 
gives you information about the running process. there are tons of 
information that 'stat' returns but we will be concentrated on just one.

* this line:

my $time = (split(/\s+/,PROC))[13] * 0.01 / 100;
  
asks the kernel to give you updated information about the current process 
(in this case, it's our own process) that's running. we split the line into 
chunks and the 14th element gives us the number of jiffies that this 
process and its children have been scheduled in user mode. i don't know how 
familiar you are with the kernel (or kernel programming) but a jiffies is 
basically 100 millisconds for most platform (except for Alpha (which sets 
it to 1024, i believe) and Real Time Linux (which sets it to 100,000)). the 
'* 0.01 / 100' simply converts it to seconds. this, of course, is not very 
accurate becauser you can simply change the jiffies on your system and 
recompile your kernel. the split on white space is also bugous but for this 
example, let's assume it's correct. for more, check out 'man proc'

* if you run the above script and 'top -p 2845' side by side at the same 
time, you will notice they both report very similiar result. this is no 
surprise because 'top' (as well as 'ps' and Proc::ProcssTable) is 
implemented using the same '/proc' process table with similar technique.

* the above script is very efficient because it directly goes to the process 
table for the info it needs thus avoid using a shell (such as parsing the 
output of 'ps' or 'top') or walking the whole process table (such as 
Proc::ProcessTable). 

david

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



Re: regexp

2003-08-26 Thread Janek Schleicher
Anton Arhipov wrote at Tue, 26 Aug 2003 13:02:00 +0300:

 i've a string like BLAH (guotes included).
 i need to control if the BLAH is in uppercase and then if it is in 
 uppercase truncate the quotes (), so BLAH becomes BLAH.

s/([A-Z]+)/$1/g;

or on a POSIX operating system I would prefer the more appropriate
character class

s/([[:upper:]]+)/$1/g;


Greetings,
Janek

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