user3350919 user3350919 - 1 year ago 69
Perl Question

creating array fields under 'ifdef using perl

I'm writing a script that creates a database of name, and this database have different versions.
My script is getting the version as input (it has a default version in case of no input)
each database version is based on the previouse versions, but contains some additional names.

I'm trying to find a way to define some of the enteries to my array as a function of the iversion.
Therefore im using something like verilog IFDEF

for example:

my @DATABASE = (

if ($version = 1.3) {


at this example, the names Arik,Ben and Roth will be at the data base for all versions, but Suzie and Dan will only be at the version 1.3 database

Is there a good way to do that?

Answer Source

It's not clear what you want, but this may help

use strict;
use warnings;

use Data::Dump;

my $version = '1.3';

my @database = (
    $version eq '1.3' ? (
    ) : (),

dd \@database;


["Arik", "Ben", "Suzie", "Dan", "Roth"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download