I posted this but then reconsidered because honestly it's really not that great but ww had beef so here's the post:

I made this little module to carry over some things i liked about C as well as some other stuff. Just drop it into your folder and do a  require 'spice.pm'; link: http://code.google.com/p/perl-spice/source/browse/trunk/spice.pm The perldoc doesn't cover all the functions. I need to update it.

UPDATE: implemented most of tobyink's suggestions and corrected spelling of promt to prompt by suggestion of no_slogan
# Copyright 2013,2014 Dakota Simonds # This program is free software: you can redistribute it and/or mod +ify # it under the terms of the GNU General Public License as published + by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/license +s/>. use warnings; use strict; sub EXIT_SUCCESS (){ #C style 1; } sub TRUE (){ 1; } sub FALSE (){ 0; } sub forceflush{ our $| = 1; return EXIT_SUCCESS; } sub savefile{ #savefile(filename, data); my $SVFL; open $SVFL, ">>", $_[0]; syswrite $SVFL, $_[1]; close $SVFL; return EXIT_SUCCESS; } sub assert{ #C style my @assertions = @_; foreach my $testAssertion (@assertions){ if( not eval $testAssertion ){ print "Assertion failure: '$testAssertion'\n"; exit 0; } #else{ print "win\n"; } } return EXIT_SUCCESS; } sub prompt{ my $question = shift; my $style = shift; my $styleOut; my $input; my %styles=( plain => "\x20", normal => ': ', yn => ' (y/n) ? ', ); if($style eq ""){ $styleOut = $styles{"plain"}; } else{ $styleOut = $styles{$style}; } { #these currlies makes redo work when input is not valid print $question, $styleOut; $input = <STDIN>; chomp $input; if(not $input =~ m/(y|n)/i and $style eq "yn"){ print "\nThat is not a valid input!\n"; redo; } } return $input; } sub strcat{ my $compiled; for my $str (@_) { $compiled = $compiled . $str; } return $compiled; } sub longCatIsLoooooooooooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooonnngggggg{ return ''; } 1; __END__ =head1 NAME Spice =head1 SYNOPSIS technically all these are functions but these three return true or false and take no arguments. meant to reduce magic numbers. EXIT_SUCCESS - C style return (true) TRUE - returns 1 FALSE - returns 0 forceflush - same as $|=1 savefile - appends data to a file assert - C style fuction. Like eval but if code reurns a fal +se the program exits otherwise returns 1. takes a list. prompt - get input in one line strcat - a funtion the concatinates it's inputs savefile - writes to a file in one line =head1 DESCRIPTION Simple PERL module to that fixes small anoying things and provides + a bit of C style funtionality =head1 EXAMPLES forceflush; while( TRUE ){ do something } savefile("meows.txt", "data"); if($foobar == FALSE){ do something } prompt("keywords","normal"); prompt("do you want a cookie", "yn"); prompt("do you want a cookie (Y/n)?", "plain"); assert('$a=1'); savefile($filename, $data); return EXIT_SUCCESS; =cut

In reply to C and other stuff by perlaintdead

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.