Question: CODE with details
=================

```
#!/usr/bin/bash -xv

```

FUNCTION\_DYNAMIC
=================

```
eval "function APP_$i_$j
{
    `enter code here`
}"

```

DEFINING\_FUNC\_TO\_CALCULATE\_VALUE
====================================

```
APP_VAR_MKT()
{
    for i in `cat ${SERVER}`
    do
        for j in `cat ${ZONE}`
        do
            shopt -s expand_aliases
            alias name="APP_${i}_${j}"
            declare -fp "APP_${i}_${j}"
        done
    done
}

```

MAIN
====

```
SERVER_NAME=/path/servers_file
ZONE=/path/zones_file

```

DECLARING FUNCTION with variable in it
======================================

```
APP_VAR_MKT

```

Answer: 
You don't; you pass that information as arguments:

```
app () {
    server_name=$1
    zone=$2
    # ...
}

app "$SERVER_NAME" "$ZONE"

```
You should not do this, unless you have a good reason for it - functions are reusable encapsulations of code, and their names should not change normally. Also you should not use eval because it is very dangerous. So be warned.

What you can do if you absolutely must is use eval:

```
#!/bin/bash

eval "function APP_${SERVER_NAME}_${ZONE}
{
    echo 'XXX'
}"

APP_${SERVER_NAME}_${ZONE}

```

The result:

`XXX`