The script works good, but I need to set in some tabbing on the terminal, and that is where the problem comes in. as soon as I attempt a division, the applet blows up, and it is not a divide by 0 error.
I have tested the particular line of code with all arithmetic operators, and the code only refuses to compile when I use the division operator.
The error display is:
Bareword found where operator expected at ./ideaStatus line 51, near "case"
(Missing semicolon on previous line?)
Bareword found where operator expected at ./ideaStatus line 52, near "case"
(Missing semicolon on previous line?)
Bareword found where operator expected at ./ideaStatus line 53, near "case"
(Missing semicolon on previous line?)
syntax error at ./ideaStatus line 49, near ") {"
syntax error at ./ideaStatus line 51, near "/^"
syntax error at ./ideaStatus line 52, near "/^"
syntax error at ./ideaStatus line 53, near "/^"
syntax error at ./ideaStatus line 53, near "; }"
Execution of ./ideaStatus aborted due to compilation errors.
The code is:
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- use Switch;
- use integer;
- $baseDir = "~/Desktop/IdeaBin";
- $tablen = 8;
- #-----------
- # list existing project ideas
- print "locating existing project ideas from $baseDir\n";
- $listIdx = 0;
- opendir(DIRHANDLE, $baseDir) || die "Cannot opendir $baseDir: $!";
- foreach $name (sort readdir(DIRHANDLE)) {
- # --- make sure it is a directory
- if (-d "$baseDir/$name") {
- # --- and it's not the . .. dir links
- if ( $name !~ /^\./ ) {
- @Ideas[$listIdx]=$name;
- $listIdx++;
- }
- }
- }
- closedir(DIRHANDLE);
- print "Code\t\tName\t\t\t\t\tDate\t\tStatus\n";
- # Cycle through our list
- for $i (@Ideas ) {
- $file = $baseDir."/".$i."/$i.txt";
- open (LOGFILE, $file) or die "I couldn't open $file\n";
- $x = 0;
- while ( $x == 0 ) {
- $line = <LOGFILE> ;
- if ( $line =~ /^\n/ ) {
- $x=1;
- } else {
- @line = split(/:/, $line);
- $y = (length $line[1]) - 2 ;
- $tbs = ((length $line[1])-((length $line[1])%8)) ;
- # any attempt at division causes the program to bork on this line
- # comment the line, and it all runs fine
- # change to any other operand, and it runs fine
- # out of ideas -- wtf!!!
- $ts = int( $tbs / 8 ) ;
- switch ( $line[0] ) {
- case /^Status/ { print substr $line[1], 1, $y; print "\n"; }
- case /^Code/ { print substr $line[1], 1, $y; print "\t"; }
- case /^When/ { print substr $line[1], 1, $y; print "\t"; }
- case /^Name/ { print substr $line[1], 1, $y; print "\t"; }
- }
- }
- }
- close LOGFILE;
- # print "located $i\n";
- }
eg : ~/Desktop/IdeaBin/TestDir/TestDir.txt
content template is:
;----------------
Code: Test
Name: Test Application
Who: Some Body
When: Jul 24, 2007
Status: Open
;----------------