sorting file

Discussion in 'Programming' started by ssimon171078, Dec 17, 2009.

  1. #1
    my problem is to sort emails.txt that in emails.txt will not be emails with gmail.com

    i started to write:
    #!/usr/local/bin/perl
    open (MYFILE, 'emails.txt');
    while ($line=<MYFILE>) {
    chomp;
    print $line;
    }
    close (MYFILE);

    how to modify this code?
     
    ssimon171078, Dec 17, 2009 IP
  2. shall

    shall Member

    Messages:
    111
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #2
    open(MYINPUTFILE, "<emails.txt");
    @dataarray = <MYINPUTFILE>;
    @sort = sort(@dataarray);
    close(MYINPUTFILE);
    open(MYINPUTFILE, ">emails.txt");
    foreach $name (@sort)
    {
    chomp;
    print MYINPUTFILE "$name";
    }
    close(MYINPUTFILE);

    This should help :D
     
    shall, Dec 18, 2009 IP