This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sentence = "the boy is 20"; | |
if($sentence =~ /the/) | |
{ | |
print "true"; | |
} | |
if($sentence =~ /Trhe/) | |
{ | |
print "true"; #will return false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
#To view This Program's Documentation execute `perldoc programname.pl` | |
=head2 utilityName.pl | |
AUTHOR: Joe Developer | |
CREATION DATE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
package moduleName; | |
use strict; | |
use warnings; | |
#To view This Module's Documentation execute `perldoc modulename.pl` | |
=head2 module.pm | |
AUTHOR: Joe Developer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub addDashes | |
{ | |
my $originalFileName = shift; | |
#split along uscores into array | |
my @parts = split('_',$originalFileName); | |
# take the third index of the array and add dashes in this pattern ####-##-## and put it back in the array | |
$parts[2] = join('-', unpack('A4A2A2', $parts[2])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $path = '/home/opuperl'; | |
opendir my($dirh), $path or die "can't opendir $path: $!"; | |
my @flist = sort { -M $a <=> -M $b } # sort by mod time | |
map { "$path/$_" } # need full paths for sort | |
grep ! m/^\./ # remove dotfiles | |
,readdir $dirh; | |
closedir $dirh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub flipSwitch{ | |
my $file = shift; | |
my $fileHandle; | |
my $value; | |
open($fileHandle,'<',$file) || warn "cant open switch file $!"; | |
$value = <$fileHandle>; | |
close($fileHandle); | |
chomp($value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(){ | |
runUntilEnterPressed(); | |
enterWasPressed(); | |
} | |
sub runUntilEnterPressed{ | |
my $input; | |
my $select_object = IO::Select->new(); $select_object->add(\*STDIN); | |
my $sleep = .1; | |
until($input){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $PARTITION = "================================================================================\n"; | |
my $PARTITIONLENGTH = length($PARTITION)-1;#-1 to remove newline from count | |
my $emptySpaceLen = $PARTITIONLENGTH - length($partOne.$partTwo.$partThree.$partFour); | |
my $divider = makeDivider($emptySpaceLen, 4); | |
my $return = "$partOne$divider$partTwo$divider$partThree$divider$partFour\n"; | |
$return .= $PARTITION; #for this application i needed a partition after each section | |
return $return; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub getCount{ | |
my $DH; # Directory Handle | |
my $WD = $_[0]; # Working Directory | |
my $DE; # Directory Entry (file) | |
my $CT; # Count | |
$CT=0; | |
opendir($DH, $WD) or die "Cannot open working directory |$WD|: $!"; | |
while ($DE= readdir($DH)) | |
{ |