On Jan 10, [EMAIL PROTECTED] said: >I have a file which has many strings like "$something[0]" through >"something[20]" amongst other text (quotes only provided here for >clarity). > >What I want to do is replace these strings with: "$SOMETHING0" through >"$SOMETHING20".
Personally, I find that odd -- moving from an array of 21 elements to 21 DIFFERENT scalars?! >perl -p -i -e 's/something\[([0-9][0-9]?)\]/SOMETHING$1/g' file > >"file" becomes 0 bytes. I'm not quite sure why this is happening; is it >a fault of my regex? Or - maybe less likely - could it because "file" is >on a file system Samba mounted from Linux to NT? I know there is a command >line option to use a backup file instead of modifying the original, but >no matter how many times I've seen this, I can't recall it. It should be writing back to file. If you want to make a backup, give the -i flag an extension: perl -p -i.bak -e 's/something\[(\d\d?)\]/SOMETHING$1/g' file -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]