Hi Monks,
I have a long string full of HREF's for links that map things over a .GIF image of a visio diagram.
I have a need to modify the HREF's when the image is displayed, but I only need to change the ones that fit that match below. There are often (not always) many matches in the string. For each match, $1 will be different. However, I need to take $1 from the match, use it to get more info from the database and use the result in a substitution at that point.
if ($$imageMap =~ /name=(.*?)_DIAGLINK/){
$diagId = $1;
$dbh = ConnectDB($User, $Password);
$sql = "SELECT version FROM diagramversion WHERE diagram_id='$
+diagId' AND workflow_state='Stored'"; #to_char(version,'099') didn't
+ work
$sth = RunJobDB($dbh, $sql);
@version = $sth->fetchrow_array;
$version = $version[0];
$sth->finish();
DisconnectDB($dbh);
$version = sprintf( "%03d", $version );
$fullId = $diagId."-".$version;
$$imageMap =~ s/ViewObject.pl\?name=(.*?)_DIAGLINK/dia_View.pl
+?diagram_id=$fullId/i;
}
How can I do this so that it works properly for each substitution ??
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.