Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

question about ordering technical data numbers

by Kevin_Raymer
on Mar 09, 2007 at 17:05 UTC ( #604011=perlquestion: print w/ replies, xml ) Need Help??
Kevin_Raymer has asked for the wisdom of the Perl Monks concerning the following question:

Okay I am going to be really technical here don't mean to throw off anyone and I am not trying to brag...

I am trying to do ordering of numbers that are in the end of a list of data

So I am trying to use PERL SORT:
SORT [/R] [/+n] [[drive1:][path1]filename1] [> [drive2:][path2]filena +me2] [command |] SORT [/R] [/+n] [> [drive2:][path2]filename2]
This seems to be the syntax which is easy for me to figure out cause I am an old hacker! What I don't get is the perl part of it

#!/usr/bin/perl use strict; OPEN "filename"/n"; COUNT |||||| #this counts spaces over in the list SORT /R #this sorts my data
This spews all kinds of computer generated errors....
Bareword "COUNT" not allowed while "strict subs" in use at ./order.pl +line 5. syntax error at ./ray.pl line 5, near "||||" Bareword "SORT" not allowed while "strict subs" in use at ./order.pl l +ine 6. Bareword "R" not allowed while "strict subs" in use at ./order.pl line + 6. Execution of ./ray.pl aborted due to compilation errors. Bareword "OPEN" not allowed while "strict subs" in use at ./order.pl l +ine 5. String found where operator expected at ./order.pl line 5, near "OPEN +"filename"" (Do you need to predeclare OPEN?) syntax error at ./order.pl line 5, near "OPEN "filename"" Bareword "n" not allowed while "strict subs" in use at ./order.pl line + 5. String found where operator expected at ./order.pl line 5, at end of l +ine (Missing semicolon on previous line?) Can't find string terminator '"' anywhere before EOF at ./order.pl lin +e 5.
I know this is pretty technical but if anyone out there could offer some tips ..I am not trying to "compile" anything either so these errors don't make much sense to me

Unconsidered for reap - Votes: Keep: 11, Edit: 0, Reap: 9

Comment on question about ordering technical data numbers
Select or Download Code
Re: question about ordering technical data numbers
by Joost (Canon) on Mar 09, 2007 at 17:10 UTC
Re: question about ordering technical data numbers
by Sixtease (Friar) on Mar 09, 2007 at 18:39 UTC

    Hi Kevin,

    I don't understand exactly what you're trying to sort but if you wish to sort the lines in a file, then this command would do the job:

    perl -e 'print sort <>' file_to_sort.txt

    You'll get the sorted lines on stdout, you may wish to redirect it to a file.

    By the way, notice that perl is case-sensitive, which is why OPEN and SORT are giving you errors. The functions are open and sort, lowercase.

Re: question about ordering technical data numbers
by ysth (Canon) on Mar 09, 2007 at 19:44 UTC
    Dear Mr. Raymer,

    This was a pretty big problem for me, but I got it after trying lots. I'm good at technical things like this because I have 19 years of experience doing object oriended programming. PERL is hard, but you can make it do what you want if you just keep trying. I wanted other people to be able to use my program, so I couldn't use my varibels, and its hard to get it to do that.

    use strict; use warnings; ${\our %kev}{$ARGV[$_]}++ and splice @ARGV, $_, 1 for reverse 0..$#ARG +V; !defined( $_ = <> ) ? do { scalar( delete( ${\our %kev}{$$_[0]} ) && o +pen(KEV, ">", $_->[0]) xor print KEV $$_[2] ) for do { use vars '@kev +'; @kev }; exit }: ( push( @{\our @kev}, [$ARGV, (split(" ", $_))[-1] +, $_] ), our @kev = sort { $a->[0] cmp $b->[0] or $b->[1] <=> $a->[1] + } @kev ) while 1;
Re: question about ordering technical data numbers
by ptum (Priest) on Mar 09, 2007 at 19:52 UTC

    Silly Kevin. Please stop being a troll, or at least try to be a clever and funny troll.

    Because I read some of your other posts, I was pre-disposed to think you are a troll. (My definition: A troll is someone who attempts to provoke discussion and dispute for his own amusement without investing in the community which he trolls.) So I ran you through my troll-o-meter, with the following results:

    question about ordering technical data numbers

    +3 troll points.

    Rationale: Your title doesn't begin title with a capital letter, just the sort of carelessness a troll will demonstrate. The title contains three unnecessary words (question, technical, and data). We know it is a question, the word 'technical' is meaningless in this context, and either data or numbers are redundant, depending on what kind of data elements you are sorting.

    Okay I am going to be really technical here don't mean to throw off anyone and I am not trying to brag...

    Two more troll points.

    Rationale: You're posting on a website about Perl (by definition, rather technical) yet you're supposedly worried about 'throwing people off' or being 'really technical'.

    I am trying to do ordering of numbers that are in the end of a list of data

    Another troll point.

    Rationale: many real programmers would talk about 'ordering data' rather than 'do ordering', but the real issue is that this sentence doesn't really make any sense. You want to order numbers that are at the end of a list of data -- what about the data at the beginning and middle of the list? When you use the word 'list', many Perl developers will think 'array', but this sentence doesn't really make sense in that context, at least for me. Trolls often fail to make sense, and they often forget periods at the end of their sentences.

    So I am trying to use PERL SORT:

    Another troll point.

    Rationale: while lots of people use PERL as an acronym, most people don't keep doing it, especially after being gently corrected, as you were. When people keep doing things that they know annoy others, this is sometimes because they desire attention or are amused by stirring up annoyance in others, both classic troll behaviors.

    The next section didn't earn you any troll points, because you actually used code tags, possibly based on prior advice. Of course, the snippet you posted has nothing to do with Perl, but maybe you'll still get to something Perl-related. Trolls don't usually learn, so maybe you're not a troll?

    This seems to be the syntax which is easy for me to figure out cause I am an old hacker! What I don't get is the perl part of it

    Sigh. Another two troll points.

    Rationale: trolls like to brag, yet here you are supposedly asking for help. Real people who ask for real help that way don't get help; therefore you are likely a troll. I don't think most serious folks use the word 'hacker' quite like you do. Also, we see now you use 'perl' (often used to refer to the perl interpreter) when you probably mean 'Perl'.

    Summarizing the rest of your post, you get another two troll points for the phrase 'computer generated errors', and for your comment about "compiling". Also, you use the word 'technical' again.

    Total score: 11 troll points.

    In the unlikely case that you are a serious, real person, please stop these troll-like behaviors (or try to be more funny). If you are a troll, please go away.

      Now, you see here . . . our troll meter goes to eleven. That's one more, isn't it? You see most trolls, you know, will be trolling at ten. You're on ten here, all the way up. All the way up. Where can you go from there? Where?

        I don't know...
Re: question about ordering technical data numbers
by blue_cowdawg (Monsignor) on Mar 09, 2007 at 22:23 UTC

    When sorting pearls you have to remember to not only sort them by size, but you also have to sort them by color and quality.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: question about ordering technical data numbers
by Ojosh!ro (Beadle) on Mar 12, 2007 at 15:56 UTC

    Hehehe, the only thing I understand is the perl part.But that dramatically ends after use strict;
    It makes the ,,old hacker'' remark all the funnier.
    Thanks for the giggle, I'm back to meditating now.

    if( exists $aeons{strange} ){ die $death unless ( $death%2 ) }
Re: question about ordering technical data numbers
by xorl (Deacon) on Mar 16, 2007 at 17:21 UTC

    see sort

    You've got to learn that Perl is not DOS. You've been a "hacker" for how long and have now many degrees and you still haven't figured this out?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-22 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (112 votes), past polls