Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^15: The current state of Perl6

by Anonymous Monk
on Apr 28, 2010 at 20:01 UTC ( #837380=note: print w/ replies, xml ) Need Help??


in reply to Re^14: The current state of Perl6
in thread The current state of Perl6

it's a language for sysadmins then, not for programmers. that's why it's not going to succeed in programming, but in glueing stuff together and continuing to be a mediocre scripting language.


Comment on Re^15: The current state of Perl6
Re^16: The current state of Perl6
by BrowserUk (Pope) on Apr 28, 2010 at 21:40 UTC

    Your arguments are getting weaker. Just be you can write it that way, it does mean you have to.

    You could write it as below. And if that makes you feel that you've done a "proper job", then you're welcome to, but it'll just take you longer, be no more "reliable"; and is no more good or "proper programming" than the one-liner.

    #! perl use strict; use warnings; use constant { FILENAMEROOT => 'split.', OPEN_MODE_OUTPUT => '>', OPEN_MODE_INPUT => '<', SELECTOR_OFFSET => 3, SELECTOR_LENGTH => 1, ZERO => 0, ONE => 1, TEN => 10, }; ############################ # Main program starts here # ############################ ################################ # An array to hold filehandles # ################################ my @fileHandles; ###################################### # iterate from 0 to 9 # # compose a filename incorporating # # the number of the split file # # open the file for output # # check that it opend successfully # # push the filehandle onto the array # # of filehandles index by the number # ###################################### for( my $index = ZERO; $index < TEN; $index = $index + ONE ) { ## A varible to hile the composed filename my $fileName = FILENAMEROOT . $index; # another to hold the file handle my $fileHandle; # open the file my $rc = open $fileHandle, OPEN_MODE_OUTPUT, $fileName; # check it opened successfully, or die if( $rc == 0 ) { die "Couldn't open " . $fileName . " for output; rc = " . $rc . "; Errortext = " . $!; } # else add it to the array of filehandles else { push @fileHandles, $fileHandle; } } die "You must supply an input filename" unless scalar @ARGV == 1; # get the name of the input file my( $inputFileName ) = @ARGV; die "The filename you supply must exist" unless -e $inputFileName; die "The file must contain something" if -z $inputFilename; # open the input file $rc = open my $inputFileHandle, INPUT_MODE, $inputFileName; # Did it open? Die if not. if( not $rc == 0 ) { die "couldn't open $inputFileName: $!"; } # iterate over the input file one line at a time while( defined( my $inputLine = readline( $inputFileHandle ) ) ) { # extract the character by which we select # the output file to put this line in my $selectorCharacter = substr( $inputLine, SELECTOR_OFFSET, SELECTOR_LENGTH ); # check that it is a digit, otherwise die if( $selectorCharacter lt '0' or $selectorCharacter gt '9' ) { die "Selector character is not a digit: " . SelectorCharacter; } # selector character is okay else { # so get the appropriate filehandle from the array my $fileHandle = @fileHandles[ ord( $selector ) - ord( S$selectorCharacter ) ]; # check that we actually got a filehandle, or die if( not defined $fileHandle ) { die "Couldn't obtain fileHandle for Selector character " . $selectorCharacter; } # okay, we've got a filehandle else { # so output the file handle to the appropriate file print $fileHandle $inputLine; } } } # close the input file close $inputFileHandle; # iterate over the output filehandles array for( my $fileHandleIndex = 0; $fileHandleIndex < 10; $FileHandleIndex = $fileHandleIndex + ONE ) { # get the output filehandle my $fileHandle = $fileHandles[ $fileHandleIndex ]; # make sure that it hasn't gone walkies in teh last 3 milliseconds if( not defined $fileHandle ) { # and die if it has (leaving all the other filehandles unclose +d; but what can you do?) die "Couldn't obtain fileHandle for index " . $fileHandleIndex +; } # okay, we;ve got a filehandle else { # so now we can close it. (Shoudl we check that it actually cl +osed successfully?) close $fileHandle; } } ###################################################################### +######## ###################################################################### +######## ## + ## ## EEEEE N N DDDD PPPP RRRR OOO GGG RRRR A M + M ## ## E NN N D D P P R R O O G G R R A A M +M MM ## ## E N N N D D P P R R O O G R R A A M + M M ## ## EEEE N NN D D PPPP RRRR O O G GG RRRR AAAAA M + M ## ## E N N D D P R R O O G G R R A A M + M ## ## E N N D D P R R O O G G R R A A M + M ## ## EEEEE N N DDDD P R R OOO GGG R R A A M + M ## ## + ## ###################################################################### +######## ###################################################################### +######## exit;

    More just a wannabe C programmer using Perl...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://837380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-07-12 23:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (242 votes), past polls