用熟悉的脚本语言完成以下功能。
a、一段html语言,找到第一个“hello the world”,删除“the” 。
b、把html里面所有的“hello the world”都替换成“hello world”。
#!/usr/bin/perl -w use strict; open FILEHANDLD,"html.txt" or die "this file can not open $!\n"; my @fileMSG = <FILEHANDLD>; # Replace all "hello the world" to "hello world" sub TstReplaceAll { my $msg = join "",@fileMSG; $msg = ~s/hello the world/hello world/g; print $msg; } # Replace Once "hello the world" to "hello world" sub TstReplaceOnce { my $msg = join "",@fileMSG; $msg = ~s/hello the world/hello world/; print $msg; } TstReplaceAll(); TstReplaceOnce();