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

Re: sort on numbers embedded in text

by Shendal (Hermit)
on Oct 09, 2000 at 19:21 UTC ( #35918=note: print w/ replies, xml ) Need Help??


in reply to sort on numbers embedded in text

Although from your question it is a bit unclear what you are looking for, perhaps the following code segment will help.

#/usr/bin/perl -w use strict; foreach (sort split /\s+/,<DATA>) { /^\d/ ? print "FH1: $_\n" : print "FH2: $_\n"; } __DATA__ 953-FMT-FMT 954-FMT-FMT BLOGO93-FMT-FMT 955-FMT-FMT BOXSTART2- +FMT-FMT BOXEND2-FMT-FMT 956-FMT-FMT 413-FMT-FMT DATE1-FMT-FMT + 414-FMT-FMT 415-FMT-FMT 416-FMT-FMT BLOGO107-FMT-FMT 417-F +MT-FMT 419-FMT-FMT 418-FMT-FMT BLOGO63-FMT-FMT 393-FMT-FMT +394-FMT-FMT BLOGO75-FMT-FMT 420-FMT-FMT 421-FMT-FMT 395-FMT-F +MT
Which outputs...
FH1: 393-FMT-FMT FH1: 394-FMT-FMT FH1: 395-FMT-FMT FH1: 413-FMT-FMT FH1: 414-FMT-FMT FH1: 415-FMT-FMT FH1: 416-FMT-FMT FH1: 417-FMT-FMT FH1: 418-FMT-FMT FH1: 419-FMT-FMT FH1: 420-FMT-FMT FH1: 421-FMT-FMT FH1: 953-FMT-FMT FH1: 954-FMT-FMT FH1: 955-FMT-FMT FH1: 956-FMT-FMT FH2: BLOGO107-FMT-FMT FH2: BLOGO63-FMT-FMT FH2: BLOGO75-FMT-FMT FH2: BLOGO93-FMT-FMT FH2: BOXEND2-FMT-FMT FH2: BOXSTART2-FMT-FMT FH2: DATE1-FMT-FMT

Cheers,
Shendal


Comment on Re: sort on numbers embedded in text
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-04-20 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls