Why would you want to?
Maybe you are just starting out with Perl and don't have a computer set up
for Perl. Unix computers already include Perl, but maybe you don't have the
permissions to run it on your computer.
Maybe you just want to try a Perl module for some
external program that you don't want to install on your
machine. Maybe you just got a bug report for Linux that you
can't easily replicate. Maybe you are online and don't have access
to your home machine. Maybe you just need 5GB of storage quickly.
You just need four steps to get to Perl in the
Google Cloud Shell:
Log in with your Google credentials
That's how you pay for it - with information about yourself. Google will monitor what programs you invoke
but not the command line parameters. In return, you get 5GB of permanent storage and a 2GB RAM virtual machine
that includes Perl 5.24, other programming languages, the Google Cloud SDKs and other stuff.
Set up CPAN to use local::lib
Run the cpan command to perform the initial setup:
cpan
There, you need to answer two questions:
- Choose the quick, no questions asked setup
- Choose the proposed local::lib method of installing modules
Install some stuff that you maybe want to try out
Upgrade Test::More, because the Debian stock 1.01 version causes some spurious test failures
cpan Test::More
cpan App::cpanminus Moo Future::AsyncAwait DBD::SQLite
- Enjoy
More documentation on the Cloud Shell
Using the Cloud Shell as a web development environment
The cloud shell also comes with an included web proxy so that you (and only you) can try out web applications
served from any web server on that machine. This makes the Cloud Shell a convenient testbed to try out web frameworks like Mojolicious, Dancer2, Dancer or even CGI::Application in PSGI mode.
Using Mojolicious
Install Mojolicious
cpan Mojolicious
Run minimal Mojolicious program:
perl -Mojo -E 'a("/hello" => {text => "Hello Mojo!"})->start' daemon -
+l http://127.0.0.1:8080
Visit /hello in the Web Preview pane
Using Dancer2
Install Dancer2
cpan Dancer2
Run minimal Dancer2 program:
perl -MDancer2 -e 'set port => 8080; get "/" => sub { "<i>Just</i> Ano
+ther <b>Perl</b> <u>Hacker</u>," }; dance'
Using Dancer with Twiggy
Install Dancer and Twiggy
cpan Dancer Twiggy
Run minimal Dancer program:
plackup -e 'use Dancer; get "/hello/:name" => sub { return "Why, hello
+ there " . param("name"); }; dance;' --port 8080 -s Twiggy
Visit /hello/yourname in the Web Preview pane
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.