Forum Moderators: coopster & phranque

Message Too Old, No Replies

regex a singleline

         

indiescene

2:14 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



Hi all,

At the mom this code works prefectly fine but i am having problems changing it so that it only affects the first line of values and not all.


while (<FILE1>) {
($hash, $input, $for, $aa) = split( /\s+/, $_) if /^\# \input\b.*/;
if ($aa =~ /LEU\b/)
{s/ (.*)/$z3leu $z2leu $z1leu $1/}
print;
}

FILE:

# INPUT FOR LEU
0.897 0.254 - so make s//g before these values
0.121 0.254
ETC

Thanks,

Hissingsid

3:38 pm on Apr 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

Just an idea but why not treat the file as an array with each line as an element in the array. You can do all of the other stuff spliting lines into variables just as easily on your array elements as you currently are.

The Tie::File module makes a file into an array of lines. Then you can reference $array[0] and run it through your regex.

Google "treating file as an array" for more info.

I hope that this helps

Best wishes

Sid

indiescene

3:49 pm on Apr 15, 2004 (gmt 0)

10+ Year Member



I think imanaged to correct the problme by using $. == x, where x is the line of interest!

Thanks though