Jorge,
You need to open and write all that you want to a new file:
open(NOUVEAU, "> $nouveau")
or die "je ne peux ouvrir $nouveau : $!";
open(new_NOUVEAU, "+> $nouveau_new")
or die "je ne peux ouvrir $nouveau_new : $!";
while ($line = <VIEUX>) {
last if ($line =~ /^host clin09/);
print new_NOUVEAU $line;
}
print new_NOUVEAU $line;
print NOUVEAU $newline2 or die "je ne peux �crire dans $nouveau : $!";
close (new_NOUVEAU);
close (NOUVEAU);
then delete $nouveau and rename $nouveau_new to $nouveau.
Jerry
Jorge Goncalvez wrote:
> HI, I have a file which ends by:
>
> host clin09 {hardware ethernet 00:80:9F:2E:3F:5E;
> filename "/bootp/linux/pre3.1/alize/startup.txt";}
> }
>
> I have a perl tk application where a user types a MAc Adress in an entry the
> variable is $_Globals{MAC_ADDRESS} .
>
> I wanted to replace what's come after hardware ethernet ie in this case
> 00:80:9F:2E:3F:5E by what the user entered.
>
> I have this code:
> my $newline2=qq{host clin09 {hardware ethernet $_Globals{MAC_ADDRESS};\n
> filename "/bootp/linux/pre3.1/alize/startup.txt";}\n};
>
> open (VIEUX,"< $_Globals{DHCPDCONF}")
> or die "je ne peux ouvrir $_Globals{DHCPDCONF} :$!";
>
> open(NOUVEAU, "> $nouveau")
> or die "je ne peux ouvrir $nouveau : $!";
>
> while ($line = <VIEUX>) {
>
> if ($line =~ /^host clin09/) {
>
> print NOUVEAU $newline2 or die "je ne peux �crire dans $nouveau : $!";
> }
>
>
> }
> close (VIEUX);
> close (NOUVEAU);
>
>
> But it didn't work could help me please Thanks
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]