in reply to Issue with capturing a string after splitting on "/"
If you are not interested in anything other than the number component of all subdirectories, I would recommend skipping the splitting all together, and perhaps this would be more of what you need:
#!/usr/bin/perl use strict; use warnings; my $path ='/Users/mydirectory/Desktop/BioinfDev/SequenceAssemblyProjec +t/KOMP/'; my @komp_dir = glob("$path\*"); foreach my $entry (@komp_dir) { if (-d $entry ){ if ($entry =~ /\/(\d+)_\w*$/) { print "$1\n"; } } }
or, more succinctly
#!/usr/bin/perl -w use strict; my $path = '/Users/mydirectory/Desktop/BioinfDev/SequenceAssemblyProje +ct/KOMP/*'; foreach (glob("$path\*")) { print "$1\n" if (-d and /\/(\d+)_\w*$/); }
As a final note, apparently I type vvvveerrryyy ssssllllooowwwlllllyyyyy....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Issue with capturing a string after splitting on "/"
by lomSpace (Scribe) on Feb 06, 2009 at 15:50 UTC |