Bad switch statement (problem in the code block?)
I am writing a perl script that will take the day of the week and based on that day, assign a label to a backup tape for eventual backup procedures.
I only have a portion of the code written, but I am getting syntax errors with my case statement.
I am using perl version 5.8.8 on a Fedora 6 system.
Here is my code:
1 #!/usr/bin/perl
2 use Switch;
3
4
5 my $day = `date +%a`;
6 my $tape_label;
7
8 print $day;
9
10 switch ($day) (
11 case ('Mon') {$tape_label = 'ISD001';}
12 case ('Tue') {$tape_label = 'ISD002';}
13 case ('Wed') {$tape_label = 'ISD003';}
14 case ('Thur') {$tape_label = 'ISD004';}
15 case ('Fri') {$tape_label = 'ISD005';}
16 case ('Sat') {$tape_label = 'ISD006';}
17 case ('Sun') {$tape_label = 'ISD007';}
18
19 )
20
21 #Switch statement to determine what to label the tape
22
23 #Execute the following system commands
24
25 #mt -f /dev/rmt/0 rewind
26 #cd /opt/openv/netbackup/bin/admincmd
27 #./bpexpdate -d 0 -m (tape variable)
28
29 #There is a prompt here to erase the tape, might need to capture this variable
30 #If yes ...procedd, no quit
31
32 #mt -f /dev/rmt/0 erase
33 #./bplabel -m (tape variable) -d 4mm -n HPC5683A0
34
I check for syntax errors at this point and receive this:
[root@BriansFC bclanton]# perl -c perltest.pl
Bad switch statement (problem in the code block?) near perltest.pl line 10
I comment out all the case statements within the code block, save it, and still get the same error:
1 #!/usr/bin/perl
2 use Switch;
3
4
5 my $day = `date +%a`;
6 my $tape_label;
7
8 print $day;
9
10 switch ($day) (
11 /* case ('Mon') {$tape_label = 'ISD001';}
12 case ('Tue') {$tape_label = 'ISD002';}
13 case ('Wed') {$tape_label = 'ISD003';}
14 case ('Thur') {$tape_label = 'ISD004';}
15 case ('Fri') {$tape_label = 'ISD005';}
16 case ('Sat') {$tape_label = 'ISD006';}
17 case ('Sun') {$tape_label = 'ISD007';}
18 */
19 )
20
21 #Switch statement to determine what to label the tape
22
23 #Execute the following system commands
24
25 #mt -f /dev/rmt/0 rewind
26 #cd /opt/openv/netbackup/bin/admincmd
27 #./bpexpdate -d 0 -m (tape variable)
28
29 #There is a prompt here to erase the tape, might need to capture this variable
30 #If yes ...procedd, no quit
31
32 #mt -f /dev/rmt/0 erase
33 #./bplabel -m (tape variable) -d 4mm -n HPC5683A0
34
35
36
37
38
39
[root@BriansFC bclanton]# perl -c perltest.pl
Bad switch statement (problem in the code block?) near perltest.pl line 10
I am using examples to check for syntax in the book "Perl for Dummies" and I do not see what I am doing wrong syntax wise.
Any input would be much appreciated.
|