in reply to Re^7: To read files from two dir
in thread To read files from two dir

Hi,

I was able to fix the issue to read from two directories. I added a variable for the second directory and used that throughout my code. That simplified the effort. I have another issue. Currently, I have this directory as

my $TOP_DIR = "$VTIERBASE/pvc/ohdr/instance-00

where the 00 in front of instance is derived from the hostname of the VM (zldcdabcdef14-vos-fxohr-correlator-00). digits after correlator- for example, the VMs may start from 00 to 99 I need to pass this value , /instance-xx dynamically How to do this?

Thanks,

Replies are listed 'Best First'.
Re^9: To read files from two dir
by hippo (Archbishop) on Apr 25, 2022 at 22:31 UTC

    The problem statement is a little vague. Perhaps see How to ask better questions using Test::More and sample data? Anyway here might be what you want.

    use strict; use warnings; use Test::More tests => 1; my $vmstr = 'zldcdabcdef14-vos-fxohr-correlator-00'; my ($digits) = $vmstr =~ /-(\d\d)$/; my $instance = "/instance-$digits"; is $instance, '/instance-00';

    🦛

      Can I use it as below?p/code>

      my $vmstr = "zldcdyh1bdce2d14-vcc-voipohdr-correlator-00"; my ($digits) = $vmstr =~ /-(\d\d)$/; my $VMinst = "/instance-$digits"; is $instance, '/instance-00'; my $SRC_DIR = "$VTIERBASE/pvc/ohdr/topology"; #my $TOP_DIR = "$VTIERBASE/pvc/ohdr/instance-0/preprocess" +; my $TOP_DIR = "$VTIERBASE/pvc/ohdr/VMinst/preprocess";

        Yes. You don't need the is line if you aren't testing and you will need a $ before VMinst in the last line, of course.


        🦛