Thread Array Werte (14 answers)
Opened by Iggy86 at 2012-08-03 09:32

Molaf
 2012-08-03 10:03
#160549 #160549
User since
2007-10-11
119 articles
BenutzerIn
[default_avatar]
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl

use strict;
use warnings;

my $filename = 'DateiMitStringsDrin.txt';

my @array = ();

if (open my $file, '<', $filename)
        {my @lines = <$file>;
        close $file;
        # Zeilenumbrüche entfernen
        chomp @lines;
        my %test = ();
        for (@lines)
                {# prüfen, ob NICHT in %test vorhanden (unless)
                unless (exists $test{ $_ })
                        {# ins Array schieben
                        push @array, $_;
                        # in %test merken
                        $test{ $_ } = 1;
                        }
                }       
        }
# test
print $_."\n" for @array;

View full thread Array Werte