in reply to how to match the pattern by using regexp for the below task

# From what Anonymous monk writes, it seems the task is: # replace a field (in double quotes) of a comma # separated record in a file called guidpair.txt with # something else. # He gives me the line, the text of the last field, and # the replacement text which he somehow gets from another # file. # The line # "Web","rad","INPUT","onclick","746B97B8-486A-094F-9426292F0C0BB644 F +","" # should be # "Web","rad","INPUT","onclick","5C1DAEF0-9386-44a5-B92A-31FE2C79236A" +,"" # # Given that information, the program could look like this: my $infile = 'guidpair.txt'; my $tempfile = "$infile.new"; # =================================================== # CAVEAT: if $infile.new exists, it will be clobbered # XXX Better use File::Temp here? # =================================================== open(I,"<$infile") or die "Can't open $infile: $!\n"; open(O,">tempfile") or die "Can't write $tempfile: $!\n"; while(<I>) { if (/"Web","rad","INPUT","onclick","746B97B8-486A-094F-9426292F0C0 +BB644 F",""/) { s/746B97B8-486A-094F-9426292F0C0BB644 F/5C1DAEF0-9386-44a5-B92 +A-31FE2C79236A/; } print O; } close(I) or die "Can't close input file $infile: $!\n"; close(O) or die "Can't close temp file $tempfile: $!\n"; rename($tempfile,$infile) or die "Can't rename $tempfile to $infile: $!\n"; __END__
This might be of no help at all, but your specs aren't clear. One way to make them clear is to write down your requirements into the program file as comments as accurate as possible. The clearer they are, the easier it is to translate them into code.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}