Sponsored Content
Full Discussion: My crap PERL program
Top Forums Shell Programming and Scripting My crap PERL program Post 28505 by auswipe on Thursday 19th of September 2002 10:54:56 AM
Old 09-19-2002
Re: My crap PERL program

Quote:
Originally posted by WIntellect
-------------------------------------------------------------------
#!/usr/bin/perl

# --------------------------------------------
# Numbers and outputs the lines in a text file
# --September 2002----------------------------

while ($ln = <>) {
print $.,": ", $ln;
}

-------------------------------------------------------------------
I am old and frumpy and still prefer to do it the "old fashioned way" and not use the fancy dancy built in perl vars.

I would do it this way:

Code:
my $lineNumber = 1;

while ($ln = <>) {
  print "$lineNumber: $ln\n";
  $lineNumber++;
};

Yeah, I know it doesn't make full use of the plethora of built in Perl vars, but most any programmer can sit down and look at it and go "Ah-ha!"

Learing Perl is a good thing. I use it under Win32 at work and under *BSD at home.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl program

I wish to write a Perl program that will provide a listing of files in a directory. The files must be listed in sorted order by the file name. • By default, the program displays only file names. • By default, the program lists the files in the current directory. • The program must provide the... (2 Replies)
Discussion started by: livewire06
2 Replies

2. Shell Programming and Scripting

perl program

could i get any help with how to link this program together. i dont know what to put where the X's are print `flush`; thank(); #print thank header use Getopt::Std; # use declaration with the options function getopts("ld:") or usage() and exit; ... (3 Replies)
Discussion started by: livewire06
3 Replies

3. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

4. Shell Programming and Scripting

I'm beginning to believe that Perl is crap.

Must every module be compiled? Why is it Math::GMP never installs? I was simply trying to use Net::SSH::Perl and it's driving me nuts. Granted, I am working as a user with limited privileges, but this is ridiculous. I even tried creating an ubuntu virtual machine, going in as root, and... (2 Replies)
Discussion started by: mrwatkin
2 Replies

5. Shell Programming and Scripting

Exiting a program! - perl

how would you exit out of a programm correctly, without having for the program to crash? for example print "Enter quit"; $input = <STDIN>; if ($input eq "quit") { {QUIT THE PROGRAM} } else { print "invalid input"; } one more thing, how do u exit a program "correctly", if... (3 Replies)
Discussion started by: bshell_1214
3 Replies

6. Programming

Perl program

Hi I am new to perl, i need to write a program to convert horizontal words to vertical eg: cat, dog, cow,.....(text file) this should be written as 1.cat 2.dog like this. can u pls help me to work out.. (4 Replies)
Discussion started by: nitha
4 Replies

7. Shell Programming and Scripting

Help regarding a Perl Program

I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it. Search a directory which has word "*latest*" in its path. and then from the latest go through z/x/c to file final.html. In total, i want it to go through... (4 Replies)
Discussion started by: hemasid
4 Replies

8. Shell Programming and Scripting

Perl program

can anyone help me out to write a code by connecting to the sql database and I need to print the list of tables present in the databse. any ideas please. (1 Reply)
Discussion started by: ramkumar15
1 Replies

9. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies
Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrUser3Contributed Perl DocumePerl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict(3)

NAME
Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict - Prohibit various flavors of "no strict". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
There are good reasons for disabling certain kinds of strictures, But if you were wise enough to "use strict" in the first place, then it doesn't make sense to disable it completely. By default, any "no strict" statement will violate this policy. However, you can configure this Policy to allow certain types of strictures to be disabled (See "CONFIGURATION"). A bare "no strict" statement will always raise a violation. CONFIGURATION
The permitted strictures can be configured via the "allow" option. The value is a list of whitespace-delimited stricture types that you want to permit. These can be "vars", "subs" and/or "refs". An example of this customization: [TestingAndDebugging::ProhibitNoStrict] allow = vars subs refs SEE ALSO
Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module perl v5.16.3 2014-06-09 Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict(3)
All times are GMT -4. The time now is 08:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy