in reply to Re^2: Finding the parent of a text in a file
in thread Finding the parent of a text in a file

Saying "(with minimal changes), the code didnt work " without showing what the changes were and why the code didn't work is an insult to all programmers everywhere.

You owe me an apology.

You also owe me test cases for the change of requirements you made.

  • Comment on Re^3: Finding the parent of a text in a file

Replies are listed 'Best First'.
Re^4: Finding the parent of a text in a file
by ExperimentsWithPerl (Acolyte) on Sep 05, 2015 at 20:06 UTC
    Hello Anonymous Monk, Apologies for the inconvenience.
    I was about to respond to you but Couldn't login today due to Wifi issues.
    Is there any way I can send attachments here because the code and examples are looking really messy when I am pasting it here.
    If there is no way to send attachment then I will the code anyhow.
    Again I would mention that I am new to this language, and have no intention to insult the monks who are helping me.

      Is there any way I can send attachments ...

      I don't know about attachments per se, but you do have a public scratchpad where you can post something temporarily for viewing or pickup by others. However, it's public, so if you don't want it potentially seen by all and sundry, best find another way. (You also have a private scratchpad, but I think that's for you alone; you cannot grant access unless you give someone your password, allowing them to sign on as you.) I say the scratchpads are "temporary," but I don't really know the policy on this. I do know I've had some stuff on my scratchpads for quite a while and it's never been touched by the PsTB, nor has there ever been any suggestion about any sort of cleanup. Of course, if you start posting mega- or gigabytes of stuff, you may attract the attention of janitors (see What do Janitors do?) or even Gods!


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

        Please find below the modified code :-
        #!/usr/bin/perl # http://perlmonks.org/?node_id=1140982 use Algorithm::Diff qw(traverse_sequences); #use strict; #use warnings; open (FH , "<123") or die $!; open (FH2 , "<456") or die $!; my @file1 = <FH>; my @file2 = <FH2>; sub fullpath { my @full; my @answer; for my $line ( shift() =~ /.+\n/g ) { $line =~ /^( *)/; $#full = length($1) - 1; # truncate array push @full, $line; push @answer, join '', grep defined, @full; } return \@answer; } print @file1; print @file2; my $len1 = scalar(@file1); print "len1 : $len1\n"; my $len2 = scalar(@file2); print "len2 : $len2\n"; for (my $i==0 ; $i < $len1 ; $i++) { for (my $j==0 ; $j < $len1 ; $j++) { if ($i==$j) { my $line1 = $file1[i]; my $line2 = $file2[j]; my $full1 = fullpath($line1); my $full2 = fullpath($line2); } } } traverse_sequences( $full1, $full2, { # DISCARD_A => sub {print $full1->[shift()], "\n"}, } );

      Answers needed:

      1) how large are your input files (in lines)?

      2) What OS are you running on?

      3) Are your input files always the same length (in lines)? With only some words changed? Or with whole new lines added?


        1) how large are your input files (in lines)?
        Ans : 13000 lines

        What OS are you running on?
        Ans : Sun Solaris and Linux

        Are your input files always the same length (in lines)? With only some words changed? Or with whole new lines added?
        Ans: The number of inputs lines and their contents vary depends on platform.