in reply to Reading part of a file name
If your file names are consistently like your example, use split :
use strict; use warnings; opendir( DIR, "/home/Lhamo/files" ) or die "painfully: $!"; my @files = readdir DIR; closedir DIR; for ( @files ) { next if ( $_ eq '..' ); next if ( $_ eq '.' ); my ( $filename, $code_number ) = split( /./, $_, 2 ); print "$code_number\n"; }
I made a mistake. I don't know where, but I always do. I haven't tested this code. Someone will point it out shortly :) In any case, you get the idea.
-- -- GhodModeBlessed is he who has found his work; let him ask no other blessedness.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading part of a file name
by johngg (Canon) on Apr 05, 2006 at 13:03 UTC |