in reply to Re: How can I keep the first occurrence from duplicated strings?
in thread How can I keep the first occurrence from duplicated strings?
You could just reverse the order of the lines in the file...
use strict; use warnings; my @lines = reverse(<DATA>);
This will read the entire file into RAM. No problem for 100 kBytes, big trouble for big files (larger than free RAM). The solutions from choroba, Grandfather, eyepopslikeamosquito, and the second solution from tybalt89 do not suffer from that problem, because they all read only one line at a time.
Alexander
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: How can I keep the first occurrence from duplicated strings?
by haukex (Archbishop) on Aug 30, 2023 at 10:54 UTC | |
Re^3: How can I keep the first occurrence from duplicated strings?
by Bod (Parson) on Aug 30, 2023 at 11:10 UTC | |
by hippo (Archbishop) on Aug 30, 2023 at 13:15 UTC | |
by eyepopslikeamosquito (Archbishop) on Sep 01, 2023 at 02:06 UTC | |
by marto (Cardinal) on Aug 30, 2023 at 11:16 UTC | |
by eyepopslikeamosquito (Archbishop) on Aug 30, 2023 at 13:48 UTC |