Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# ST logic

Posted on 2001-06-10
Medium Priority
201 Views
sub ST(&@)
{
my \$metric=shift; map{\$_->[0]} sort{\$b->[1]<=>\$a->[1]} map{[\$_,&{\$metric}]} @_;
};

print NEWFILE ST{return (split/\|/)[1]}<OLDFILE>;

# What corresponds to the above code in one line?
# (How do I remove the subroutine?)
0
Question by:superquestions
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 84

Accepted Solution

ozo earned 100 total points
ID: 6173888
#assumng (split/\|/)[1] are integers
print NEWFILE map{/\|(.*)/s}sort map{join'|',5e14-(/\|([^|]*)/)[0],\$_}<OLDFILE>;
0

LVL 1

Author Comment

ID: 6174861
# The complete code is like this:

@list=("joined.txt","posted.txt");

sub ST(&@)
{
my \$metric=shift; map{\$_->[0]} sort{\$b->[1]<=>\$a->[1]} map{[\$_,&{\$metric}]} @_;
};

foreach \$file(@list)
{
open(OLDFILE, "<\$file.txt");
flock OLDFILE, 1;

open(NEWFILE, ">\$file.tmp");
flock NEWFILE, 2;

print NEWFILE ST{return (split/\|/)[1]}<OLDFILE>;

close(NEWFILE);
close(OLDFILE);
};

# Is it an intenger?
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
###### Suggested Courses
Course of the Month10 days, 2 hours left to enroll