f15smtd Starting Lineup 78 Posts user info edit post |
I need to parse some text from a log file and I was wondering what if there was a prefered scripting language for this. I need something that will grab timestamps, string processing, and do numerical operations, nothing too fancy.
I know Java and PHP, but I was curious if anyone would think Perl, Python, Tcl, or C# would be better. Thanks. 9/10/2007 3:00:04 PM |
f15smtd Starting Lineup 78 Posts user info edit post |
Also FYI i will be developing and executing the scripts on Windows. 9/10/2007 3:01:24 PM |
GraniteBalls Aging fast 12262 Posts user info edit post |
what's the project?
out of curiosity. 9/10/2007 3:07:47 PM |
dakota_man All American 26584 Posts user info edit post |
perl 9/10/2007 3:16:52 PM |
Redneck Bob All American 1040 Posts user info edit post |
agree with Perl 9/10/2007 3:19:12 PM |
darkone (\/) (;,,,;) (\/) 11610 Posts user info edit post |
perl </thread> 9/10/2007 6:01:17 PM |
Solinari All American 16957 Posts user info edit post |
perl 9/10/2007 6:11:34 PM |
Stein All American 19842 Posts user info edit post |
Perl
Though realistically PHP can do everything you need and since you already know it, you might as well use it. 9/10/2007 6:16:36 PM |
Noen All American 31346 Posts user info edit post |
since it's windows and you know php, stick to that.
Just install the CGI package, and go run it. I STILL use php for random command line scripting all the time in windows, it's really light-weight and powerful 9/10/2007 6:53:47 PM |
qntmfred retired 40726 Posts user info edit post |
perl is the traditional choice but i agree with those who say use php. you already know it, and it can do pretty much everything] 9/10/2007 7:10:32 PM |
Lionheart I'm Eggscellent 12775 Posts user info edit post |
perl 9/10/2007 9:12:26 PM |
DoubleDown All American 9382 Posts user info edit post |
you'd have more fun with ruby 9/10/2007 9:27:59 PM |
Chance Suspended 4725 Posts user info edit post |
Agreed with stein, noen, and qntmfred. 9/10/2007 9:51:48 PM |
zorthage 1+1=5 17148 Posts user info edit post |
perl
its a good langauge to know and it excels at text parsing. Learning something new (and brushing up on regex's) is never a bad idea. 9/10/2007 10:04:21 PM |
scud All American 10804 Posts user info edit post |
ruby 9/10/2007 11:38:04 PM |
smoothcrim Universal Magnetic! 18966 Posts user info edit post |
you can more than likely do what you need to do with regular batch commands, possibly with the addition of regular resource kits. if you exceed the limitations of batch, perl/awk/python would be my choice, mainly because I don't know php 9/11/2007 12:20:09 AM |
SandSanta All American 22435 Posts user info edit post |
Thats a retarded idea as he'd be doing the same amount of work writing 10 lines of batch and pipe commands as 10 lines of perl.
I would use Perl, avoid Tcl or python and certainly PHP for this task. 9/11/2007 12:58:21 AM |
tmmercer All American 2290 Posts user info edit post |
python ftw 9/11/2007 1:37:51 AM |
smoothcrim Universal Magnetic! 18966 Posts user info edit post |
yes, clearly, working with what windows comes with while maintaining the same code efficiency is a retarded idea 9/11/2007 2:00:26 AM |
Noen All American 31346 Posts user info edit post |
fyi guys, for text parsing, perl and php are like 90% interchangeable.
Also, not that he would even care to do this, but if you run the code through zend, it's also a good bit faster than perl. 9/11/2007 2:38:24 AM |
Gonzo18 All American 2240 Posts user info edit post |
python 9/11/2007 7:19:17 AM |
evan All American 27701 Posts user info edit post |
without even reading this thread
just reading the title "suggest a language for parsing a text file"
the only answer is perl 9/11/2007 10:19:21 AM |
joe_schmoe All American 18758 Posts user info edit post |
QBasic or Pascal. 9/11/2007 11:49:18 AM |
LimpyNuts All American 16859 Posts user info edit post |
PARSING TEXT > REGULAR EXPRESSIONS
The language you use doesn't even matter. Regular expressions are powerful and versatile and designed SPECIFICALLY TO FACILITATE PARSING TEXT! 9/11/2007 5:23:41 PM |
kiljadn All American 44690 Posts user info edit post |
Assembly 9/11/2007 5:54:14 PM |
joe_schmoe All American 18758 Posts user info edit post |
^ oh, word. that shit rocks. you can use the RISC emulator from ECE 206. 9/11/2007 6:13:29 PM |
Noen All American 31346 Posts user info edit post |
^^^yes it does, because not all languages support regex. luckily php and perl do, and use almost the same standards 9/11/2007 6:38:12 PM |
joe17669 All American 22728 Posts user info edit post |
I tried doing some regex stuff once, and it made my head explode. 9/11/2007 6:40:45 PM |
llama All American 841 Posts user info edit post |
9/11/2007 7:23:44 PM |
qntmfred retired 40726 Posts user info edit post |
^ traitor
9/11/2007 7:24:54 PM |
LimpyNuts All American 16859 Posts user info edit post |
Quote : | "yes it does, because not all languages support regex. luckily php and perl do, and use almost the same standards" | i was understating when i said it doesn't matter. i meant go with whatever he felt comfortable with, because PHP, Perl, C and most common languages support RegEx. Shit, even VB does
And as for languages that don't support it natively there are RegEx extensions for any language you would consider actually parsing text with.9/11/2007 7:47:47 PM |
cyrion All American 27139 Posts user info edit post |
COBOL always wins my vote
[Edited on September 11, 2007 at 8:19 PM. Reason : PARSE STRINGPART FROM STRINGTOTAL] 9/11/2007 8:17:50 PM |
dakota_man All American 26584 Posts user info edit post |
c supports regular expressions natively?
[Edited on September 11, 2007 at 8:51 PM. Reason : like the posix regex stuff or what] 9/11/2007 8:49:26 PM |
scud All American 10804 Posts user info edit post |
To say that C supports regexp is really a stretch. To say that some implementations of the C stdlib have limited support for some form of regular expressions would be much more accurate.
I think a lot of people struggle with the difference between a programming language and a platform. That being said...it's interesting to see the difference b/w people who have grown up with mostly VM-based language platforms. 9/11/2007 10:18:32 PM |
skokiaan All American 26447 Posts user info edit post |
perl >>>> * 9/11/2007 10:22:45 PM |
gs7 All American 2354 Posts user info edit post |
brainfuck.
http://www.dmoz.org/Computers/Programming/Languages/Brainfuck/ 9/11/2007 10:45:23 PM |
joe_schmoe All American 18758 Posts user info edit post |
Speaking of Perl
i was looking something up, and found this research into number theory
do any of you remember Carl Sagan's Contact? You wont believe the pattern that's been found
-----------begin Perl code here---------------
$maxerrors = 220; # needs tuning $pi = reverse "3.141592653589793238462643383279502884197169399375105820974944592 30781640628620899862803482534211706798214808651328230664709384460955058223172535 94081284811174502841027019385211055596446229489549303819644288109756659334461284 75648233786783165271201909145648566923460348610454326648213393607260249141273724 58700660631558817488152092096282925409171536436789259036001133053054882046652138 41469519415116094330572703657595919530921861173819326117931051185480744623799627 49567351885752724891227938183011949129833673362440656643086021394946395224737190 70217986094370277053921717629317675238467481846766940513200056812714526356082778 57713427577896091736371787214684409012249534301465495853710507922796892589235420 19956112129021960864034418159813629774771309960518707211349999998372978049951059 73173281609631859502445945534690830264252230825334468503526193118817101000313783 87528865875332083814206171776691473035982534904287554687311595628638823537820166 73231564231563231874231873231284231283236583236973236472239231011673231564231563 23287323187423128323128323158423158323197423197323147723923101167323656323187123 18722318742352832315842315832319742319732314772392310116732315642315632318722318 71231873231284231283231584231583231974231973231477239231011674234564231873232873 23628323158423158323697323147723923301723923101667323128423128323696823108823101 16742312832312882319682310882310116742352862339642350882310116732312842312882319 63231084231088231011673236283236963236088234016963231274231276231482231011963231 27423127623148223101923396323627623148223101196323127423127623148223101696323127 423127423548101";
while ($offset < length($pi)) { my($x) = substr($pi, $offset +++ 0, 2); my($y) = substr($pi, $offset +++ 1, 1); # XXX should be 3? my($z) = substr($pi, $offset +++ 2, 1); if ($x * cos($y) / cos($z)) { $dbg .= chr ($x) x $y; if (++$errors >= $maxerrors) { # "cannot happen" die("$dbg\n"); } } } # passes sig test print("ok!\n");
------------end Perl code here----------------9/12/2007 2:45:56 AM |
qntmfred retired 40726 Posts user info edit post |
TTTTT H H EEEEEE T H H E T HHHHHH EEE T H H E T H H EEEEEE
PPPPPP EEEEEE RRRRRR L P P E R R L PPPPP EEE RRRRR L P E R R L P EEEEEE R R LLLLLL
J OOOOOO U U RRRRRR NN N AAAA L J O O U U R R N N N A A L J O O U U RRRRR N N N AAAAAA L J O O U U R R N NN A A L JJJJJJ OOOOOO UUUUUU R R N N A A LLLLLL
[Edited on September 12, 2007 at 7:00 AM. Reason : neat]9/12/2007 7:00:27 AM |