Q
qanda
Hi all
I've just started with Perl again and would like some help with the following.
I have files that contain records like the following (I've used comma as the
delimiter but in real life it is octal 177)...
field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6
I want to find a pattern such as /C\/w+/ (I belive?) and then replace it
with string_patternNumber. Each different pattern that is found would be
assigned an incremental number and each pattern would then be replaced by
a text string plus the pattern number. The pattern can appear any number
of times in a record.
So we could end up with something like ...
field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
field1,XBC/string_1 ef34,field3,field4,EFC/string_2 ef56,field6
field1,YBC/string_1 ef34,field3,field4,EFC/string_3 ef56,field6
My other problem is with modifying ARGV after doing a readdir with grep.
I want to match a subset of several similar file patterns.
aa_b_aba_kdkgh.ext
aa_b_bcb_kdkgh.ext
aab_b_def_kdkgh_ueyd.ext
aa_b_abc_kdkgh.ext
aab_b_abc_kdkgh_kdkdk.ext
aab_b_gag_kdkgh.ext
aab_b_abc_kdkgh.ext
aab_b_abc_kdkgh.ext
so the aa.?_ part is common at the beginning and the _.+\.ext is common at the
end, but I only want aba, def and gag in the middle.
Any help is greatly appreciated.
Thanks.
I've just started with Perl again and would like some help with the following.
I have files that contain records like the following (I've used comma as the
delimiter but in real life it is octal 177)...
field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6
I want to find a pattern such as /C\/w+/ (I belive?) and then replace it
with string_patternNumber. Each different pattern that is found would be
assigned an incremental number and each pattern would then be replaced by
a text string plus the pattern number. The pattern can appear any number
of times in a record.
So we could end up with something like ...
field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
field1,XBC/string_1 ef34,field3,field4,EFC/string_2 ef56,field6
field1,YBC/string_1 ef34,field3,field4,EFC/string_3 ef56,field6
My other problem is with modifying ARGV after doing a readdir with grep.
I want to match a subset of several similar file patterns.
aa_b_aba_kdkgh.ext
aa_b_bcb_kdkgh.ext
aab_b_def_kdkgh_ueyd.ext
aa_b_abc_kdkgh.ext
aab_b_abc_kdkgh_kdkdk.ext
aab_b_gag_kdkgh.ext
aab_b_abc_kdkgh.ext
aab_b_abc_kdkgh.ext
so the aa.?_ part is common at the beginning and the _.+\.ext is common at the
end, but I only want aba, def and gag in the middle.
Any help is greatly appreciated.
Thanks.