Hello,

I'm brand new to the world of Perl.  The topic I'm about to ask about
might have been addressed before.  Sorry for the duplication, if that's
the case.

My understanding is that whatever is between the parens in a regexp get
stored in a variable ($1,$2,...).  And, if you do a 

($var_name1,$var_name2) = regexp with parens around interesting stuff to
store,

then the interesting stuff inside the parens get stored in the vars you
specify.  Am I understanding incorrectly?

The last print statement in the code below outputs nothing after the
"pid =".  What am I doing wrong?

Thanks,
Rami
_______________________________
$test_ps_txt_file = "txt_file_name";

print "Opening test ps file  $test_ps_txt_file...\n";
open (TEST_PS_FILE, $test_ps_txt_file) || die "Couldn't open
$test_ps_txt_file: $!";

while (<TEST_PS_FILE>)
{
  print "Read line...\n";
  chomp; # used to removed newline char.
  print "$_\n";

  #parse a line and store.
  print "Parse line...\n";
  ($pid,$elapsed_hours,$elapsed_minutes,$char_combo,$command,$cmd_arg) =
/\s*(\d+)\s+([0-9]?[0-9]?):([0-9][0-9]):[0-9][0-9]\s+(\\?_?)\s+\-?(\w+)\
s+(\w)/;

  print "pid = $pid\n";
}
___________________________________

Here are the contents of the txt file (just create a file and
copy/paste):

 3847       00:26 -tcsh
  884    03:29:36 perl test_meister.pl
 1034    01:36:33  \_ sh -c . setup_sh && cd /somedir && perl doit.pl
 1036    01:36:32      \_ perl doit.pl -w -a
 1076    01:36:31          \_ sh -c perl run.pl -w >> some_log 2>&1
 1077    01:36:31              \_ perl run.pl -w
 1497    01:34:48                  \_ sh -c some_exe some_file_name >
redirect_file_name 2>&1
 1498    01:34:48                      \_ some_exe dstest_control.out


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

Reply via email to