pattern match anything before "dot"
I want to replace the filename name.exe with --FILE--.exe as part of my perl script.
Is there an easy way to do that with pattern matching? Bascially, i want to match anything before ".exe", then replace them with "--FILE--". |
use =~// to match
use =~s/// to substitute: Code:
#!/usr/bin/perl -w --FILE--.exe --FILE--.exe notthis.txt --FILE--.exe \w is an alphanumeric character + is one or more of the character \. is a real period (. is anything) ^ indicates the beginning $ indicates the end Google "Rex Swain's HTMLified Perl 5 Reference Guide"; it's a great, very short quick reference that includes all the regular expression stuff. Also perlmonks.com is a very active and helpful forum :) |
Quote:
$variable =~ s/<variable where your input comes from>/"--FILE--.exe"/; Check the syntax, though...not sure that's right. :) |
All times are GMT -5. The time now is 10:55 AM. |