On 09/28/2017 09:53 PM, ToddAndMargo wrote:
On 09/28/2017 09:45 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 12:41 AM, ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

    Does perl 6 have an equivalent to bash's "-f" to
    see if a file exists?  Or is that a system call?


IO::Path's .f method. (Or .e to not require it to be a file, etc. as usual.)

     pyanfar Z$ 6 '".profile".IO.f.say'
     True

Hi Brandon,

How do I get this to give me a "False" instead of crashing
and wagging the finger at me?

$ perl6 -e 'say "eraseme.txt".IO.f;'
True

$ perl6 -e 'say "erasxeme.txt".IO.f;'
Failed to find '/home/linuxutil/erasxeme.txt' while trying to do '.f'
   in block <unit> at -e line 1

Many thanks,
-T


    method f

    Defined as:

    method f(--> Bool:D)

    Returns True if the invocant is a path that exists and is
    a file. The method will fail with X::IO::DoesNotExist if
    the path points to a non-existent filesystem entity.

maybe it is suppose to crash?





--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to