Hello again everyone,
Sorry about being so cryptic but I will put my question in code.
I found a way to do what I want but it seems so cumbersome.
I am sure a better way exist. well here is the code
open(XFIL,"var.txt") || die $!;
@main = <XFIL>;
close(XFIL);
open(XFIL,">var.txt") || die $!;
foreach $line (@main) {
$line =~ s/\n/replace/g;
print XFIL $line;
}
close(XFIL);
open(XFIL,"var.txt") || die $!;
@main = <XFIL>;
close(XFIL);
open(XFIL,">var.txt") || die $!;
foreach $line (@main) {
$line =~ s/the line to be replaced/this is the new line/;
$line =~ s/replace/\n/g;
print XFIL $line;
}
close(XFIL);
Hello ,
I have a quick question . Lets say the word data is in
the $string 20 times. I want to only match the first instance
of the word data . How would I do this ?
if ($string =~ m/data/) {
do whatever
}