#!/usr/bin/perl
print “enter some lines,then press ctrl-z:\n”;
@lines=;
@[email protected];
print @reverse_lines;
#!/usr/bin/perl
@names=qw/fred betty barney dino wilma pebbles bamm-bamm/;
print “enter some numbers from 1 to 7,one per line,then press ctrl-z:\n”;
chomp(@numbers=);
foreach (@numbers){
print “names[_ -1] \n”;
}
#!/usr/bin/perl
chomp(@lines=);
@sorted=sort @lines;
print “@sorted\n”;
##print sort ;
#ex3_1.pl
#!/usr/bin/perl -w
print “please enter some character string(one in each row),then press ctrl+z and enter:\n”;
@lines=;
print reverse @lines;
#ex3_2.pl
#!usr/bin/perl -w
print “please enter some numbers from one to seven(one in each row),then press ctrl+z and and enter:\n”;
@list=qw(begin fred betty barney dino wilma pebbles bamm-bamm);
chomp(@lines=);
foreach KaTeX parse error: Expected '}', got 'EOF' at end of input: …lines){
print "list[$lines]\n";
}
#ex3_3.pl
#!/usr/bin/perl -w
print “please enter some character string(one in each row),then press ctrl+z and enter:\n”;
@lines = ;
print " \n";
print “different lines:\n”;
print sort @lines ;
print " \n";
print “one line:\n”;
chomp(@lines);
@line = sort @lines;
print “@line”;
|
请发表评论