Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^7: appending a variable

by Marshall (Canon)
on Apr 29, 2022 at 01:28 UTC ( [id://11143416]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143416]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-19 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found