View copyMove.pl
#!/usr/bin/perl
#copyMove.pl By: Andrew Hayes <http://AndrewHay.es/>
#Copyright (c) 2013 Andrew Hayes
#
# This takes a file from Dir A and copies it to Dir B and moves it to Dir C.
# When the copy suceedes it prints a line to the stdout
# When a copy fails it Dies. For now. Dies if dir placed in A.
#
use strict;
use warnings;
View recAdd.pl
#!/usr/bin/perl
#recAdd.pl By: Andrew Hayes <http://AndrewHay.es/>
#Copyright (c) 2012 Andrew Hayes
#
# This perl script recursively adds a given number to every number between it and zero.
#
use strict;
use warnings;
use Scalar::Util qw(looks_like_number);
View phpDBdump.php
<?php
// Connects to your Database
mysql_connect("db.host", "uname", "pwd") or die(mysql_error());
mysql_select_db("ectmenu") or die(mysql_error());
$data = mysql_query("SELECT * FROM pizza") or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{ // here is the menu code below
print"<p>
View perlCmdLineOneLiners.pl
#replace file with file name and the entire contents get printed with line numbers to screen
perl -n -e 'print "$. - $_"' file
#or
perl -p -e '$_ = "$. - $_"' file
View shellOneLiners.sh
#grep recursively
find . -type f -exec grep -n "stuff" {} \; -print
#count files in directory
ls -1 <targetdir> | wc -l
#put contents of one file at end of another
cat ./this-file >> ./into_this-file
# remove results of ls
View date_time.pl
use strict;
use warnings;
use Time::Local;
my $sec = 0;
my $min = 0;
my $hours = 0;
my $day = 28; #(days are 1-31)
my $month = 5; #(months are 0-11)
my $year = 2013;
View arrayByRef.pl
@arr = qw(1 2 3 4 5 6 7 8 9 10);
use Data::Dumper;
#print Dumper(@arr);
printme(1,2,\@arr,4);
View dataDumperSort.pl
use Data::Dumper;
$Data::Dumper::Sortkeys =1;
#$Data::Dumper::Sortkeys = sub { [reverse sort keys %{$_[0]}] }; #reverse order
View updateGitSubmodules.sh
# get the submodule initially
git submodule add ssh://bla submodule_dir
git submodule init
# time passes, submodule upstream is updated
# and you now want to update
# change to the submodule directory
cd submodule_dir
View getSwitchState.pl
my $switchName = "Debug Switch";
open($switchFileHandle,'<',$switchFile) || warn "cant open switch file $!";
$switch = <$switchFileHandle>;
close($switchFileHandle);
chomp($switch);
if($switch){$switch = "ON";}
else{$switch = "OFF";}
$switchString = "$switchName($switch)";