#!/usr/bin/perl use warnings; print"\n Enter the Filename (x.txt) with Data in List context: "; $filename = ; chomp$filename; # open the file, or exit unless ( open(FILE, $filename) ) { print "Cannot open file \"$filename\"\n\n"; exit; } $list = ; print"\n List= $list\n"; @array=split('',$list); # To convert scalar to array print"\n Array From the List= @array\n"; $N_elements=@array; # To count number of elements in array print"\n Number of Elements= $N_elements\n"; # Sum of all elements in array: $sum=0; $sum=eval join '+',@array; # Mean of the list: $mean=$sum/$N_elements; # Line 21 print"\n Mean of the list= $mean\n"; exit; #### Enter the Filename (x.txt) with Data in List context: x.txt List= (10,12,14,16,18); Array From the List= ( 1 0 , 1 2 , 1 4 , 1 6 , 1 8 ) ; Number= 17 Use of uninitialized value $sum in division (/) at C:\Users\x\Desktop\mean.pl line 21, line 1. Mean of the list= 0 #### Enter the Filename (x.txt) with Data in List context: x.txt List= (10,12,14,16,18); Array From the List= ??? Number of Elements= 5 Mean of the list= 14