Search code examples
perlperforceperl-module

How to read a file which is on server using perl script


I have a file on my perforce client which i can read from the client but i want to read it from the depot instead from my client and i Have to achieve this using a Perl script and my client name is ata and its root directory is /home/ata/hw The following code is written for the file on my client

my $clients_file="/home/ata/hw/hard/ip/golden_design_map.cfg";
open(READ,"<$clients_file") or die "Couldn't open the file for reading:$!";

But this is what i want to achieve

my $clients_file="//hw/hard/ip/golden_design_map.cfg";
open(READ,"<$clients_file") or die "Couldn't open the file for reading:$!";

Here //hw/hard/ip/golden_design_map.cfg is the file on the depot or the server. Is there any module which i can use.Any help is truly appreciated.Thanks in advance.


Solution

  • You could use File::Remote module.

    Synopsis:

    use File::Remote;
    
    # read from a remote file
    open(REMOTE, "host:/remote/file") or die $!;
    print while (<REMOTE>);
    close(REMOTE);