Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: REGEXP Helpby arunhorne (Pilgrim) |
on Jun 24, 2002 at 13:24 UTC ( [id://176777]=note: print w/replies, xml ) | Need Help?? |
First up... if you always have the same lines why don't you just hard code the transformation, i.e $header[0] = "Date/Time"? Another note is that where you say $header[1] =~ s/^\".*\"$/Date\/Time/; in your script I think you mean $header[0] =~ s/^\".*\"$/Date\/Time/; as array indexing begins at zero... These points aside you are going to need a regular expression that can cope with the machine name syntax... how about: s/^\\\\(.*)\\.*$/your_text_here/;Note that its probably possible to write the above in a neater way due to the escaping of multiple backslahses. The brackets around the first .* in the expression act as a memory allowing you to retrieve the exact text they macthed, in this case the machine name... thus if you wanted to include the machine name in the text that replaces the macthed text you could use \1 or $1. Check out a regex text for information on these. Hope this helps... your questions a bit vague so clarify it a bit more and i'll try and help some more. ____________Arun
In Section
Seekers of Perl Wisdom
|
|