Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

some notes on ideas of perl and how it works

  • Loading branch information...
commit d1d88465d3246a4d6e588683f38689a8691b6689 1 parent 5a84811
@roopeshvaddepally authored
Showing with 50 additions and 0 deletions.
  1. +50 −0 step1.md
View
50 step1.md
@@ -0,0 +1,50 @@
+### Ideas about the why's and what's
+#### Documenting stuff
+
+`perldoc` is the utility to access documentation of installed modules.
+
+##### useful links:
+[recent version of perl documentation](http://perldoc.perl.org)
+[cpan index 1](http://search.cpan.org)
+[cpan index 2](http://metacpan.org)
+
+Examples of usage:
+
+ $ perldoc List::Util
+ $ perldoc perltoc
+
+#### Design of perl
+TIMTOWTDI (Tim Toady): There Is More Than One Way To Do It
+DWIM: Do What I mean
+Principle of Least Astonishment
+
+#### Context
+governs the amount and kind of data to use.
+
+#### Void, Scalar, List contexts
+**amount context** : how many items you expect from operation
+
+`find_chores();` just a regular call without using it's return value calls
+the function in *void context*
+
+example of a *scalar context* is:
+
+ my $single_result = find_chores();
+
+In a *list context*:
+
+ my @all_results = find_chores();
+ my ($single_result, @rest) = find_chores; # paranthesis as lexical scope
+ process_list_of_results( find_chores() );
+
+`my ($single) = find_chores();` is equivalent to `my ($single, @rest) = find_chores();`
+paranthesis hint at list context to parser
+
+lists propogate list context
+
+ process_list( find_chores() );
+ my %results = (
+ cheap_operation => $cheap_results,
+ expensive_operation => find_chores(), # <- triggers list context
+ # expensive_oepration => scalar find_chores(),
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.