Search many PPM’s (ActivePerl packages) and printing multi line results into a file

I want to search many PPM’s (ActivePerl packages) and printing multi line results into a file.

This is Windows XP PC, using ActivePerl 5.10.0 Build 1004.

So I have the file “require_for_padre.txt” which contains all the Perl modules needed for Padre.

I took the names from:
http://svn.perlide.org/padre/trunk/Padre/Makefile.PL

and put each after the search query of ActiveState PPM, as follows:
(Note – this is for running from DOS):

ppm search App::Ack
ppm search Carp
ppm search Class::Adapter
...
ppm search Test::Exception
ppm search Test::NoWarnings
ppm search Test::NeedsDisplay

Now I wand to read all the above –  and put the output –  which is multi line per each search – into a text file.

Here’s the way:

=======================================

#!/usr/bin/perl -w
use strict;
use Cwd;
use File:: Path;

my $cur_dir = getcwd();
my $pkg_file = "require_for_padre.txt";
my $dest_file = "ppm_output_for_padre.txt";

my $line = "";
my $ppm_search_line = "";
my $total_lines = 0;
my $actual_lines = 0;

## my $cur_line = 0;

## Get the answer for the  ppm search:
  my $get_ppm_search_answer = "";

opendir(DIRHANDLE, "$cur_dir") or die "couldn't open $cur_dir: $!";

print "Openned  $cur_dirn";

  open (PKG_FILE, "$pkg_file") or die "couldn't open $pkg_file: $!";

  print "Openned  $pkg_filen";
  print "----------------------------------------------------------n";

  # create a blank file
  open (DST_FILE, ">$dest_file");
  close (DST_FILE);

  print "tttcreated $dest_filen";
  print "----------------------------------------------------------n";

  open (DST_FILE, ">$dest_file");

  while (<PKG_FILE>) {
       $total_lines = $total_lines +1 ;
       ##    $cur_line = 0;
       my $ppm_search_line = $_;
       #print "nnnn$line $total_lines :t $linen";

       print "$ppm_search_line";

       #system("$ppm_search_line");

       print for qx{$ppm_search_line};
       }

        close (DST_FILE);
  close (PKG_FILE);

closedir(DIRHANDLE);

print "$total_lines are: $total_lines n";

=======================================

That’s it

How to run?

Well… :

N:OrenMperl_ppm>ppms_padre001.pl   ppm_output_for_padre.txt

Why do I want an IDE for Perl

I was asked (Gabor – thanks) to explain why do I actually need an IDE for Perl.

The short answer is –
To run my little Perl/TK program from inside the editor, and Debugging.

Details:

  • First – a little background:
    I’m not an experienced programmer. I mean –  not in the sense of using major “heavy” languages like Java, C++/ C# or C and others.  (I know just a little of those… ).
  • Second – A specific example:
    I do know know some Perl and use it at my daily work – to process textual files.
    So I wrote a Perl/TK thing on my PC  – to process a textual bibliographic files and add certain fixed bibliographic fields.
    It’s Windows XP that I have at work.
    So for editing my scripts –  I use Vim, which is nice and colorful  just like in various Unixes .
    BUT For running – I currently use ActivePerl 5.10.0.1003 .

    The “coding” is separated from the code testing and debugging.

  • Now –  people around me at work use Visual Studio for C++ to develop a GUI application.
    So … Why won’t I use something like this to improve my little Perl/TK program?

    What I do now is trial and error:
    I edit the script / program in Vim but run it separately (done by ActivePerl when I double click it) and not from inside the editor.

And that’s where I need an IDE.

Vim is great – but IDE can stop the run in a breakpoint, so it saves a lot of debugging time.