How to resolve the algorithm File size step by step in the Perl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm File size step by step in the Perl programming language

Table of Contents

Problem Statement

Verify the size of a file called     input.txt     for a file in the current working directory, and another one in the file system root.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm File size step by step in the Perl programming language

Source code in the perl programming language

my $size1 = -s 'input.txt';
my $size2 = -s '/input.txt';


use File::Spec::Functions qw(catfile rootdir);
my $size1 = -s 'input.txt';
my $size2 = -s catfile rootdir, 'input.txt';


my $size1 = (stat 'input.txt')[7];  # builtin stat() returns an array with file size at index 7
my $size2 = (stat '/input.txt')[7];


  

You may also check:How to resolve the algorithm String concatenation step by step in the BQN programming language
You may also check:How to resolve the algorithm Associative array/Iteration step by step in the ATS programming language
You may also check:How to resolve the algorithm Monads/Writer monad step by step in the Ruby programming language
You may also check:How to resolve the algorithm Read entire file step by step in the Euphoria programming language
You may also check:How to resolve the algorithm Strip whitespace from a string/Top and tail step by step in the Common Lisp programming language