delete from java temporary file generated from PERL

2007-06-29 Thread Tatiana Lloret Iglesias

Hi all!


From my Java application I call a PERL process which generates some files.


When I come back to the Java part and I process these files I try to delete
them and some of them are deleted correctly but other not...

Any idea?

I've checked that I call CLOSE methods everytime I create a file in PERL

Hint: I've noticed that big files are deleted correctlty perhaps because I
spend more time processing them before trying to delete them ...

Thanks!!
T


exit code

2007-06-29 Thread Tatiana Lloret Iglesias

Hi all,

when I execute my perl script in my local machine and I get to a controlled
error situation i've got as exit value 777

if(!$test){
   $failed_times =$failed_times +1;

   if($failed_times ==3)
   {
exit(777);
   }
   sleep 15;
  }# if $test

but when i execute the same script with the same controlled error situation
I've got as exit value 9 which seems a generic error code

Any idea ?

Thanks!
T


Re: exit code

2007-06-29 Thread Paul Johnson
On Fri, Jun 29, 2007 at 11:08:19AM +0200, Tatiana Lloret Iglesias wrote:

> Hi all,
> 
> when I execute my perl script in my local machine and I get to a controlled
> error situation i've got as exit value 777
> 
> if(!$test){
>$failed_times =$failed_times +1;
> 
>if($failed_times ==3)
>{
> exit(777);
>}
>sleep 15;
>   }# if $test
> 
> but when i execute the same script with the same controlled error situation
> I've got as exit value 9 which seems a generic error code
> 
> Any idea ?

Exit statuses are stored in eight bits.

> Thanks!

You're welcome.

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: exit code

2007-06-29 Thread Tatiana Lloret Iglesias

Sorry.. but I don't understand what do you mean ...



On 6/29/07, Paul Johnson <[EMAIL PROTECTED]> wrote:


On Fri, Jun 29, 2007 at 11:08:19AM +0200, Tatiana Lloret Iglesias wrote:

> Hi all,
>
> when I execute my perl script in my local machine and I get to a
controlled
> error situation i've got as exit value 777
>
> if(!$test){
>$failed_times =$failed_times +1;
>
>if($failed_times ==3)
>{
> exit(777);
>}
>sleep 15;
>   }# if $test
>
> but when i execute the same script with the same controlled error
situation
> I've got as exit value 9 which seems a generic error code
>
> Any idea ?

Exit statuses are stored in eight bits.

> Thanks!

You're welcome.

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



Re: exit code

2007-06-29 Thread Martin Barth
exit codes are stored in 1 byte. so you can only exit with
2^8 == 256 different values.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: exit code

2007-06-29 Thread Tatiana Lloret Iglesias

And why i windows I get exit value 777?

On 6/29/07, Martin Barth <[EMAIL PROTECTED]> wrote:


exit codes are stored in 1 byte. so you can only exit with
2^8 == 256 different values.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





Re: using a homemade perl module

2007-06-29 Thread Mumia W.

On 06/28/2007 10:22 PM, Mathew Snyder wrote:


I'm getting a strange bit of behaviour.  I have everything set up right and my 
dates are getting made up properly however, one sub which creates the searchDate 
array isn't being called.  I have to enter the full module path 
(Reports::Dates::searchDate) for it to work while all of the other dates are 
called without problem using just the sub name.  Any thoughts on why this might be?




It works for me. People can only guess at the problem you're having 
because you didn't show the program that is failing.


Also, the functions in Reports/Dates.pm are undocumented.




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: parse help

2007-06-29 Thread [EMAIL PROTECTED]
> I would suggest splitting each record on "\n", looping
> over the results checking to see if the first character is a space,
> and appending that line to the last field if it is or creating a new
> key/value pair if it isn't.

thank you. Would you mind posting sample code that does this trick?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread [EMAIL PROTECTED]
Hi all,

Any help on this would be appreciated :)

Currently I have a perl program thats required to call another perl
program. The second one takes arguments and can be called as:

perl vplan_all.pl 5.6 24.0 ajtest

Here 5.6, 24.0 and ajtest are all command line options.

I have to call this from a second program that i wrote. I tried the
call as below -

  system( "perl vplan_all.pl 5.6 24.0")
