Search the web
Sign In
New User? Sign Up
Perl_Official · Perl . CGI . Shell script
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
pl some one post perl tutorial with examples   Message List  
Reply | Forward Message #2047 of 2062 |
Re: pl some one post perl tutorial with examples

--- In Perl_Official@yahoogroups.com, "arun5167" <arun5167@...> wrote:
>
> please someone post perl turorial with examples expecially for
> administrators
> Thanks in advance
>
Here is a small exercise that I have prepared. This is meant for
someone who wants to learn Perl.

Exercise 1. In a Perl script, accept command line arguements.
Display all the arguements and also the number of arguements.

Expected output:

$ ex1.pl this that
Arguements: this that
Number of arguements: 2
$

===========================

Exercise 2. Accept a filename as command line arguement. Display the
contents of that file.

Expected output:

$ cat > newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
Elaine, have you forgotten?
(Ctrl+C)$
$
$ ex2.pl newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
Elaine, have you forgotten?
$

This is similar to displaying the contents of a file using cat
command.

===========================

Exercise 3. Accept a filename as command line arguement. Display all
lines of that file which contain letter d

Expected output:

$ ex3.pl newfile.text
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
$

===========================

Exercise 4. Accept a filename as command line arguement. Display a
count of how many lines of that file contain letter d

Expected output:

$ ex4.pl newfile.text
newfile.text contains w 3 times
$

===========================

Exercise 5. Accept a filename as command line arguement. Display all
lines of that file which contain the character ?

Expected output:

$ ex5.pl newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
Elaine, have you forgotten?
$

===========================

Exercise 6. Accept a filename as command line arguement. Display all
lines of that file which do not contain the letters w and W

Expected output:

$ ex6.pl newfile.text
Elaine, Have you forgotten?
You are so very stupid, dear!
Elaine, have you forgotten?
$

===========================

Exercise 7. Accept a string as first arguement and a filename as
second arguement. Display all lines of that file which contain the
given string.

Expected output:

$ ex7.pl es newfile.text
How much is three times humpty-steen?
Why does a chicken cross the road?
Who carries home a toper's load?
$

The first steps of making our own grep command!

===========================

Exercise 8. Accept a username as command line arguement. Display if
that user is currently logged in or not. Run who or w command and
use its output to determine if the given user is logged in or not.

Expected output:

$ ex8.pl yogesh
yogesh is not logged in
$

$ ex8.pl root
root is logged in
$

===========================

Exercise 9. Accept a username as command line arguement. Display if
that user is currently logged in or not; and if logged in, then how
many times.

Expected output:
$ ex9.pl root
root is logged in 3 times
$

Additional exercise: show "1 time" if user is logged in only once
and "x times" if user is logged in multiple times (use of s in times
only in case of multiple logins)

===========================

Exercise 10. Accept command line arguements. Consider all command
line arguements as user names and for all the given user names,
display if they are logged in or not.

Expected output:
$ ex9.pl yogesh sandesh root
yogesh is not logged in
sandesh is not logged in
root is logged in
$

===========================





Wed Sep 12, 2007 8:35 am

yoga_sawant
Offline Offline
Send Email Send Email

Forward
Message #2047 of 2062 |
Expand Messages Author Sort by Date

please someone post perl turorial with examples expecially for administrators Thanks in advance...
arun5167
Offline Send Email
Sep 9, 2007
2:54 am

... Here is a small exercise that I have prepared. This is meant for someone who wants to learn Perl. Exercise 1. In a Perl script, accept command line...
Yogesh Sawant
yoga_sawant
Offline Send Email
Sep 12, 2007
8:41 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help