Red_Dragon has asked for the wisdom of the Perl Monks concerning the following question:
The data pair should only be included in the string if the variable contains a value and a comma should be appended at the end of each pair only if another pair is to be appended."2", "submitted by", "7", "Status", "8", "a short, concise description +", "536870915", "Jobfail", "536870922", "finance", "536870926", "Stev +ens"
The data and variables are layed out as follows:
Things I've tried that failed:..........................# VALUE CONTAINED IN THE VARIABLE "2", "$p_suby", # submitted by "7", "$p_stat", # Status "8", "$p_desc", # a short concise description "536870915", "$p_catg", # Jobfail "536870922", "$p_agrp", # finance "536870926", "$p_lnam" # Stevens
$counter = 0 ; if ($p_suby != "") {$tkt_data = "\"2\", \"$p_suby\"" ; $counter = $counter + 1 ;} if ($p_stat != "") {if ($counter > 0) {$tkt_data = "$tkt_data, \"7\", \"$p_stat\""} else {$tkt_data = "\"7\", \"$p_stat\""} $counter = $counter + 1 ;} if ($p_desc != "") {if ($counter > 0) {$tkt_data = "$tkt_data, \"8\", \"$p_desc\""} else {$tkt_data = "\"8\", \"$p_desc\""} $counter = $counter + 1 ;} if ($p_catg != "") {if ($counter > 0) {$tkt_data = "$tkt_data, \"536870915\", \"$p_catg +\""} else {$tkt_data = "\"536870915\", \"$p_catg\""} $counter = $counter + 1 ;} if ($p_agrp != "") {if ($counter > 0) {$tkt_data = "$tkt_data, \"536870922\", \"$p_agrp +\""} else {$tkt_data = "\"536870922\", \"$p_agrp\""} $counter = $counter + 1 ;} if ($p_lnam != "") {if ($counter > 0) {$tkt_data = "$tkt_data, \"536870926\", \"$p_lnam +\""} else {$tkt_data = "\"536870926\", \"$p_lnam\""} $counter = $counter + 1 ;}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My Novice is Showing
by Roy Johnson (Monsignor) on Nov 18, 2003 at 19:38 UTC | |
|
Re: My Novice is Showing
by blokhead (Monsignor) on Nov 18, 2003 at 19:37 UTC | |
|
Re: My Novice is Showing
by duff (Parson) on Nov 18, 2003 at 19:35 UTC | |
|
Re: My Novice is Showing
by cleverett (Friar) on Nov 18, 2003 at 19:40 UTC |