in reply to Issue with capturing a string after splitting on "/"
I hope it helps ! The problem came from the "use strict" and the loop variable being not declared at main level :#!/usr/bin/perl use strict; my $komp_dir ='/Users/mydirectory/Desktop/BioinfDev/SequenceAssemblyPr +oject/KOMP/'; my @komp_dir_content = glob("$komp_dir/*"); my $k_dir; foreach $k_dir(@komp_dir_content) { if (-d $k_dir){ $k_dir =~ s(.*/)(); next if ( $k_dir !~ /^\d+_/); $k_dir =~ s(_.*)(); print "$k_dir\n"; next; } }
either don't use "use strict" or declare the loop variable (became $k_dir here)
I changed a little variable-names because I think reusing the same name for different usages is an unuseful risk for programs maintenance.
But, of course, you're quite free ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Issue with capturing a string after splitting on "/"
by lomSpace (Scribe) on Feb 06, 2009 at 15:46 UTC |