--- PRADEEP GOEL <[EMAIL PROTECTED]> wrote: > i have a file(say f1) containing patch names > pach_2377 > pach_2676 > pach_3897 > I want to check if there are(is) patch _id(s) which r greater than > given patch_id > (say : pach_2579) > pls tell me how to do that in perl > i.e. > while (<f1>) { > $ch = $_; > if ($given_patchid gt $ch ) ###### pls tell me how to exactly do > it > < do some action> > } > ### should i extract last digits - then to extract them ? > > u can also write me how to sort & store the result in a file
Here's my take: given argument "pach_2579", my $floor = shift; # $floor now = "pach_2579" my($num) = $floor =~ /_(\d+)$/; # $num now 2579, parens required open F1, "f1" or die $!; # ALWAYS check the open! open F2, ">f2" or die $!; # that's the output file print F2 sort grep { # print the sorted matches to f2 my($cmp) = /_(\d+)$/; # get the line's patch number $cmp >= $num; # compare it } <F1>; # while reading from the file close F1; close F2; Now f2 should be all the lines greater or equal. Writing this off the top of my head as usuall, so if anyone see a hole, please share. Finally, your phrasing seems a little assuming. My apologies if it wasn't intended to be so, but you shouldn't ask the list to solve your problems, exactly -- rather to help you do so. Granted, in this case it was pretty easy to write out what is probably a quick solution, but because of the way you asked, I wasn't inclined to really explain it the way I might've otherwise. Still, if anyone on the list is confused by my rambling solution, please feel free to write me and ask, and I'll be happy to elaborate to the whole list. Good morning, everyone. =o) Paul PS - a pet peeve which the rest of the list may or may not share; proper grammar, spelling, and punctuation always make me more likely to respond helpfully. "which r greater" and "pls tell me" communicate the point well enough, but this is a forum where you want to maximize the odds of someone helping, yes? :) PH __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]