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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.