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

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';

🦛

Replies are listed 'Best First'.
Re^10: To read files from two dir
by pragovnj (Acolyte) on Apr 26, 2022 at 15:05 UTC

    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.


      🦛

        Hi,

        A slight change. The VMs are numbered as 0 to 99 and not 00 to 99 as I wrongly assumed :( How to modify your code so that it can identify 0,1,2 ...99?