Code Examples and Notes

Project Page


my $hello="hello there";
print "$hello from Perl\n";

use Pelfe;

use strict;

use PKG.Mypackages::GoodPackage;
use PKG.Pelfe::Preproc;

/* Pelfe places all unprefixed variables into the & namespace, so unprefixed variables may be accessed with or without the &. $, @, % remain seperate namespaces. All types of structures can be placed within a & symbol, including hash, array, and scalar, with the hash, array and scalar functions. */

my hash &hash;
my array &array;
my scalar &scalar;

my hash hash1;
my array array1;
my scalar scalar1;

my scalar goodobj=PKG.Mypackages::GoodPackage.new;

my scalar goodresult=goodobj.goodmethod "hello there";

say "$hello from Pelfe";

my scalar fiveplusfive=5+5;

my fpf=ref fiveplusfive;

say "Five plus five is &fiveplusfive";

say deref fpf;

my hash myhash=(hello=>"there");

my mref=ref myhash;

say mref.hello;

my mref3=ref ref mref;

my mref=deref deref mref3;

my &one=1;

say one;

say &one;

my $oneref=\&one;

say $$oneref;

my &oneref=\&one;

say &&oneref;

my @array=("hello");

say $array[0];

say @array[0];

say @array{0};

my arrayref=\$array;

say arrayref.0;

say &&arrayref[0];



if (time < 33333) {
CODE.="say 'hello there1';";	

else {

CODE.="say 'hello there';";	
setmacro 'MACRO', sub {say 'hello again &_[0] ';};

// You can insert macros inside of macros here
setmacro 'MACRO2', "say 'hello again 2 &_[0] ';";



MACRO("A message to print");
MACRO2("A message to print");

/* Both scalar and scalar1 are variable  */

my scalar, scalar1;

/* Only scalar1 is variable */

my scalar scalar1;

// Both scalar and var1 are variable

my scalar (scalar, var1);


my var="hello";

sub var : avalue {

my scalar assigned=ASSIGNED[0];
return "hello from sub &assigned";

#prints hello from sub
say var();

# prints hello

say var;

# prints hello from sub

say var "hello there";

# prints "hello from sub hello again"

var()="hello again"; 

my array myarray;

myarray[1]="element 1";

say myarray[1];

# This is valid too
say myarray{1};

foreach (my vcount=0; vcount< 32; ++vcount) {
say "This is greeting number &vcount from Pelfe &ffunction";	

ffunction ("this is just a message");


ffunction "Just another message " cc vcount;

my vresult;

ffunction from "Just another message" cc vcount into vresult;


(my array vreturn, my scalar another) my sub ffunction (my msgin) {
say " We were told to print this: &msgin";


sub printmsg {
my (scalar invariable, array inarray)=_;	

say "This is just another message";

return 1;

// new sub created automatically, can be ovewritten with your own

my mypkg=PKG.Mypackage.new;


package Mypackage {
sub hello (my self) {
	say "hello my friend";

sub hello1 (my self) {
	say 'hello1';

#yes its possible to do this
sub hello=hello1;

# if the sub is avalue, this can be used to force an overwrite

forceassign hello, hello1;

forceassign [hello, helloa], [hello1, hello2];

my hashref myhash;


say myhash.hellothere;

my hellovar="hellothere";

say myhash.(hellovar); // The parens contain a codeblock

say myhash.{hellothere}; // "hellothere is parsed as plaintext

// delete a symbol
delete hello;

// Everything can be an object	
my mhobj=getobj myhash;

say mhobj.access("hellothere");

say mhobj->access("hellothere");

our array myarray=("hello", "there");
my currentscopeid=getscopeid;
my pkgref=ref PKG.Mypackage;

my arrayref=ref PKGS.Mypackage.main.myarray;

say SCOPES.(currentscopeid).main.myarray.0;	

my scoperef=ref SCOPES.(currentscopeid);

/* This is an enhanced version of caller, it includes all scopes, with instruction numbers, function names, codeblock ids, basically all context information 

Every function has a codeblock id


my array contextstack=getcontextstack()

my currentcontext=getcontextid();

my array contextstack=getcontextstack(currentcontext);

my array contextstack=CONTEXTSTACK.(currentcontext);

my codeid=getcodeid();

my scopeid=getscopeid();

my array scopestack=getscopestack();


sub delete (my array todelete) {

my array varstack=gethist(todelete[$count]);
my variable=varstack[1];



The Pelfe Programming Language is essentially based on Perl, and follows a similar philosophy of allowing for great programmer freedom, and not placing restrictions on the programmer which are spurious or without any real need or absolutely necessary but instead on the tastes of the designer. We try to limit the effects that the tastes of the language designer has on how the language can be used. We believe, that instead of making the language more difficult to write and read, instead the reverse is often true. Restricting how a language can be used, in certian unusual cases where a certian feature must be used, can actually cause the programmer to resort to odd workarounds and hacks that can harm readability. There are some features, which are more unusual and which one would not normally use, but may be needed in some special situation. Some may want to remove this feature since if used where it is not needed, it may impair readability. Yet, in situations where it is needed, it may provide a more straightforward solution, and its absense may cause more difficult to understand and convoluted code. The language has its more obvious and more used, straightforward features that will be used in a typical program. The more unusual features tend to be less natural and less favourably used when there is a simpler and more common way to write something. The lesser used features, which in some contexts may not be appropriate, may in other contexts be essential. So therefore, it is best we believe to let the programmers decide and not restrict or limit the language that would make more difficult applications impossible.