or die "Couldn't run the vplan_all.pl script: $!\n";

However, this doesn't seem to work. The shell reports that perl can't
find the file. However, when i simply try with -

  system( "perl vplan_all.pl")
or die "Couldn't run the vplan_all.pl script: $!\n";

The script is now called and i get the result -

  vp_all: USAGE: perl vplan_all.pl  


which is the expected behaviour when no options are provided.
So apparently the shell calls perl and passes the entire "perl
vplan_all.pl 5.6 24.0" as a chunk. Perl can't then seem to
differentiate between the code name and the options.

I've tried bypassing the shell [ system(xxx,xxx,xx)] but that doesn't
seem to help.

Please do point out any ideas on this one.
Thx in advance!
Alex Jamestin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Steve Bertrand
[EMAIL PROTECTED] wrote:
> Hi all,
> 
> Any help on this would be appreciated :)
> 
> Currently I have a perl program thats required to call another perl
> program. The second one takes arguments and can be called as:
> 
> perl vplan_all.pl 5.6 24.0 ajtest
> 
> Here 5.6, 24.0 and ajtest are all command line options.
> 
> I have to call this from a second program that i wrote. I tried the
> call as below -
> 
>   system( "perl vplan_all.pl 5.6 24.0")
> or die "Couldn't run the vplan_all.pl script: $!\n";
> 
> However, this doesn't seem to work. The shell reports that perl can't
> find the file. However, when i simply try with -
> 
>   system( "perl vplan_all.pl")
> or die "Couldn't run the vplan_all.pl script: $!\n";
> 
> The script is now called and i get the result -
> 
>   vp_all: USAGE: perl vplan_all.pl  
> 
> 
> which is the expected behaviour when no options are provided.
> So apparently the shell calls perl and passes the entire "perl
> vplan_all.pl 5.6 24.0" as a chunk. Perl can't then seem to
> differentiate between the code name and the options.
> 
> I've tried bypassing the shell [ system(xxx,xxx,xx)] but that doesn't
> seem to help.

If vplan_all.pl is in fact it's own application, try calling it without
calling Perl first:

system("/path/to/program/vp_all.pl arg1 arg2") or die "blah blah: $!";

BTW, AFAIR, inserting a \n after the $! will negate the $!, but I may be
mistaken.

Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




pp utility

2007-06-29 Thread kusu
Hi,

Can any one help me in analyzing this code

system(pp -o abc.exe --icon=icon.ico --xyz xyz_bootsvr)


Thanks in advance,

Kusuma


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Spreadsheet IO::Scalar v. PerlIO::Scalar confusion

2007-06-29 Thread [EMAIL PROTECTED]
I'm trying to install Spreadsheet-ParseExcel-0.32 from CPAN. It claims
to require IO::Scalar, but when I make it, it says (reasonably):

  $Config{useperlio} is defined, removing requirement of IO::Scalar

But then immediately:

  Warning: prerequisite IO::Scalar 0 not found.
  Writing Makefile for Spreadsheet::ParseExcel

And when I make test I get:

  t/basicok
4/8 skipped: various reasons
  t/parseok 1/37Can't locate IO/Scalar.pm in @INC (@INC
contains: ...)

I looked for IO::Scalar, but it appears to be superseded (or
something) by PerlIO::Scalar.

Confusion reigns!


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Net::SFTP functions

