专家的:
open (TextFile, "C:\\Scripts\\Alice.txt");
@arrTextFile = ;
close (TextFile);
$strFile = @arrTextFile[0];
chomp($strFile);
@arrWords = split(' ',$strFile);
$x = @arrWords;
for ($i = 0; $i < $x; $i ++)
{
$strValue = @arrWords[$i];
$strValue = reverse $strValue;
@arrWords[$i] = $strValue;
}
$strNewContents = join(" ",@arrWords);
print $strNewContents;
我的:
#!/usr/bin/perl -w
use strict;
open FH," < alice.txt" or die "$!";
my $mystring=;
my @every=split / /,$mystring;
my ;
my $laststring="";
for (my $i=0;$i<$number;$i++)
{
my $myreverse=reverse $every[$i];
# print "$myreverse\n ";
$laststring=$laststring . " " .$myreverse;
}
print "@every\n";
print "******************\n";
print "$laststring";
阅读(1190) | 评论(0) | 转发(0) |