?
Solved

Simple Perl Syntax Problem

Posted on 2000-01-21
1
Medium Priority
?
158 Views
Last Modified: 2010-03-05
>cat dousage.pl
#!/usr/bin/perl

system ("ls /home > /tmp/do.webalizer");
open (SERVER, "> /tmp/do.webalizer");
        while (<SERVER>) {
                $i = $_
                        if ("-d /home/$i/public_html") && ("-d /home/$i/public_html/usage") {
                                system ("/usr/bin/webalizer -n $i -o /home/$i/public_html/usage /home/$i/log/log");
                        } else {
                                system ("mkdir /home/$i/public_html/usage");
                                system ("/usr/bin/webalizer -n $i -o /home/$i/public_html/usage /home/$i/log/log");
                        }


> perl -c dousage.pl
syntax error at dousage.pl line 13, near "}"
syntax error at dousage.pl line 16, near "}"
dousage.pl had compilation errors.
0
Comment
Question by:albrecht2000
1 Comment
 
LVL 25

Accepted Solution

by:
clockwatcher earned 200 total points
ID: 2375882
You're missing a semicolon:
 
  $i = $_;

You're missing parens around your first if statement:

 if (("-d /home/$i/public_html") && ("-d /home/$i/public_html/usage"))

You're missing the closing bracket on your while.

Here's the syntactically correct version:

#!/usr/bin/perl

system ("ls /home > /tmp/do.webalizer");
open (SERVER, "> /tmp/do.webalizer");
        while (<SERVER>) {
                $i = $_;
                        if (("-d /home/$i/public_html") && ("-d /home/$i/public_html/usage")) {
                                system ("/usr/bin/webalizer -n $i -o /home/$i/public_html/usage /home/$i/log/log");
                        } else {
                                system ("mkdir /home/$i/public_html/usage");
                                system ("/usr/bin/webalizer -n $i -o /home/$i/public_html/usage /home/$i/log/log");
                        }
        }




 

 
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question