Hai Jeff,

The solution you have provided is working fine. Thanks a lot.

Regards,
Ganesh


Jeff 'japhy' Pinyan wrote:

On Jun 1, N. Ganesh Babu said:

<o><r>C.A. Eschenbach, F. Hall, C.R. Johnson, Z. Li, The graphs of unambiguous entries in the product of two <m>MATH0810075.dat:1</m> sign patterns, Linear Algebra Appl. 260 (1997) 95--112.</r></o>

  while($line=~m!MATH(\d{7}\.dat):(\d{1,2})!g)
  {
  $math=&math($1, $2);
  $line=~s!MATH$1:$2!$math!;
  print $line;
  }


Two things to mention...

First, the '^' character in a regex does not match a '^', but instead means "match the beginning of the string". So in your regex, you want to backslash it.

  m!\^AMATH\^D(\d{7}\.dat):(\d{1,2})\^B!

Second, there's a way to do:

  while (m/XXX/g) {
    YYY = some_function();
    s/XXX/YYY/;
  }

all at once.  It's like this:

  s/XXX/some_function()/eg;

The /e modifier means "execute the right-hand side of the s/// and use its return value as the replacement text". So your regex would be

  s!\^AMATH\^D(\d{7}\.dat):(\d{1,2})\^B!math($1,$2)!eg;


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


Reply via email to