My program has a problem..Why Can't I loop through each line of the file, I get to print only the first line. It might sound silly asking this question but whats problem with my foreach loop?maps_c7 190_520 3195927 00 40 0K8632 maps_c7 210_520 3195928 00 41 0K8701 maps_c7 210_620 3195929 00 42 0K8702 maps_c7 230_560 3195930 00 43 0K8635 maps_c7 230_620 3195931 00 44 0K8703 maps_c7 230_660 3195932 00 45 0K8704 maps_c7 250_660 3195933 00 46 0K8638 maps_c7 250_800 3195934 00 47 0K8705 maps_c7 275_800 3195935 00 48 0K8640 maps_c7 300_860 3195936 00 49 0K8706 maps_c7 300_860_ER 3195937 00 50 0K8642 maps_c7 330_860_ER 3195938 00 51 0K8643 maps_c7 350_860_ER 3195939 00 52 0K8707 maps_c7 300_860_RV 3195940 00 53 0K8645 maps_c7 330_860_RV 3195941 00 54 0K8646 maps_c7 350_860_RV 3195942 00 55 0K8647 maps_c7 360_925_RV 3195943 00 56 0K9048
Thanks#!/usr/bin/perl use strict; use warnings; use Tie::File; use Fcntl; $ENV{HOME}='C:\Documents and Settings\kompeS\Desktop\PERL SCRIPTS'; my $file= "$ENV{HOME}/partno_C7_5.03.4_prod"; my @array; my $line=""; my @data; my $map_dir=""; my $dir=""; my $part_no=""; my $chg_lvl=""; my $int_lock=""; my $t_spec=""; my @list=""; my $formatted_list=""; open (FILE,"$file"); close(FILE); tie (@data,'Tie::File',$file, mode=>O_RDWR) or die "Can't tie to $file +:$^E\n"; (tied @data)->defer; foreach (@data) { ($map_dir,$dir,$part_no,$chg_lvl,$int_lock,$t_spec) = split /\s+/; print "@list"; print "$formatted_list"; print " $map_dir,$dir,$part_no,$chg_lvl,$int_lock,$t_spec"; } (tied @data)->flush;
In reply to Problem with foreach loop by sas429s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |