Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: one-line split file sequence checker

by poolpi (Hermit)
on Jan 24, 2008 at 13:28 UTC ( [id://664010]=note: print w/replies, xml ) Need Help??


in reply to one-line split file sequence checker

With files :
file.1 file.02 file.003 file.5 file.00007 file.011
perl -e '/\.0*(\d+)$/and$t[$1]=1for<*>;map{$t[$c]?1:print"$c ";$c++}@t'
Output :
4 6 8 9 10

HTH,

PooLpi

'Ebry haffa hoe hab im tik a bush'.  Jamaican proverb

Replies are listed 'Best First'.
Re^2: one-line split file sequence checker
by wdef2 (Acolyte) on Jan 24, 2008 at 15:43 UTC
    Nice, thx. Could golf slightly further I suppose to:

    perl -e '/(\d+)$/and$t[$1]=1for<*>;while($c<$#t){$t[++$c]||print "$c "}'

    I like that since it seems quite readable as well (at least for me) Though is map more efficient than while?

      map may or may not be more efficient, but it's certainly shorter:

      perl -le '/(\d+)$/and$t[$1]=1for<*>;map$t[$_]||print,1..$#t'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-26 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found