Perl Quotes and Escape Sequences

Perl string literals are enclosed in quotation marks. You can use either single quotes ('') or double quotes ("").

print "hello";
print 'hello'; 

Now suppose you need to print a string which contains a single or double quote such as following strings:

This is bob's watch.
Alice replied, "It was a birthday gift."

If I do the following,

Pushed changes to GIT but don't see it in repository


You pushed your changes to GIT but you don't see it in the repository.


First thing is to compare status with log

git log

will give you a list of the commits. You will not see your changes here.

git status

You will see your files here. Above the list of files, you will see

Changes to be committed


The reason you don't see your changes in repository is because they were not committed.

Converting to and from epoch time

Epoch time is Unix timestamp which counts the number of seconds since January 1 1970 00:00:00 UTC. Without getting into long discussion, follow is how your convert between human readable date and epoch time.

Convert Human Readable Date to Epoch Time

  $now = strtotime('2010-04-25');
  print $now;

Convert Epoch Time to Human Readable Time

PHP Array functions

Passing arrays by value and reference

The difference between passing by value and passing by reference is that you when pass by value, you are passing a copy of the array. When passing by reference, you are passing a pointer i.e any changes made in the function you pass to can modify the original.

function foo($var) {
function bar(&$var) {

print "Passed by value:\n";
print "Passed by reference:\n";


PHP File functions

Opening directory and listing files

See the following code:

  $dir = 'mydir';
  $myfiles = scandir($dir);


  [0] => .
  [1] => ..
  [2] => one.txt
  [3] => two.txt

To remove certain file name from the list, see the following code: