Hey all,
Just wanted to ask a question that's been burning in my head for some time now. Here's an example of a script that I want to modify.
$itemType = "PC";
sub get_item_weight
{
$itemWeight = "";
if ( $itemType eq "PC" ) {
$itemWeight = "50";
}
elsif ( $itemType eq "CPU" ) {
$itemWeight = "10";
}
}
I'm trying to make a script that will edit another script
Basically I need a front-end that anybody at my work can use, none of them have even heard of perl. I'm trying to make it so they can add to the script from a html form gui. But the problem I'm having is opening the script and imputing certain sections to arrays or strings.
What I need it to do is something allong the lines of opening the file and push everything between "sub get_item_weight {" and the closing sub char "}".
So that array will contain:
$itemWeight = "";
if ( $itemType eq "PC" ) {
$itemWeight = "50";
}
elsif ( $itemType eq "CPU" ) {
$itemWeight = "10";
}
Than I need to go one step further and be able to push everything from "if ... }" or "elsif ... }" to an array or string.
The problem is that I really only know how to input one line at a time. And I want it to grab anything between { and }. Anyone know how to do that? I would greatly appricate it.
Thanks
Just wanted to ask a question that's been burning in my head for some time now. Here's an example of a script that I want to modify.
$itemType = "PC";
sub get_item_weight
{
$itemWeight = "";
if ( $itemType eq "PC" ) {
$itemWeight = "50";
}
elsif ( $itemType eq "CPU" ) {
$itemWeight = "10";
}
}
I'm trying to make a script that will edit another script

What I need it to do is something allong the lines of opening the file and push everything between "sub get_item_weight {" and the closing sub char "}".
So that array will contain:
$itemWeight = "";
if ( $itemType eq "PC" ) {
$itemWeight = "50";
}
elsif ( $itemType eq "CPU" ) {
$itemWeight = "10";
}
Than I need to go one step further and be able to push everything from "if ... }" or "elsif ... }" to an array or string.
The problem is that I really only know how to input one line at a time. And I want it to grab anything between { and }. Anyone know how to do that? I would greatly appricate it.
Thanks