hi,
thank you for your help, i read up regular expressions and have written
some code, but it substitutes the value at all places, i want it to
substitute only if it is raised to the power or if it occurs after '^'
..
Code :
#!usr/bin/perl
# testing for ^ substitution.
use strict;
use warnings;
my $iname = "/home/user/test1.txt";
my $oname = "/home/user/out.txt";
my (@temp,@newline,@newtmp);
open(INF,'<',$iname) or die ("Cannot open input file \n");
@newline=<INF>;
close (INF);
open(OUTF,'>',$oname) or die ("Cannot open output file\n");
my ($newlines,$i);
my @tmp;
foreach $newlines(@newline)
{
if ($newlines =~ /(.*)(\.)(.*)( = )(.*)(

/) // if it matches
Species4.variable
{
@temp = split (/=/,$newlines); // split at '=' & store
values in
@temp
}
if ($newlines =~ /(\^)/) // search for ^
{
@tmp = split(/ /,$newlines); // if
found split at '^'
@newtmp = split (/;/,$tmp[1]); //
store Species4.variable after
split
}
}
if ($temp[0] eq $newlines[1])
{
foreach $newlines(@newline)
{
$newlines =~ s/$tmp[1]/$temp[1]/;
print $newlines;
}
}
close (OUTF);