Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Compare elements of a line in a file

by oxydeepu (Novice)
on Sep 13, 2012 at 08:21 UTC ( [id://993418]=note: print w/replies, xml ) Need Help??


in reply to Re: Compare elements of a line in a file
in thread Compare elements of a line in a file

Thank you for the reply.

I have these data inside a file. So how am I supposed to format? This code is direct from command line right?

Thank you
Deepak

Replies are listed 'Best First'.
Re^3: Compare elements of a line in a file
by frozenwithjoy (Priest) on Sep 13, 2012 at 08:32 UTC
    So, based on the code you posted in response to Dave, you should be able to replace your foreach loop with:
    foreach (sort keys %h) { @n = split /\t/, $h{$_}; map {say if $_ > $last+50; $last = $_} @n; }

      Thank you.

      I will try that snippet.

      Thank you.

      I will try that snippet. If you don't mind can you tell me what does it do?

        Unless I've made a typo, the following two snippets should be equivalent:
        my $last = -50; # set to -50 so that the first coordinate will be incl +uded as long as it is 1 or more map {say if $_ > $last + 50; $last = $_} @n;
        my $last = -50; for (@n) { if ($_ > $last + 50) { say $_; } $last = $_; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://993418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found