I just realized- JavaScript is my Perl
Twice this morning I did massive, repetitive, string manipulations with JavaScript.
One took a list of files, turned it into an array and then looped through creating .htaccess entries.
The other took an HTML table output by Excel and turned it into a Definition List. I then used FireBug to copy the innerHTML of the body and pasted it into a new document, ready to be manipulated in the application I'm building (with JavaScript of course
) If you're curious, here's the code for that one:
<script type="text/javascript">
window.onload = function() {
var trs = document.getElementsByTagName("TR");
var newString ="<dl>";
for (i=0;i<trs.length;i++){
var tds=trs[i].getElementsByTagName("TD");
newString +="<dt id='"+tds[1].innerHTML+"'>"+tds[4].innerHTML+"</dt>";
newString +="<dd>"+tds[5].innerHTML+"</dd>";
}
newString +="</dl>"
document.body.innerHTML=newString;
}
</script>
Anyway, I've done this sort of thing before and I realized that I'm using JavaScript for the sort of administrative scripting that other people would use Perl or Python for.
No, there's nothing more to this post than that.
I just wanted to point it out since it struck me as interesting.
Does anyone else out there use JS for this sort of thing?
Or am I a complete weirdo?