Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Sorting using the highest last column criteria

by Bethany (Scribe)
on Jul 27, 2014 at 15:22 UTC ( [id://1095242]=note: print w/replies, xml ) Need Help??


in reply to Sorting using the highest last column criteria

What have you tried so far, and what results did you get?

You'll get much better replies if you show what effort you've already put into solving your problem, how far you've got toward a solution, and what parts you don't understand. This is especially true when it comes to help with homework assignments. It's also helpful to let others know how much experience you have with Perl, from "none at all" to "I've read a quick introduction and written a few simple scripts."

The more (relevant) information you provide, the better others will be able to guide you.

(edited to add) Oh, and the Anonymous Monk above is right -- you should definitely check out the Guide to the Monastery. I think this part of the FAQ is the most important for newcomers: How do I post a question effectively?

  • Comment on Re: Sorting using the highest last column criteria

Replies are listed 'Best First'.
Re^2: Sorting using the highest last column criteria
by deepakshyl (Novice) on Jul 27, 2014 at 17:23 UTC
    #!/usr/bin/perl #use strict; use warnings; open FILE,"out07.txt"; my @fields = split / /, <FILE>; chomp @fields; my @lines = split (/(\n)/, "@fields"); for (@lines) { print @fields,"\n"; }

      Okay, that's a start. I see some problems that you should be able to fix.

      When I'm not sure why a script isn't doing what I expect, a good exercise is to write a comment before each line telling what I think that line of code should do. If it's a complicated line I write a comment for each part of the line. (This is a variation on "rubber duck debugging".)

      Then I add debugging code to print out the results after each step. This way I can find where things stop behaving as I expect them to behave.

      You won't learn much if someone just tells you "do this instead" and provides a ready-to-use solution. If you work it out for yourself you will have learned not only how to fix this problem but also how to approach the next problem you have to solve.

      Past this advice, as AppleFritter pointed out, you'll need to understand what you want your results to look like -- and you'll have to tell this to the people you're asking for guidance. Post an example of the output you'd like your code to produce.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found