It is something like this:
!#/usr/bin/perl -w use strict; use Net::FTP; my $hostname = "sample-host"; my $ftp = Net::FTP->new($hostname); $ftp->cwd("mypath"); my @cat1 $ftp->ls("h?_*"); my @cat2 $ftp->ls("*-zips"); print "category 1:\n", join "\n",@cat1; print "category 2:\n", join "\n",@cat2; <>;
I think I must prefer globbing than regex since not all user that will use my program has knowledge in regex.
I have tried converting all * and ? into .* and .? respectively and use regex but before I finish coding it I thought about the "+" character which is a valid char for naming file or directory. It will be a problem when a file/folder contains a "+" char. since it is a special char in regex. And there are many other special char in regex which i don't want to make a code just to escape them all.
It seems that it will become complicated if i use regex. What should I do..?
In reply to Re^4: Get contents in an FTP path using glob
by toastbread
in thread Get contents in an FTP path using glob
by toastbread
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |