Perl parse string

Hi Perl Guys

I have another perl question

I have the following code that i have written

Getopt::Long::config(qw( permute bundling ));
my $OPT = {};
GetOptions($OPT, qw(
    ver=s
    help|h
)) or die "options parsing failed"; 

This will allow the user to do something like this

 prog.pl --ver 2b2 

i need a way to parse the bit atfer --ver ( which is take from the get opt above using =s )

for example 4r2v1 acutally relates to

3DE4_linux64_r2b2

and i will end up using it something similar to this

exec $apppath/$version 

version being the bit i got from --ver

how can a parse the bit after --ver and apply it

the other options that is can be like below

3DE4_linux64_r1
3DE4_linux64_r2b2
3DE4_linux64_r2
3DE4_linux64_r3b1

i hope that make sense

Many Many Many Thanks

#! /usr/bin/perl
use strict;

use Getopt::Long;
my $OPT = {};
my ($version,$help_flag);
my $OPT=GetOptions(
    "ver=s" =>\$version,
    "help|h" =>\$help_flag
)or die "options parsing failed";
my %versions=(
r1=>"3DE4_linux64_r1" ,
r2b2=>"3DE4_linux64_r2b2" ,
r2=>"3DE4_linux64_r2",
r3b1=>"3DE4_linux64_r3b1");
print $versions{$version}?$versions{$version}:"$version is not a valid version string" , "\n";;

Thanks. But is there a way not to do it with a hard code list. That mean every time we get a new version I will have to update it. If I could just take the version then i would not have to update i

Sorry, of course you can, I need to look at the data more carefully :wink:

use Getopt::Long;
my $OPT = {};
my ($version,$help_flag);
my $OPT=GetOptions(
    "ver=s" =>\$version,
    "help|h" =>\$help_flag
)or die "options parsing failed";
my $appath="/opt/my/sfw/";
my $string="3DE4_linux64";
exec (-x "$appath/$string_$version")?("$appath/$string_$version"):("echo","$version is not a valid version string" );

Hi

Thanks for your reply, i have this

# Get command-line options
Getopt::Long::config(qw( permute bundling ));
my ($version,$help_flag);
my $OPT = {};
GetOptions($OPT, qw(
    "ver=s" =>\$version,
    "help|h" =>\$help_flag
)) or die "options parsing failed";


if ($OPT->{help}) {
    info();
    exit(2);
}

but getting some errors

Possible attempt to separate words with commas at ./3DE line 73.
Error in option spec: ""ver=s""
Error in option spec: "=>\$version,"
Error in option spec: ""help|h""
Error in option spec: "=>\$help_flag"

any suggestions?
Thanks