in reply to Re: comparing lines of data
in thread comparing lines of data

Thankyou tybalt89

Could I ask another ?

Could you adjust that code so that it will read the input data from a file called input.txt

and print the match data to match.txt and no match.txt ?

Or should I ask as a new question ?

Thanks again :)

Replies are listed 'Best First'.
Re^3: comparing lines of data
by AnomalousMonk (Archbishop) on Nov 16, 2019 at 01:51 UTC
    Could I ask another ?

    No! (Just kidding :)

    ... adjust that code so that it will read the input data from a file ... and print the match data to [files] ...

    Please see also perlintro, open, perlopentut, and some of the articles in Input and Output, such as File Input and Output (but use the modern "three argument" call to open; the latter article is old and often uses "global" filehandles in its examples).


    Give a man a fish:  <%-{-{-{-<

Re^3: comparing lines of data
by harangzsolt33 (Deacon) on Nov 16, 2019 at 01:03 UTC
    To read from a file, all you have to do is :

    my $Filename = “...”; my $Filehandle; open $Filehandle, ‘<‘, $Filename or die “cant open file.\n”; my @Lines = <$Filehandle>; close $Filehandle; ...

      Better to let open report why opening fails should that occur:

      open(my $fh, "<", $filename) or die "Can't open $filename: $!";