LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2011, 11:51 PM   #1
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Rep: Reputation: 119Reputation: 119
Writing some perl Programs


Well I feel I know most of the basics of perl but now I just trying to figure out some small perl programs I can write for practice and experience. So any that you guys recommend?
 
Old 11-20-2011, 01:55 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Honestly, the best would be here - http://www.google.com/search?hl=en&s...1251l0.3.3l6l0
Not being mean about this either; The best would be to get online and follow many problems and exercises available freely.

Cheers,

Josh
 
Old 11-20-2011, 10:03 AM   #3
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Original Poster
Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by corp769 View Post
Honestly, the best would be here - http://www.google.com/search?hl=en&s...1251l0.3.3l6l0
Not being mean about this either; The best would be to get online and follow many problems and exercises available freely.

Cheers,

Josh
I actually did do a little bit of googling. I figured I would just ask here if anybody wanted a perl script that would be simple to do. And not being mean? What are you being mean about by saying google? LOL I tell people that all the time.
 
Old 11-20-2011, 11:19 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by jmc1987 View Post
Well I feel I know most of the basics of perl but now I just trying to figure out some small perl programs I can write for practice and experience. So any that you guys recommend?
Write programs you need for yourself.
 
Old 11-20-2011, 11:42 AM   #5
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Original Poster
Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by Sergei Steshenko View Post
Write programs you need for yourself.
Oh trust me I am. I am actually going to write a automated installer for all web services such as php, httpd, and build a simple user domain gui. If I do a good job I'll progress with it and actually release it.
 
Old 11-20-2011, 09:05 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by jmc1987 View Post
Oh trust me I am. I am actually going to write a automated installer for all web services such as php, httpd, and build a simple user domain gui. If I do a good job I'll progress with it and actually release it.
Or, you can start on it right now and make it your primary project, and then post your code here, and get second opinions and advice on it. Sounds like a feasible way to do it, and you might be able to learn a few more things that way too.
 
Old 11-20-2011, 09:28 PM   #7
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Original Poster
Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by corp769 View Post
Or, you can start on it right now and make it your primary project, and then post your code here, and get second opinions and advice on it. Sounds like a feasible way to do it, and you might be able to learn a few more things that way too.
Well if you insist I started but the names are going to change and stuff
PHP Code:
#!/usr/bin/perl 
#This Panel is licensed under GPL feel free to rebuild as your heart desires
#owPanel (Open Web Panel) is designed by James Carney

use strict;
use 
warnings;

print 
"\nWelcome to owPanel!\n";

my ($OS$release$version)=split(/\s+/,`cat /etc/*release*`);

if (
$OS eq "CentOS"){
    if(
$version >= '5.7'){
    print 
"\nOperating System Requirements met!!\n";
    } 
}
else {
        print 
"\nERROR:  Operating System Requirements not met!!\n";
        print 
"Requied Operating System is CentOS 5.7 or Later\n";
        exit;
}
print 
"Check if Yum exsist!\n";
if (`
ls /usr/bin|grep 'yum'`){
    print 
"Found Yum!\n";
} else {
    print 
"ERROR!!!  YUM is not installed!\n";
    exit;
}
print 
"Installing Apache\n";
print `
yum -y install httpd,"\n";
print 
`chkconfig --levels 235 httpd on`;
print 
`service httpd start`;
print "Install Secussfull!\n"; 


update:

Changed my mind I'm going to build the web interface and let a bash script do on the service installs.

Last edited by jmc1987; 11-20-2011 at 11:49 PM.
 
Old 11-21-2011, 06:43 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by jmc1987 View Post
Well if you insist I started but the names are going to change and stuff
PHP Code:
#!/usr/bin/perl 
#This Panel is licensed under GPL feel free to rebuild as your heart desires
#owPanel (Open Web Panel) is designed by James Carney

use strict;
use 
warnings;

print 
"\nWelcome to owPanel!\n";

my ($OS$release$version)=split(/\s+/,`cat /etc/*release*`);

if (
$OS eq "CentOS"){
    if(
$version >= '5.7'){
    print 
"\nOperating System Requirements met!!\n";
    } 
}
else {
        print 
"\nERROR:  Operating System Requirements not met!!\n";
        print 
"Requied Operating System is CentOS 5.7 or Later\n";
        exit;
}
print 
"Check if Yum exsist!\n";
if (`
ls /usr/bin|grep 'yum'`){
    print 
"Found Yum!\n";
} else {
    print 
"ERROR!!!  YUM is not installed!\n";
    exit;
}
print 
"Installing Apache\n";
print `
yum -y install httpd,"\n";
print 
`chkconfig --levels 235 httpd on`;
print 
`service httpd start`;
print "Install Secussfull!\n"; 


update:

Changed my mind I'm going to build the web interface and let a bash script do on the service installs.

In a sense it is not Perl.

For example,

Code:
if (`ls /usr/bin|grep 'yum'`)
is "tasteless" - you do not need to fork a child process (`...` does fork a child process) to check whether a file exists. Similarly, there is no error checking - theoretically 'grep' can become missing due to a screw up.

Code:
my ($OS, $release, $version)=split(/\s+/,`cat /etc/*release*`);
is not portable, and it's not worth it to write code only for CentOS.

Diagnostic output should better be printed to STDERR, not STDOUT.

All the above comments are not Perl specific. I've seen a sea of scripts like this. And, unfortunately, inheriting them from original authors I had to maintain them.
 
Old 11-22-2011, 05:04 AM   #9
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hi,

I've learned much at Project Euler http://projecteuler.net/index.php?section=about

Markus
 
Old 11-22-2011, 05:13 AM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
I'm afraid you need to study a bit more.
No offence!



stuff like this really isn't pretty.
Code:
split(/s+/,`cat /etc/*release*`);
If you are printing error messages you should really use warn not print.


Also, this is possibly easier as a shell script.
Always use the best tool for the job.
 
Old 11-22-2011, 12:48 PM   #11
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Original Poster
Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by bigearsbilly View Post
I'm afraid you need to study a bit more.
No offence!



stuff like this really isn't pretty.
Code:
split(/s+/,`cat /etc/*release*`);
If you are printing error messages you should really use warn not print.


Also, this is possibly easier as a shell script.
Always use the best tool for the job.
Yea I'm still learning best way to do things. Infact if you noticed where I edited my post days ago I stated that I'm discontinuing this project because I want to do the installs and stuff with a shell script and the actual web interface will be written in perl.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Novel writing programs for Linux ganymeder Linux - Newbie 7 06-01-2010 04:46 PM
Writing Useful Programs In C InvisibleSniper Programming 6 10-13-2005 11:50 PM
Writing C programs! SpiderIRE Linux - Software 3 05-10-2005 05:25 PM
Writing/Compling C programs in suse 9.0 wozzle Programming 5 03-15-2004 08:36 AM
Writing Programs in Linux? Volcom Programming 4 11-21-2003 08:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration