"Global symbol "@fields" requires explicit package name at get_maid_num.pl line 10."
That happens because you haven't declared the array @fields anywhere.
foreach $komp_dir(@komp_dir) { if (-d $komp_dir){ $komp_dir = split /\//; # splitting what?
See split: it operates per default on $_ and returns a list. However, you are assigning the results of split to a scalar, which is also your loop iteration variable.
($komp_dir = $fields[6]) =~ /(^\d*)_(\w*)$/;
No @fields. I guess you meant:
foreach $komp_dir(@komp_dir) { if (-d $komp_dir){ my @fields = split /\//, $komp_dir; $fields[6] =~ /(^\d*)_(\w*)$/ and print "$1\n"; } }
You don't need next there, because, as written, there is no statement after the 'next', so there's no need to jump to the beginning of the loop to evaluate the next element - that would happen anyways.
In reply to Re: Issue with capturing a string after splitting on "/"
by shmem
in thread Issue with capturing a string after splitting on "/"
by lomSpace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |