Hello Dermot, Wednesday, November 14, 2001, Dermot Paikkos <[EMAIL PROTECTED]> wrote:
DP> I am having trouble getting the data I want out of a text file: The file has DP> this sturcture: DP> File Name: m:\a\a084099.jpg DP> Width x Height: 2480 x 2062 DP> Number of Colours: True Colour (24 bits) DP> Dots per inch: 300 x 300 DP> Image size (inches): 8.27 x 6.87 DP> Raw size: 15341280 Actual size: 1203289 (Compression ratio: 12.8:1) DP> There a thousand or so entries. Each entry is separated by a blank new line. DP> I want to get just the file name and the last line. My troulbe is I can't DP> manage to parse it correctly. The best I have been able to get is: DP> m:\a\a084100.jpg Uncompressed Size: 15341280 Actual size: 1203289 DP> m:\a\a084100.jpg Uncompressed Size: 15341280 Actual size: 1203289 DP> m:\a\a084100.jpg Uncompressed Size: 15341280 Actual size: 1203289 DP> m:\a\a084100.jpg Uncompressed Size: 15341280 Actual size: 1203289 DP> m:\a\a084100.jpg Uncompressed Size: 15341280 Actual size: 1203289 DP> m:\a\a084100.jpg Uncompressed Size: 15006480 Actual size: 1251205 DP> m:\a\a084100.jpg Uncompressed Size: 15006480 Actual size: 1251205 DP> The lines get repeated 7 times before getting the next entry. I used: DP> while (<REPORT>) { DP> if (/File/gc) { # I tried with or without gc but it made no difference. /gc useless here. why not use if (/File Name: /) { DP> $name = $'; , and remove 2 next lines? DP> chomp($name); DP> ($file = $name) =~ s/ Name: //; DP> } DP> if (/Raw/) { DP> $size = $'; DP> chomp($size); DP> ($foo = $size) =~ s/\((Compression...*)//; DP> ($bar = $foo) =~ s/size/Uncompressed Size/; DP> } DP> print OUTPUT "$file $bar \n"; move your print inside if (/Raw/) { } to avoid useless repetitions. while (<REPORT>) { chomp; if (/File Name: /) { $name = $'; } if (/Raw/) { $size = $'; $size =~ s/\((Compression...*)//; $size =~ s/size/Uncompressed Size/; print OUTPUT "$name $size \n"; } } Best wishes, Maxim mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]