Mumia W. wrote:
> On 12/25/2006 11:51 AM, Goksie wrote:
>> [...]
>> If i run the script, the changes could not be effected bcos the files is
>> a readonly file.
>>
>> I will be glad if someone can put me true
>>
>> goksie
>>
>
> You probably want a mode of "+<" to open the file read-write.
>
> perldoc -f open
>
>
>
>

when i used the below code and allow the printing to the files
 
#!/usr/bin/perl
use warnings;
use strict;
print "what is the ip to suspend\n";
our $ip = <STDIN>;
chomp($ip);
my $files = "/etc/pbx/mine.conf";
open my $fh, '+<', $files or die "can't open the files $files: $!";
while (<$fh>) {
  s/host=$ip/host=$ip\.old/mg;
print $_;
 }

mine.conf
[2.2.2.2]
type=friend
host=2.2.2.2
context=default
port=5060
dtmfmode=rfc2833
canreinvite=no
qualify=yes
allow=g723

the output of running the script is
[2.2.2.2]
type=friend
host=2.2.2.2.old
context=default
port=5060
dtmfmode=rfc2833
canreinvite=no
qualify=yes
allow=g723

but it does not change the file, but the control print i made to the
screen shows the change.

goksie


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to