Arrays and Hash Methods

03-20-2014
Tags: Developer

Someone asked me the other day, "Why do FWS array & hash methods have the name hash and array in them ( i.e. somethingHash() and somethingArray() )?"   What a great question!  So I figured I would write a little article about why that was done - because it wasn't the first time someone asked :)


Method names in FWS have a theme to help people that write in different language or are new to programming make it easier to get started.  There are a couple more conventions like this if your familiar with FWS, but the convention we will cover here are arrays & hashes.   When getting data from default methods of FWS you usually are getting arrays of hashes or a single hash.   Here is an example:


my @dataArray = $fws->dataArray( type=> 'this_type' );

This will give me back an array of hashes of anything that matches this type.  For a single hash that would have been returned you would retrieve it like:

my %dataHash = $fws->dataHash( guid => 'some_guid' );

And this theme is repeated pretty much anywhere that uses arrays of hashes.  There is one extra piece this is handy for advanced FWS coders, and that is the use of a reference.   The other convention is the ability to use the ref => 1 into the parameters, when used you will retrieve the array as an array reference.  This is great for larger arrays, and are more efficient in general because your pointing at the list, not copying it to a new array every time you ask for it.

my $dataArrayRef = $fws->dataArray( type=> 'this_type', ref => 1 );

The idea of references sometimes takes a few for new Perl programmers to pick up, but once you get the hang of them, you should use the ref => 1 all the time.

 

 

FWS::V2 Release 10 Live!

09-09-2013
Tags: Developer

CPAN release 10 is now live as version FWS-V2-1.13091122.    This release is the landmark of the CLI version of FWS and the web rendering version combined.  With combining them the CPAN version will now share the same version system as the web rendering version so... I guess its not fair to call it release 10 anymore.   Thanks for everyones hard work making this transition. An extended recognition to Richard Crawford, Julia Hollender and Amanda Lewis.   Hats off to them, and everyone that took part in this release!


Why is this good?

#
# My server knows about FWS - lets just use its version and we are
# good to go for web rendering
#

use FWS::V2;


If your server has the current FWS installed, no need to maintain it per instance.   This update is promoted to enhance use of cloud based hosting with FWS and instant installs that no longer require pulling the core package down when creating a new instance.   Your admin package can still be independent of the core code which allows even more versatility, and exciting customization opportunities for the future!

CPAN release:
https://metacpan.org/release/FWS-V2


Current development and master branch at github:
https://github.com/natelewis/FWS-V2


If you would like to be involved in our open source project and be part of the FWS team let us know at development (at) frameworksites.com.   There is several initiatives bringing new functionality and wider support to FWS.

 

Blog Categories

Get FWS 2.1

Getting a FrameWork Sites installation is easy:

  1. Log into this site
  2. Click FWS Installations
  3. Add your domain name
  4. Click the install link
  5. Use your FWS Website!

Host Your FrameWork Sites Website At iPage for $1.99 a Month!

affiliate_link