Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Sort alphabetically from file

by hippo (Archbishop)
on Jun 14, 2019 at 15:12 UTC ( [id://11101357]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Sort alphabetically from file
in thread Sort alphabetically from file

You'll need to open the file first. eg:

open my $in, '<', 'file.txt' or die "Cannot open file for reading: $!" +; print sort { ($a =~ /\S+\n$/g)[0] cmp ($b =~ /\S+\n$/g)[0] } <$in>; close $in;

See open and close for all the details.

Replies are listed 'Best First'.
Re^4: Sort alphabetically from file
by edujs7 (Novice) on Jun 15, 2019 at 09:49 UTC
    This worked - thanks so much :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-06-24 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.