Need help understanding perl code

Pankaj Jaiswal

I am a beginner in perl. Just wanted to understand the following code.

sub get_files {
    foreach my $customer (keys %customers){
        lg("Getting files from ftp for customer $customer", "LOG");
        my $ftp_server = $customers{$customer}{'FtpServer'};
        my $ftp_user   = $customers{$customer}{'FtpUser'};
        my $ftp_pass   = $customers{$customer}{'FtpPass'};
        my $datadir    = $datafiles.$customer."/";


        `$get_files $ftp_server $ftp_user $ftp_pass $datadir`;

    }
}

What does last line in the above subroutine tells?

Alnitak

It invokes the command that's in the string $get_files, passing the command the remaining strings as parameters.

Usually it's used if you want to capture the resulting output and store it in a variable. In this case where the result is being discarded it would be more usual to use system instead:

system $get_files, $ftp_server, $ftp_user, $ftp_pass, $datadir;

although if the command does then produce any output it'll appear on-screen instead of being absorbed by the back-ticks operator.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Need help understanding this perl code

From Dev

Need help understanding Perl code- Multi process / fork

From Dev

Need help understanding this Perl snippet

From Dev

Need help understanding Python Code

From Java

Need help understanding what this C code does

From Dev

Need help understanding GCC assembly code

From Dev

Need help understanding pointers in given code

From Dev

I need help understanding this java code

From Dev

I need help understanding part of a code - Python

From Dev

Need help understanding this C Code (Array)

From Dev

learning C#, need help understanding this code

From Dev

need some help understanding an aspect of this code

From Dev

Need help understanding some code sample?

From Java

Need help in understanding Scale

From Dev

Need help understanding this operation

From Dev

Dagger: need help in understanding

From Dev

Need help understanding this line

From Dev

Need help understanding an algorithm

From Dev

I need help understanding this line of code dynamically creating an array?

From Dev

I am new to php and I need help understanding this code

From Dev

pointer int in C, need help understanding and simplifying code snippet

From Dev

Help understanding the bash code?

From Dev

Need help in understanding this SQL query

From Dev

need help understanding ngRepeat with filter

From Dev

Need help understanding this Ngrx effect

From Dev

Need help understanding the Shadow DOM

From Dev

Need help understanding threads in Java

From Dev

Need help understanding LINQ in MVC?

From Dev

Need Help Understanding Javascript Closure