New

## Long-Term Learning

Learn efficiently and remember over time.

## Start Long-Term Learning

Get personalized study reminders at intervals optimized for better retention.
Track your progress on this set by creating a folder
Or add to an existing folder

## Add this set to a folder

my \$x = 5;

### declare a string x equal to Mary

my \$x = 'Mary';

### declare an array a of the numbers 1,2,4

my @a = (1, 2, 3);

### declare a hash h where a has key 1, b has key 2

my %h = (1=>a, 2=>b);

### concatenate strings hello + world into s

\$s = 'hello'.'world';

chomp(\$s)

length(\$s)

lc(\$s)

### get substring of s

substr(\$s, start, len)

### join bob & mary by comma

join(',','bob','mary');

### read one line from keyboard

\$x = <STDIN>;

### print hello world

print "Hello world";

### start perl script

#!/usr/bin/perl
use strict;
use CGI ':standard';

### get all data from CGI using post

@var = param();

### get name data from CGI using post

\$var = param('name');

### get 2nd and 3rd values from days array

(\$x, \$y) = @days[1,2];

### remove last item in @days

\$last = pop(@days);

### remove first item in @days

\$first = shift(@days);

### sort @days alphabetically

@sorted = sort(@days);

### reverse days array

@rev = reverse(@days);

### get item with key 2 in data hash

\$item = \$data{'2'};

### cycle through each element in hash %data

while ( (\$key, \$val) = each (%data) ) {print "\$key = \$val";}

### if string equals yes

if (\$s eq 'yes')

### for each variable in array, print variable

foreach \$x (@array) { print "\$x"; }

\$#array

/[A-Z]/

/\w\s/

/^ABC/

/ABC\$/

### if x contains either A B or C

if (\$x ~= /[ABC]/)

### print date in \$s = "Today is 17 May 2006"

\$s ~= /(\d+) (\w+) (\d+)/;
print "\$1 \$2 \$3";

### split string by comma into array

@a = split /,/,\$s;

s/bob/mary/;

### open file and print "hello"

open (my \$in, ">>file.txt");
print \$in "hello";
close \$in;

### open file.txt and read each line, printing to console

open(my \$in, "<file.txt");
while (my \$row = <\$in>) { print "\$row"; }
close \$in;

Example: