Thanks for all the help guys, I have had a play and because I want to be able to put a number of different commands in without worrying, and the format is something that I can set myself for the input file I've opted for the file containing any commands, that need to be parsed, within a set of asterisks. The asterisk is not needed anywhere else within the file so I have decided on using the following code:
sub ParseArguments { # Parses any perl commands with * delimeters, eg:
+ '*$ENV{CONFIG_DIR}*/contents' --> 'MY/CONFIG/DIR/contents'
my $Line = pop @_;
my @Args = split /\*/, $Line;
foreach my $Arg (@Args) {
if ($Arg ne "") {
if ($Arg =~ /^[\@\$\%]/) {
my $Temp;
$Arg = "\$Arg = $Arg";
eval $Arg;
$Arg =~ s/^\$Arg = //;
}
}
}
my $Return = "";
foreach my $Arg (@Args) {
$Return = $Return . $Arg;
}
return $Return;
}
The contents of the file can now contain a number of different items that I need, examples are:
*$ENV{COMPANY}*/Custom_Perl/Logs
*$Config->{PerlDir}*/Lib/Chris/Pantheon/Border.CoOrds
I know this isn't the best way for me to do this as it leaves all kinds of security vulnerabilities etc, but I'm not worried about those as the program ultimately is run by me and a few other people who don't have any knowledge of perl anyway!
Thanks Again Guys,
Chris Bailey
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.