xjlittle has asked for the wisdom of the Perl Monks concerning the following question:
Here is the original string and the output data. As you can see the output substitutes the string but then adds the :: and everything after it again. I haven't been able to figure out how to escape the :: to make it quit doing this. Please shed some light.#!/usr/bin/perl -w use strict; my $group = "sbo"; my $newstring = "sbo::18659:x0929,x1465,x1368,x5552; my $backup = "/etc/group"; my $new = "/etc/group.tmp"; #back up group `cp -f $backup $backup.4623`; #fix group open (GROUP, "<", $backup); open (NEW, ">", $new); while (<GROUP>){ s/^$group/$newstring/; print NEW $_; } close GROUP; close NEW; print "\n"; print "\n"; system("cat $backup |grep $group"); #system("ls -lad $dirs"); print "\n"; system("hostname"); print "\n";
Thanks!_DATA_ diff /etc/group /etc/group.tmp 104c104 < sbo::18659:x0929,x1465 --- > sbo::18659:x0929,x1465,x1368,x5552::18659:x0929,v1x1465,x1368,x5552 bash-2.05#
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I escape a :: in s///?
by ikegami (Patriarch) on Aug 14, 2009 at 16:10 UTC | |
|
Re: How do I escape a :: in s///?
by JavaFan (Canon) on Aug 14, 2009 at 16:10 UTC | |
|
Re: How do I escape a :: in s///?
by SuicideJunkie (Vicar) on Aug 14, 2009 at 16:11 UTC | |
|
Re: How do I escape a :: in s///?
by perlkiller (Acolyte) on Aug 14, 2009 at 18:13 UTC | |
|
Re: How do I escape a :: in s///?
by perlkiller (Acolyte) on Aug 14, 2009 at 19:20 UTC | |
by ikegami (Patriarch) on Aug 14, 2009 at 19:56 UTC |