#!/usr/local/bin/perl
#use warnings;


sub system_test {
      system("ls -all |less");
      system("echo March");
      $bar=10;
      system("echo $bar");  #displays 10
      print "$_[0]\n";
      $ENV{BAR1}=200;
      `echo $bar`; #will not display anything
}


sub file_size1 {
	system("ls -all > myfiles.txt");
	open(IN,"<myfiles.txt") or die "Cannot open myfiles.txt: $!\n";
	my $line=<IN>;
	$line=<IN>;
	while ($line=<IN>) {
	  my @fields=split(/\s+/,$line);
	  $myfiles{$fields[8]}=$fields[4];
	}
	close(IN); 
	print "File\t  Size\n";
	while (($file,$info)=each(%myfiles)) {
	  printf "$file \t $info\n";
	}
}

sub file_size2 {
	open(IN,"ls -all | ");
	my $line=<IN>;
	$line=<IN>;
	while ($line=<IN>) {
	  my @fields=split(/\s+/,$line);
	  $myfiles{$fields[8]}=$fields[4];
	}
	close(IN); 
	print "File\t  Size\n";
	while (($file,$info)=each(%myfiles)) {
	  printf "$file \t $info\n";
	}
}

sub file_size3 {
	my $bigline=`ls -all`;
      my @lines=split(/\n/,$bigline); 
      foreach my $line (@lines) {
          my @fields=split(/\s+/,$line);
          print "$fields[8]\t $fields[4]\n";
      }    
}



system_test $ARGV[0];
file_size1;
file_size2;
file_size3;