Here is my current subroutine, I would like to use a file instead of an if then structure, so if I go on vacation, someone can just add sitecodes to the file. This works, but adding a file would make it better, I could change the sub depending on the match to call this or the other sub
sub MLX40Tutorials { my $str = ""; $str .= mLeftIndex(); my $xml = xmlFileData(Content", "Sitelist40.xml", "MLX40Tutorials()") +; if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange40.*?<\/mlxchange40>)/s; $str .= shadowBox("Mlxchange Tutorials", "<tutorials>".$1."</tut +orials>", ($g_docWidth/5*4-(2*$g_docSpace))); } return $str; }
Sub 2 trying to break into 2 seperate routines..
sub mTutorials { if ($Session->{'usrSystem'} eq "MRT") { my $str=""; $str.=mLeftIndex(); my $xml=xmlFileData("Content", "Sitelist40.xml", "MLX40Tutorials()") +; if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange40.*?<\/mlxchange40>)/s; $str .= shadowBox("MLXchange Tutorials &amp; Demos", "<tutorials +>".$1."</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); #$xml =~ /(<mlxchange.*?<\/mlxchange>)/s; #$str .= shadowBox("MLXchange 3.0 Tutorials", "<tutorials>".$1." +</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); } return $str; } if ($Session->{'usrSystem'} eq "RMLS") { my $str=""; $str.=mLeftIndex(); my $xml=xmlFileData("Content", "Sitelist40.xml", "MLX40Tutorials()") +; if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange40.*?<\/mlxchange40>)/s; $str .= shadowBox("MLXchange Tutorials &amp; Demos", "<tutorials +>".$1."</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); #$xml =~ /(<mlxchange.*?<\/mlxchange>)/s; #$str .= shadowBox("MLXchange 3.0 Tutorials", "<tutorials>".$1." +</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); }return $str; } else { if ($Session->{'usrSystem'} eq "BAR") { my $str=""; $str.=mLeftIndex(); my $xml=xmlFileData("Content", "Sitelist40.xml", "MLX40Tutorials()") +; if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange40.*?<\/mlxchange40>)/s; $str .= shadowBox("MLXchange Tutorials &amp; Demos", "<tutorials +>".$1."</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); #$xml =~ /(<mlxchange.*?<\/mlxchange>)/s; #$str .= shadowBox("MLXchange 3.0 Tutorials", "<tutorials>".$1." +</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); } return $str; } else { my $str = ""; $str .= mLeftIndex(); my $xml = xmlFileData("Content", "Tutorials.xml", "mTutorials()"); if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange.*?<\/mlxchange>)/s; $str .= shadowBox("MLXchange Tutorials &amp; Demos", "<tutorials +>".$1."</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); $xml =~ /(<general.*?<\/general>)/s; $str .= shadowBox("General PC Tutorials", "<tutorials>".$1."</tu +torials>", ($g_docWidth/5*4-(2*$g_docSpace))); } return $str; } } }

In reply to Re^4: loop through file checking for session variable by grashoper
in thread loop through file checking for session variable by grashoper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.