#!/usr/bin/perl -w use strict; #set up the test data my @potential_links = ('[url|desc|target]','[www.test.com|test page]','[www.test.com|test page|new]'); #using the test data foreach(@potential_links){ #strip out the braces $_ =~ s/\[|\]//g; #split the remaining string represented by $_ on the pipe my($url, $desc, $target) = split /\|/; #ternary to test if $target was set if not print the non-target version. ($target) ? print qq*$desc\n* : print qq*$desc\n* ; } exit;