CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
help required in perl

 



sania.mirza
Novice

Feb 7, 2014, 6:32 AM

Post #1 of 12 (1353 views)
help required in perl Can't Post

Hello Sir,

I am new to perl, please help me how i can become a good perl programmer.

Regards,
Sania M.


FishMonger
Veteran / Moderator

Feb 7, 2014, 7:01 AM

Post #2 of 12 (1351 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

Practice, practice, practice.

Do you have a specific coding question? If so, post your question and code and explain how your code is failing to do what you expect.


sania.mirza
Novice

Feb 7, 2014, 8:09 AM

Post #3 of 12 (1346 views)
Re: [FishMonger] help required in perl [In reply to] Can't Post

Sir, Thanks for reply. I need to learn basics to intermediate and then intermediate to expert level.

But can you give me hint online where i can read and start practicing it. I want to make a monitoring system in perl that is my goal. My monitoring system having two components.

1) Monitor Server
2) Monitor Client

Monitor client push all detail to Monitor Server and on web interface i can see all result. I know it will take time but I need input from which point i can start.

Sir, I need your help in that, it my aim of life to make my own monitoring system with all good options. Please guide me.

Best Regards,
Sania Mirza


FishMonger
Veteran / Moderator

Feb 7, 2014, 8:33 AM

Post #4 of 12 (1341 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

A short list of good books.

Learning Perl, 6th Edition - Making Easy Things Easy and Hard Things Possible
http://shop.oreilly.com/product/0636920018452.do

Programming Perl, 4th Edition - Unmatched power for text processing and scripting
http://shop.oreilly.com/product/9780596004927.do

Mastering Perl, 2nd Edition - Creating Professional Programs with Perl
http://shop.oreilly.com/product/0636920012702.do

Modern Perl - Paperback
http://www.amazon.com/Modern-Perl-chromatic/dp/0977920151


A few online resources

Modern Perl - Ebook
http://modernperlbooks.com/mt/2011/05/free-ebook-giveaway-modern-perl-514-edition.html

Perl Beginners' Site
http://perl-begin.org/

Perl Documentation i.e., perldoc
http://perldoc.perl.org/

Perlmonks
http://www.perlmonks.org/?node=Seekers%20of%20Perl%20Wisdom

CPAN - Comprehensive Perl Archive Network
http://search.cpan.org/


sania.mirza
Novice

Feb 7, 2014, 12:40 PM

Post #5 of 12 (1324 views)
Re: [FishMonger] help required in perl [In reply to] Can't Post

Please tell me what is the purpose of chomp function in below code and in generally why chomp function is use.....


Code
 
print "Enter first number:\n";
$a = <STDIN>;
chomp $a;



sania.mirza
Novice

Feb 7, 2014, 12:44 PM

Post #6 of 12 (1321 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

If i will use not use chomp function then there is no impact on code, but i need reason why chomp is required.


In Reply To
Please tell me what is the purpose of chomp function in below code and in generally why chomp function is use.....


Code
 
print "Enter first number:\n";
$a = <STDIN>;
chomp $a;




FishMonger
Veteran / Moderator

Feb 7, 2014, 12:45 PM

Post #7 of 12 (1321 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

c:\test>perldoc -f chomp

Code
    chomp VARIABLE 
chomp( LIST )
chomp This safer version of "chop" removes any trailing string that
corresponds to the current value of $/ (also known as
$INPUT_RECORD_SEPARATOR in the "English" module). It returns the
total number of characters removed from all its arguments. It's
often used to remove the newline from the end of an input record
when you're worried that the final record may be missing its
newline. When in paragraph mode ("$/ = """), it removes all
trailing newlines from the string. When in slurp mode ("$/ =
undef") or fixed-length record mode ($/ is a reference to an
integer or the like; see perlvar) chomp() won't remove anything.
If VARIABLE is omitted, it chomps $_. Example:

while (<>) {
chomp; # avoid \n on last field
@array = split(/:/);
# ...
}

If VARIABLE is a hash, it chomps the hash's values, but not its
keys.

You can actually chomp anything that's an lvalue, including an
assignment:

chomp($cwd = `pwd`);
chomp($answer = <STDIN>);

If you chomp a list, each element is chomped, and the total
number of characters removed is returned.

Note that parentheses are necessary when you're chomping
anything that is not a simple variable. This is because "chomp
$cwd = `pwd`;" is interpreted as "(chomp $cwd) = `pwd`;", rather
than as "chomp( $cwd = `pwd` )" which you might expect.
Similarly, "chomp $a, $b" is interpreted as "chomp($a), $b"
rather than as "chomp($a, $b)".



sania.mirza
Novice

Feb 7, 2014, 12:51 PM

Post #8 of 12 (1318 views)
Re: [FishMonger] help required in perl [In reply to] Can't Post

I am confuse after this long. Is there any short tip to understand this.


FishMonger
Veteran / Moderator

Feb 7, 2014, 12:59 PM

Post #9 of 12 (1315 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

When getting input from the user via <STDIN>, that input string will end with the line terminator (INPUT_RECORD_SEPARATOR). The chomp function removes that character.


miningdata
New User

Feb 10, 2014, 12:40 PM

Post #10 of 12 (1260 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post

I have a beginner perl-tutorial on youtube if you want to check it out

Moderated (Laurent_R): web link removed



(This post was edited by Laurent_R on Feb 10, 2014, 2:23 PM)


Laurent_R
Veteran / Moderator

Feb 10, 2014, 2:20 PM

Post #11 of 12 (1256 views)
Re: [miningdata] help required in perl [In reply to] Can't Post

Did you come here just to hijack this thread and advertise for your tutorials?

Please don't do that (and, especially, don't do that again, your post might just be deleted without further notice).

I could well understand that you create a new thread about your videos and ask for comments. But please don't try to troll and spoil existing threads with totally off-topics posts.

I would have a number of comments (including blatant opportunities for improvement) on your videos, but I will not do it here.


Laurent_R
Veteran / Moderator

Feb 10, 2014, 2:39 PM

Post #12 of 12 (1253 views)
Re: [sania.mirza] help required in perl [In reply to] Can't Post


In Reply To
I am confuse after this long. Is there any short tip to understand this.


In brief and in general terms, chomp is used for just removing the trailing end-of-line characters. For example, if you read from <STDIN> input from your user, any input will be followed by an end-of-line character (the return key pressed by the user). If your user entered "a", the variable (say $input) you read from STDIN will contain "a" followed by some character or sequence of characters (depending on the OS). If you want to compare the user input with letter "a" (presumably a menu option),

Code
 if ($input eq "a") { 
do_something();
};


the comparison will fail because your user input might be "a\n" or "a\r\n" or whatever your system thinks is an end of line. Chomping the $input variable will enable you to get a "a", without the trailing end-of-line characters, so that your comparison might now succeed.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives