Hello alokranjan,
my $cname = "$File::Find::name"; #prints location of file my @chunks = split '/', $cname; $country = $chunks[4];
Update 1: Added the code snippet quotation.
If the full path+filename is /home/alok/countries/London, then the call to split produce a 4-member list. But the fourth element (London) of the array @chunks is $chunks[3], because array indices start at zero.
Update 2: alokranjan is correct, of course: the first element is the empty string. Note to self: always test before posting! Sorry for the noise. :-(
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Grep a word and print the filename
by Athanasius
in thread Grep a word and print the filename
by alokranjan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |