I'll be a coder dork for a second and ignore the fun error messages and comments.
Wny do you run the match several times? It seems like your config file is a bunch of name/value pairss and you could do something like this:
my $line=$_; if ($line=~/^(.+)=(.+)/) { if ($1 eq 'dir') { } else if ($1 eq 'name') { } }
I didn't think through this at all and certainly didn't try and run it and now it occurs to me that your confg file isn't all 'name=value' and you depend on the word "backup*******" before the other attributes, but still, it's early and I felt like giving some undeserved criticism.
The first match find the line that goes: dir = c:\omg\wtf\bbq Then it sets the full path to a variable.
The next match strips off the last directory (c:\omg\wtf) The extra bit of strangeness (\\[^\\]+\\*$) makes it match whether someone put a trailing backslash or not. If you've still got a way to shorten it, I'll do it! I lurve shortening my code.
Ahhh... I read you comment again after lunch and see what you actually were talking about.
Only running the match once then checking the input with multiple if statements would save a small amount of time, but then I'd have to define variables to hold the initial values of $1 and $2 (as they are only place holders, and don't hold their values very well through other regexs, and can't do all the things regular variables can do) This would add a few more lines of code to define variables that have little use. If I was checking for 1000 possibilities I'd do it that way.
There's only 5 lines it's reading (per backup set) and only one line is unmatched. I only lose a few milliseconds, and I'm not concerned about those. (otherwise I would be using a compiled language)
Lily Burk's story is about a young girl's trust and our failure as a society. It includes a family friend of hers who joins the discussion and unbelievably offers the beliefs that perpetuate these horrors. Read the posts and comments starting here. Never forget that these people exist.
Remember James Broadnax
He wounded and executed two Christian music producers for $2 and a car so he wouldn't have to walk home. Watch the interview with the remorseless murderer that changed my life. Never forget that these people exist.
5 comments:
Ahhhhh! Iggy is watching on your desktop!
We're all going to jail.. in two weeks.
I'll be a coder dork for a second and ignore the fun error messages and comments.
Wny do you run the match several times? It seems like your config file is a bunch of name/value pairss and you could do something like this:
my $line=$_;
if ($line=~/^(.+)=(.+)/) {
if ($1 eq 'dir') {
} else if ($1 eq 'name') {
}
}
I didn't think through this at all and certainly didn't try and run it and now it occurs to me that your confg file isn't all 'name=value' and you depend on the word "backup*******" before the other attributes, but still, it's early and I felt like giving some undeserved criticism.
It was an odd bit of code.
The first match find the line that goes:
dir = c:\omg\wtf\bbq
Then it sets the full path to a variable.
The next match strips off the last directory (c:\omg\wtf) The extra bit of strangeness (\\[^\\]+\\*$) makes it match whether someone put a trailing backslash or not. If you've still got a way to shorten it, I'll do it! I lurve shortening my code.
...
Ahhh... I read you comment again after lunch and see what you actually were talking about.
Only running the match once then checking the input with multiple if statements would save a small amount of time, but then I'd have to define variables to hold the initial values of $1 and $2 (as they are only place holders, and don't hold their values very well through other regexs, and can't do all the things regular variables can do) This would add a few more lines of code to define variables that have little use. If I was checking for 1000 possibilities I'd do it that way.
There's only 5 lines it's reading (per backup set) and only one line is unmatched. I only lose a few milliseconds, and I'm not concerned about those. (otherwise I would be using a compiled language)
Plus, it's quick, and easy to understand ;)
Post a Comment