From: "minky arora" <[EMAIL PROTECTED]> > Here is my code: > !/usr/bin/perl > > use strict; > open FILE, "/users/meenaksharora/db.txt" or die"cnt open $!"; > my($fname,$lname,$address,$lline,$line,@db); > foreach my $line(<FILE>){ > $fname=substr($line,0,10); > $lname=substr($line,10,15); > $address=substr($line,16,25); > > $lline=substr($line,59,13);
my ($fname,$lname,$address,$lline) = ($line =~ /^(.{10})(.{15})(.{25})(.{13})/); > $fname=~s/\s+/ /; > $lname=~s/\s+/ /; > $address=~s/\s+/ /; > $lline=~s/\s+/ /; for ($fname,$lname,$address,$lline) { s/\s+/ /; # you sure? Replace the first group of spaces by a single one? } > print "$fname $lname\n"; > print "$address\n"; > print"$lline\n"; > } > > Now each record as I calculated is of a fixed lenght of 75 chars.I > need some idea as to how to run the Loop to print all such > records.Right now I am only able to print the first record, If the file doesn't contain lines, but fixed length records you should either use read() or set $/ = \75; see perldoc -f read and perldoc perlvar If you modify $/ you should do so for the smallest part of the code possible ... I would rather use read() myself. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/