2007-06-29 Thread julien . laffitte
On 27 juin, 16:38, [EMAIL PROTECTED] (Oryann9) wrote:
> --- Octavian Rasnita <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > You need to use:
>
> > $ftp->get("/path/to/remote/file",
> > "/path/to/local/destination_file");
>
> > Octavian
>
> Also you can use
>
> $remotedir = qq(/path/to/remoteserver/dir/);
> $sftp->cwd($remotedir) || die "CWD to folder outbound
> failed!: $!",
>
> ## OHMONSTER here is the remote file
>  foreach ( $sftp->ls() ) {
>   if (/${$fref}\d+\w+/) {
>$OHMONSTER = $_;
>$sftp->get( $OHMONSTER, "$localdir/$OHMONSTER" )
>  || die "SFTP get from .com failed!: $!",
>
> ___­_
> Food fight? Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink 
> Q&A.http://answers.yahoo.com/dir/?link=list&sid=396545367
>
> ___­_
> Building a website is a piece of cake. Yahoo! Small Business gives you all 
> the tools to get online.http://smallbusiness.yahoo.com/webhosting

Octavian Rasnita > Ok I really don't get it.

My folder tree is similar to that one: d:\shared\exports\Export.csv
When I connect to the sFTP server, the home directory is the "shared"
folder, so when I list the folders I see the "exports" one.

I tried:

$sftp->get("exports/Export.csv", local/folder/file.csv);
$sftp->get("/exports/Export.csv", local/folder/file.csv);
$sftp->get("shared/exports/Export.csv", local/folder/file.csv);
$sftp->get("/shared/exports/Export.csv", local/folder/file.csv);

But neither of these work :(

oryann9 > the cwd command does not exists with sFTP package :((
It'd have been to easy !


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: pp utility

2007-06-29 Thread Chas Owens

On 6/28/07, kusu <[EMAIL PROTECTED]> wrote:

Hi,

Can any one help me in analyzing this code

system(pp -o abc.exe --icon=icon.ico --xyz xyz_bootsvr)


Thanks in advance,

Kusuma


looks like PAR::Packer tool to me:

http://search.cpan.org/~smueller/PAR-Packer-0.975/lib/pp.pm

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: parse help

2007-06-29 Thread Chas Owens

On 6/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I would suggest splitting each record on "\n", looping
> over the results checking to see if the first character is a space,
> and appending that line to the last field if it is or creating a new
> key/value pair if it isn't.

thank you. Would you mind posting sample code that does this trick?


There is nothing tricky about it. (warning untested code)

my @records;
local $/ = "\n\n"; #records are separated by two line feeds
while (<>) {
   my %rec;
   my $name;
   for my $field (split /\n/) {
   if ($field =~ /^ /) { #or if (substr($field,0, 1) eq ' ') { your choice
   $rec{$name} .= $field;
   next;
   }
   ($name, my $value) = split /=/, $field;
   $rec{$name} = $value;
   }
   push @records, \%rec;
}

for my $rec (@records) {
   print "$rec->{host} is owned by $rec->{owner}\n";
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Adding a line in a file inside many directories

2007-06-29 Thread Ved
Hi All,
Situation is bit complex (atleast for a beginer like me).
Directory structure is somewhat like this:
 testcases--> 150 Directories (names starting with mixed or green.) ---
> kat.s
i.e. a directrory named testcases has 150 number of directories in it
and each of those 150 number of directories has a file named kat.s .

Now I have to print a single line at say line number 20 in each of 150
number of  kat.s file.
I also have a list of names of all 150 subdirectories in a text file
named "list_of_files".

I have thought of implementing like this:
Open all kat.s in all the 150 directories using "list_of_files" and
print the line(tried as in  code below).
There is some problem in line where I am trying to open kat.s using
dirIN handle.
What am I doing wrong ?
Is there any better approach ?

#
use strict;
use warnings;
my $file =  'print.txt';
open my $VEDOUT, '>', $file or die "Could not open '$file':  ";

open (VEDIN, 'list_of_files.txt') or die "Cannot open 'File.txt' $!";
my @rgstr=;

foreach my $file_list (@rgstr) {
  print $file_list ;#prints file list
open (dirIN, '$file_list/kat.s') or die "Cannot open 'File.txt' $!";
#How to open kat.s ??

###Further have to add the print statement
}
close (VEDIN);
close ($VEDOUT);

##



Regards
Ved


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




CPU/Memory usage of a process on Windows machine

2007-06-29 Thread jeevs
Greetings

  I am trying to find CPU and memory usage on a windows machine and i
was able to get through memory usage using Win32::Process::Info
module's GetProcInfo function.
  This code may be helpfull to others which calculate the memory usage
of a particular process on windows


#!c:/perl/bin/perl.exe
# This is a test scrip
use Win32::Process::Info;
use warnings;
use strict;
my  $pi = Win32::Process::Info->new ();
my @process_information  = $pi->GetProcInfo(4488); ## 4488 is pid of a
particular process.
foreach  $info (@process_information) {
foreach my $key (keys %{$info}) {
if ($key eq 
"WorkingSetSize") {
my 
$value = ${$info}{$key}/1024;
print 
"$key:=>$value \n"
}

}
}


However i am struck at the cpu usage part.. If anyone can point me to
some good article or any docs to read for the same would be
appreciated. I have already googled a lot but i think i am missing
something..

Thanks ..


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




pp utility

2007-06-29 Thread kusu
Hi

Can any one help me in analizing this code

system(pp -o abc.exe --icon=icon.ico --xyz xyz_bootsvr)


Thanks in advance,

Kusuma


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Chas Owens

On 6/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip

I've tried bypassing the shell [ system(xxx,xxx,xx)] but that doesn't
seem to help.

snip

Hmm, what OS are you using?  And by system(xxx,xxx,xx) do you mean

system("perl vplan_all.pl", "5.6",  "24.0") == 0
   or die "blah";

or

system( "perl", "vplan_all.pl",  "5.6",  "24.0") == 0
   or die "blah";

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: parse help

2007-06-29 Thread [EMAIL PROTECTED]

>
>http://search.cpan.org/author/DCONWAY/Parse-RecDescent-1.94/lib/Parse...
>
> Hope this helps!
>
>

. I am still at the beginner level. I am afraid this would help me at
this stage.
Thanks anyway.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Splitting a CSV file at a variable number

2007-06-29 Thread Chas Owens

On 6/28/07, sum_duud <[EMAIL PROTECTED]> wrote:

in essence I would like the perl script to output all the fourth
column "0" values to a file called phase_0.csv and all the "1" values
to phase_1.csv etc.

snip

use an array of file handles (warning, untested):

use strict;
use warnings;

open my $in, '<', "phase.csv" or die "Could not open phase.csv: $!\n";
<$in>; #discard first line

my @file = map {
   open my $fh, '>', "phase_$_.csv"
   or die "could not open phase_$_.csv: $!";
   $fh
} 0 .. 20;

while (<$in>) {
   chomp;
   my ($x, $y, $z, $phase) =split /\s*,\s*/;
   my $file = $file[$phase];
   print $file "$x, $y, $z, $phase\n";
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Chas Owens

> Hmm, what OS are you using?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: exit code

2007-06-29 Thread Martin Barth
I just googled a bit:

http://www.hiteksoftware.com/knowledge/articles/049.htm

it seems that windows has more exit codes than linux.


On Fri, 29 Jun 2007 13:15:18 +0200
"Tatiana Lloret Iglesias" <[EMAIL PROTECTED]> wrote:

> And why i windows I get exit value 777?
> 
> On 6/29/07, Martin Barth <[EMAIL PROTECTED]> wrote:
> >
> > exit codes are stored in 1 byte. so you can only exit with
> > 2^8 == 256 different values.
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > http://learn.perl.org/
> >
> >
> >

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Splitting a CSV file at a variable number

2007-06-29 Thread sum_duud
I have a large CSV file of the format x,y,z,number (a coordinate file)
that I need to parse and output as individual files based on the
fourth field (column 3).  The file looks like the sample below, and
the fourth field can be from zero to 20,
so in essence I would like the perl script to output all the fourth
column "0" values to a file called phase_0.csv and all the "1" values
to phase_1.csv etc.

257673.711,6275192.977,150.500,0
257693.711,6275167.977,147.500,0
257713.711,6275167.977,147.500,2
257693.711,6275192.977,147.500,0
257713.711,6275192.977,147.500,0
257693.711,6275167.977,150.500,2
257713.711,6275167.977,150.500,2
257693.711,6275192.977,150.500,0
257713.711,6275192.977,150.500,2
257733.711,6275167.977,147.500,2
257753.711,6275167.977,147.500,2
257733.711,6275192.977,147.500,2

The perl script I have will work on one file, and one defined field,
but is there a way or telling perl to increment the search of the
fourth field value and effectively looping through the data until
there are no more fourth field values. ?.
The script I have is below:-


open( DEFAULT , "phase.csv") or die "Could not open $input.csv\n";
$blank = ;


# OPEN OUTPUT FILE AND WRITE HEADER LINE


open( OUT , ">phase_1.csv") or die "could not open $output\n";
print OUT "X, Y, Z, Phase\n";

# Read the data from csv file
# -

while (my $line = )
 {
chomp $line;
my @col =split (/\s*,\s*/ , $line);
$phase  = $col[3];
if ($phase == 1)
  {
   print OUT "$col[0], $col[1], $col[2], $col[3] \n";
  }
  }
close DEFAULT;
close OUT;
exit 0;
# pause so that window does not close
print "\nPress  \n";
;


Any help would be greatly appreciated.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Chas Owens

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:

Thanks Chas,
This does work. So there's no problem with perl itself. I guess now,
i'll have to take a look at vplan_all.pl.

The sucky thing is that road is too much of pain to go down. (Though
now i don't think ill be able to sleep without thinking about this :))
Oh well, Bug begets bug :)

Anyways,
thx again for helping out
Alex



I don't think the problem is in vplan_all.pl.  I looked back at your
original code and noticed a bug:
system( "perl vplan_all.pl 5.6 24.0")
  or die "Couldn't run the vplan_all.pl script: $!\n";

This should be

system( "perl vplan_all.pl 5.6 24.0") == 0
  or die "Couldn't run the vplan_all.pl script: $!\n";

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Chas Owens

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:

Sorry forgot about that.. I'm running it on FreeBSD/i386 accessed via.
a terminal prog.


I have a FreeBSD box handy, but I cannot reproduce your error.  Do the
two scripts below work for you?

/home/cowens>uname -smr
FreeBSD 4.11-STABLE i386
/home/cowens>cat t.pl
#!/usr/bin/perl

system("perl f.pl foo bar baz") == 0
   or die "perl blew up: $!";
/home/cowens>cat f.pl
#!/usr/bin/perl -l

print map { "[$_] " } @ARGV;
/home/cowens>perl t.pl
[foo] [bar] [baz]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Adding a line in a file inside many directories

2007-06-29 Thread Ved
Hi all,
I am a beginer in PERL.
What I am trying to do is this:
I have a 150 directories, each having a file "kat.s" in them.
I have names of all these directories in a text file
"list_of_dir.txt".

I have to open the each of "kat.s" in all the 150 directories and add
a line(say "ABCD" at line number 20) in each of them.

What I have thought of doing is that using "list_of_dir", open each
directory and open kat.s and print the required statment.
I have written a code. But I am stuck in opening the directory and
than kat.s file.
Please help.
(Or suggest any better way to do it)

Thanks.

###
use strict;
use warnings;


my $file =  'print.txt';
open my $VEDOUT, '>', $file or die "Could not open '$file':  ";


open (VEDIN, 'list_of_dir.txt') or die "Cannot open 'File.txt' $!";
my @rgstr=;

foreach my $file_list (@rgstr) {
  print $file_list ;#printing list of dir

open (dirIN, '$file_list/kat.s') or die "Cannot open 'File.txt' $!";
#This is not working

}
close (VEDIN);
close ($VEDOUT);

#


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: CPU/Memory usage of a process on Windows machine

2007-06-29 Thread oryann9

> #!c:/perl/bin/perl.exe
> # This is a test scrip
> use Win32::Process::Info;
> use warnings;
> use strict;
> my  $pi = Win32::Process::Info->new ();
> my @process_information  = $pi->GetProcInfo(4488);
> ## 4488 is pid of a
> particular process.
> foreach  $info (@process_information) {
>   foreach my $key (keys %{$info}) {
>   if ($key eq 
> "WorkingSetSize") {
>   my 
> $value = ${$info}{$key}/1024;
>   print 
> "$key:=>$value \n"
>   }
> 
>   }
> }
> 
> 

I tried to use a regexp like so
and it prints nothing, however I use the PID of the
outlook process and it works??? 
Any help would be appreciated!

my $name qr(/out\w+/i);
my @process_information  = $pi->GetProcInfo($name);




 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Chas Owens

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:
snip

my $vplan_parent_path = "\/pdd\/qes\/vsuites\/vplan";

snip

You don't need to escape those slashes.

snip

system("perl $vplan_parent_path\/vplan_all.pl") == 0
   or die "perl blew up: $!";

snip

Same thing here.

snip

And the o/p got is -

vp_all: USAGE: perl vplan_all.pl   

perl blew up: No such file or directory at test2.pl line 8.


Interesting thing is, while perl locates the second perl prog
successfully - it still calls die after that.

snip

You said before that it was supposed to die if it got no arguments, so
that is the expected behaviour.  As to why it keeps saying "No such
file or directory", well, if I remember correctly $! is the system
call errno, not the return from system.  I think you want $?
(specifically $? >> 8).  Here is what I think you want

system("perl vplan_all.pl 5.6 24.0 ajtest") == 0
   or die "vplan_all failed with an exit code of " . ($? >> 8);

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: CPU/Memory usage of a process on Windows machine

2007-06-29 Thread oryann9

You have to add UserModeTime and KernelModeTime then
divide by 10,000,000.

See:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0922.mspx

use Win32::Process::Info;
use Data::Dumper;

my $pi = Win32::Process::Info->new ();
my @process_information = $pi->GetProcInfo(3692);


foreach my $info (@process_information) {
foreach my $key (keys %{$info}) {
 if ($key eq "Name" or $key eq
"WorkingSetSize" or
$key eq "UserModeTime" or $key eq
"KernelModeTime") {
my $value = ${$info}{$key};
   print "\n$key: => $value \n";
}
}
}

~



   

Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Adding a line in a file inside many directories

2007-06-29 Thread Tom Phoenix

On 6/28/07, Ved <[EMAIL PROTECTED]> wrote:


open (VEDIN, 'list_of_dir.txt') or die "Cannot open 'File.txt' $!";


Why does the error message mention the wrong file name?


my @rgstr=;

foreach my $file_list (@rgstr) {
  print $file_list ;#printing list of dir


The items in this list haven't been chomped, have they? So each item
ends with a newline.


open (dirIN, '$file_list/kat.s') or die "Cannot open 'File.txt' $!";
#This is not working


If $file_list ends with a newline, I wouldn't expect it to work. Make
sure you're trying to open the correct filename, and make sure that
you mention the correct filename in the error message from die.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Alex Jamestin

Well, i tried both the options -


system("perl vplan_all.pl", "5.6",  "24.0") == 0
or die "blah";

or

system( "perl", "vplan_all.pl",  "5.6",  "24.0") == 0
or die "blah";


I think when perl -> shell -> perl . Here perl doesn't seem to
understand that vplan_all.pl is the script name and 5.6 and 24.0 are
options to be passed.

The exact same text ie. perl vplan_all.pl 5.6 21.0 works fine when i
just run it from the command line. Confusing! :\


On 6/29/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 6/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip
> I've tried bypassing the shell [ system(xxx,xxx,xx)] but that doesn't
> seem to help.
snip

Hmm, what OS are you using?  And by system(xxx,xxx,xx) do you mean

system("perl vplan_all.pl", "5.6",  "24.0") == 0
or die "blah";

or

system( "perl", "vplan_all.pl",  "5.6",  "24.0") == 0
or die "blah";



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Alex Jamestin

Okay,
system returns a 0 if it executes successfully. So then, die is called
only if system returns anything other than a 0.

And in the old code system would return a 0 after calling perl. This
would short-circuit and call die.

Makes sense :) Will try out and reply.

Thx,
Alex


On 6/29/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:
> Thanks Chas,
> This does work. So there's no problem with perl itself. I guess now,
> i'll have to take a look at vplan_all.pl.
>
> The sucky thing is that road is too much of pain to go down. (Though
> now i don't think ill be able to sleep without thinking about this :))
> Oh well, Bug begets bug :)
>
> Anyways,
> thx again for helping out
> Alex
>

I don't think the problem is in vplan_all.pl.  I looked back at your
original code and noticed a bug:
 system( "perl vplan_all.pl 5.6 24.0")
   or die "Couldn't run the vplan_all.pl script: $!\n";

This should be

 system( "perl vplan_all.pl 5.6 24.0") == 0
   or die "Couldn't run the vplan_all.pl script: $!\n";



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Alex Jamestin

Thanks Chas,
This does work. So there's no problem with perl itself. I guess now,
i'll have to take a look at vplan_all.pl.

The sucky thing is that road is too much of pain to go down. (Though
now i don't think ill be able to sleep without thinking about this :))
Oh well, Bug begets bug :)

Anyways,
thx again for helping out
Alex

On 6/29/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:
> Sorry forgot about that.. I'm running it on FreeBSD/i386 accessed via.
> a terminal prog.

I have a FreeBSD box handy, but I cannot reproduce your error.  Do the
two scripts below work for you?

/home/cowens>uname -smr
FreeBSD 4.11-STABLE i386
/home/cowens>cat t.pl
#!/usr/bin/perl

system("perl f.pl foo bar baz") == 0
or die "perl blew up: $!";
/home/cowens>cat f.pl
#!/usr/bin/perl -l

print map { "[$_] " } @ARGV;
/home/cowens>perl t.pl
[foo] [bar] [baz]



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Alex Jamestin

Tried that but it still won't work. Doh! Stupid bug :\

I'd run this test script below -

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

my $vplan_parent_path = "\/pdd\/qes\/vsuites\/vplan";


system("perl $vplan_parent_path\/vplan_all.pl") == 0
  or die "perl blew up: $!";


And the o/p got is -

vp_all: USAGE: perl vplan_all.pl   

perl blew up: No such file or directory at test2.pl line 8.


Interesting thing is, while perl locates the second perl prog
successfully - it still calls die after that.


Anyways, gotta leave for friday (I'm on the other side of the world :))
Thx,
Alex

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread marin
Hi everyone!

I'm trying to get references from a simple regular exepression like
this :

"a40d7412" =~ /(([[:xdigit:]]{2})*)/;

print "$1: <$2><$3><$4><$5>\n";


This prints :
a40d7412: <12><><><>

How to get all references and not the last one in the second
parenthesis pair ?
I'm STFW for 2 hours :-(

Thanks in advance.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Adding a line in a file inside many directories

2007-06-29 Thread usenet
On Jun 28, 12:00 pm, [EMAIL PROTECTED] (Ved) wrote:
> Now I have to print a single line at say line number 20 in each of 150
> number of  kat.s file.

Hey, another chance to show off my favorite Perl module, IO::All.

> Situation is bit complex (atleast for a beginer like me).

Actually it is so simple (with IO::All) that you're gonna think I'm
pulling your leg...

#!/usr/bin/perl
   use strict;
   use warnings;
   use IO::All;

   my $dir = '/tmp/clpm';   #root directory of data
   my $line = 19;   #print line 20 (first line is line zero)
   my $file = 'kat.s';  #match this filename

   map {print "@$_[$line]\n"}
  io($dir)->filter(sub{$_->filename eq $file})->all_files(0);

__END__



That's it.  Really.

IO::All is a proxy to a bunch of I/O modules.  In this case, it is
doing two things:

   io($dir)->filter(sub{$_->filename eq $file})->all_files(0);

This uses File::Find to recurse all directories below $dir and find
all files named 'kat.s'.

   map {print "@$_[$line]\n"}

This uses Tie::File to treat the file like an array; I print the line
I want (line #20, which is array element #19).

IO::All provides all of your basic error-handling services, so no need
to futz around with that.

Cheers!


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: How can i make a perl program lauch another perl program that takes options

2007-06-29 Thread Tom Phoenix

On 6/29/07, Alex Jamestin <[EMAIL PROTECTED]> wrote:


Well, i tried both the options -

> system("perl vplan_all.pl", "5.6",  "24.0") == 0
> or die "blah";
>
> or
>
> system( "perl", "vplan_all.pl",  "5.6",  "24.0") == 0
> or die "blah";

I think when perl -> shell -> perl . Here perl doesn't seem to
understand that vplan_all.pl is the script name and 5.6 and 24.0
are options to be passed.

The exact same text ie. perl vplan_all.pl 5.6 21.0 works fine when i
just run it from the command line. Confusing! :\


Could it be that you have a different $PATH, a different directory or
other envronment changes? If your perl binary is properly built and
installed, it should be capable of running another perl.

   system("perl", "-lwe", "print q(perl works!)") == 0
 or die "Can't call perl: $!";

Cheers!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread Tom Phoenix

On 6/29/07, marin <[EMAIL PROTECTED]> wrote:


I'm trying to get references from a simple regular exepression like
this :

"a40d7412" =~ /(([[:xdigit:]]{2})*)/;

print "$1: <$2><$3><$4><$5>\n";



How to get all references and not the last one in the second
parenthesis pair ?


I don't think you're looking for references; those are described in
the perlref manpage. You're using regular expressions, described in
the perlre manpage (and elsewhere). Is that the source of your
confusion?

I think you're looking to get every hex digit pair you can match,
maybe? You could use m//g in list context:

  my @matches = "a40d7412" =~  /([[:xdigit:]]{2})/g;

But that may not be what you want, especially if your data isn't just
hex. Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Test::Class fixture problem

2007-06-29 Thread Ovid
I've just spent quite a bit of time debugging a problem where a Test::Class 
setup method was misbehaving.  My tests passed, but mysql was spitting out 
errors directly to STDERR and quite a bit of tracing led me to the following:

  sub setup : Tests(setup) {
  my $test = shift;
  $test->SUPER::startup;
  $test->_make_test_servers(
  num_servers => 2,
  username=> 'Ovid',
  );
  }

As you can see, I called SUPER::startup instead of SUPER::setup.

My base class has stubs for these methods to ensure that I never have a problem 
with SUPER::

  sub startup : Tests(startup) {}
  sub setup : Tests(setup) {}

  sub teardown : Tests(teardown) {}

  sub shutdown : Tests(shutdown) {}


Sometimes in my hierarchy, though, the SUPER::startup (or whatever) method will 
call a chain of two of these before getting to the stub.  It's trivial to write 
code in my stubs which check the caller and issue a warning and maybe I can 
just walk back through the call stack to issue a warning if I'm ever called by 
an inappropriately named method, but that seems a bit hackish.  Is there some 
better way to solve this problem?

Cheers,
Ovid


-- 
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Adding a line in a file inside many directories

2007-06-29 Thread John W. Krahn

[EMAIL PROTECTED] wrote:

On Jun 28, 12:00 pm, [EMAIL PROTECTED] (Ved) wrote:

Now I have to print a single line at say line number 20 in each of 150
number of  kat.s file.


Hey, another chance to show off my favorite Perl module, IO::All.


Situation is bit complex (atleast for a beginer like me).


Actually it is so simple (with IO::All) that you're gonna think I'm
pulling your leg...

#!/usr/bin/perl
   use strict;
   use warnings;
   use IO::All;

   my $dir = '/tmp/clpm';   #root directory of data
   my $line = 19;   #print line 20 (first line is line zero)
   my $file = 'kat.s';  #match this filename

   map {print "@$_[$line]\n"}
  io($dir)->filter(sub{$_->filename eq $file})->all_files(0);


Instead of using map in a void context:

   print "@$_[$line]\n" for
  io($dir)->filter(sub{$_->filename eq $file})->all_files(0);

Or just call print once with a large list:

   print map "@$_[$line]\n",
  io($dir)->filter(sub{$_->filename eq $file})->all_files(0);



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: how to get references from imbricated capturing parenthesis ?

2007-06-29 Thread Dr.Ruud
marin schreef:

> I'm trying to get references from a simple regular 
> exepression like this :
> 
> "a40d7412" =~ /(([[:xdigit:]]{2})*)/;
> print "$1: <$2><$3><$4><$5>\n";
> 
> This prints :
> a40d7412: <12><><><>
> 
> How to get all references 

Verbose variant:

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

  my $s = 'a40d7412';

  my ($m, @m) = $s =~
  /(
[[:xdigit:]] {2}  # 2 hex-digits
   )/xg;  # each

  print "$m: <",
join('><', @m),
">\n";
__END__


Terse variant:

  @m = $s =~ /../g;# no capturing () needed
  { local $" = '><';   # see perlvar
print shift(@m), ": <@m>\n";
  }


See also `perldoc -f pack` (the H-template). 


> and not the last one in the second
> parenthesis pair ?


You shouldn't suggest the wrong approach as part of the solution.
:)

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/