in reply to Re^6: appending a variable
in thread appending a variable

my ($opstr) = $vmstr =~ /-(\d\d)$/; will result in an undefined value for $opstr because there is only one digit after the "-" instead of 2 digits.
Better: >my ($opstr) = $vmstr =~ /-(\d+)$/;

Why are you ignoring the warnings and errors that Perl is printing out?

Always put:

use strict; use warnings;
at the top of your script.

Replies are listed 'Best First'.
Re^8: appending a variable
by pragovnj (Acolyte) on Apr 29, 2022 at 13:35 UTC
    Hi,

    my ($opstr) = $vmstr =~ /-(\d+)$/; works well! Previously, it was PMOSS_P3_SIPNBVQM_5MIN_OHDR_20220429132424 and now I see the 0 added correctly at the end, PMOSS_P3_SIPNBVQM_5MIN_OHDR_202204291324240 Suppose, if i need to display PMOSS_P3_SIPNBVQM_5MIN_OHDR_202204291324240 as PMOSS_P3_SIPNBVQM_5MIN_OHDR_2022042913242400 or PMOSS_P3_SIPNBVQM_5MIN_OHDR_2022042913242401, how do I modify, even if there is only one digit after the "-"?

      It's an FAQ!


      🦛

      A reply falls below the community's threshold of quality. You may see it by logging in.