Epoch & Unix Timestamp Conversion Tools
Perl Code –> perl -e ‘print scalar localtime(1217646573), “\n”;’
or use this URL http://www.epochconverter.com/
Perl Code –> perl -e ‘print scalar localtime(1217646573), “\n”;’
or use this URL http://www.epochconverter.com/
bunzip2 -d < filename.bz2
tcsh
foreach f (`find . -name ‘*.txt’`)
echo $f
end
1. Go to Start>Programs>Microsoft Excel to open the application. Go to File>New and open a new spreadsheet.

2. Go to Tools>Customize and select it.

3. A pop-up menu window called “Customize” will appear, click on the “Toolbar” tab and select the toolbar where you want the macro button to appear. For this tutorial, we want the macro button to be accessible and visible in the “Standard” toolbar, so check the box for the Standard toolbar.

4. Now click on the “Commands” tab and select a category – the kind of function you will be creating as a button. Go down and select “macros.” The Commands window to the right of the pop-up window appears with two options: Custom Menu Item or a Custom Button.

5. Click on the “Custom Button” (it looks like a happy face) option and drag it to the standard toolbar (located at the top of the screen under the different menu options – File, Edit, etc.), place it right next to the “Save” button so it is easy to locate.

6. Now click on the new macro button and a pop-up window called “Assign Macro” will appear. Here select the actual macro that will be assigned to this button, so for this tutorial we’ll use one already created called “PERSONAL.XLS!.ht” macro and hit OK.


7. Finally, we’ll test the new custom macro button. Go to File>New to open a new spreadsheet, and click on the newly created macro button located on the standard toolbar to the right of the “Save” button. After clicking the button, you will see the names of ten training managers automatically appear.


Great! wasn’t it super easy. You can basically follow the same steps to add a button for any function other than a macro. Remember to keep practicing because the more you do it, the better you will get.
| Figure A |
![]() |
| Figure B |
![]() |
| Figure C |
![]() |
You may now run your macro by clicking the button you’ve created. It will be available from all workbooks.
Create a macro button in Microsoft Word
Creating a macro button in Microsoft Word is similar to creating one in Excel. The following directions were written using Microsoft Word 2000. Instructions for other versions may differ slightly. Before starting the steps below, I created a macro, named PasteText, to paste unformatted text in Word documents. To create a macro button:
| Figure D |
![]() |
| Figure E |
![]() |
You may run your macro by clicking the button you’ve created. It will be available from all documents.
contents of a variable to a regular expression, use the =~ operator. Regular expressions are also used by perl built in functions such as grep and split, and by the s operator.
Perl uses a very full set of elements within its regular expressions, most of which are terse so hard for the newcomer to follow when maintaining code. It predates, so does not follow, the POSIX standard.
Perl 6, currently under development, will support grammars and rules rather than regular expressions. Grammars and Rules will take pattern matching to a whole new level, and tools will be available to covert code – in other words, rules and grammars will do everything that the old Regular Expressions didn’t, and more.
|
Operator Type |
Examples |
Description |
|
Literal Characters |
a A y 6 % @ |
Letters, digits and many special |
|
$ ^ + \ ? |
Precede other special characters |
|
|
n t r |
Literal new line, tab, return |
|
|
cJ cG |
Control codes |
|
|
xa3 |
Hex codes for any character |
|
|
Anchors and assertions |
^ |
Starts with |
|
$ |
Ends with |
|
|
b B |
on a word boundary, |
|
|
Character groups |
[aAeEiou] |
any character listed from [ to ] |
|
[^aAeEiou] |
any character except aAeEio or u |
|
|
[a-fA-F0-9] |
any hex character (0 to 9 or a to f) |
|
|
. |
any character at all |
|
|
s |
any space character (space n r or t) |
|
|
w |
any word character (letter digit or _) |
|
|
d |
any digit (0 through 9) |
|
|
S W D |
any character that is NOT a space |
|
|
Counts |
+ |
1 or more (“some”) |
|
* |
0 or more (“perhaps some”) |
|
|
? |
0 or 1 (“perhaps a”) |
|
|
{4} |
exactly 4 |
|
|
{4,} |
4 or more |
|
|
{4,8} |
between 4 and 8 |
|
|
Add a ? after any count to turn it sparse (match as few as possible) rather than have it default to greedy |
||
|
Alternation |
| |
either, or |
|
Grouping |
( ) |
group for count and save to variable |
|
(?: ) |
group for count but do not save |
|
|
Variables |
$xyz |
Insert contents of $xyz into regular expression |
|
1 2 |
Back reference to 1st, 2nd etc matched groups |
|
After the closing / of your regular expression, you can add one or more modifiers to change its behaviour.
|
Modifier |
Description |
|
i |
Ignore case in matching |
|
g |
Global match. Return a list of all matches (list context) or return the next match (scalar context) |
|
x |
White space is to be treated as a comment (otherwise it matches exactly) |
|
s |
. to match everything including new line (otherwise it matches everything except new line) |
|
m |
^ and $ to match embedded new lines |
|
o |
Tell compiler that regular expression doesn’t change even if it includes a variable reference |
|
e |
s command only. Execute the output before you substitute it in |
The following Perl functions and operators use regular expressions
|
Function / Operator |
use |
|
|
If you write a regular expression without an operator, it matches the regular expression against the contents of the $_ variable. |
|
=~ |
Match the regular expression to the right against the variable to the left |
|
s |
Substitute the matched regular expression with a replacement string |
|
grep |
Filter a list for all member scalars that match the regular expression |
|
split |
split a scalar into a list, dividing the elements at the regular expression |
The above lists show the most commonly used elements of Perl regular expressions, and are not exhaustive.
In Perl, you can change the / regular expression delimiter to almost any other special character if you preceed it with the letter m (for match); if you change to ( { or [, the balancing end expression character becomes ) } or ].
sub trim($){
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
$body =~ s/(\s)/(++$count%15==0)?”\n”:$1/ige;
use Cwd;
my @files;
opendir (DIR, $dirname) or die $!;
my @dir = readdir DIR;
foreach my $item1 (@dir){
if ($item1 ne “..” || $item1 ne “.”){
push @files ,$item1;
}
}
closedir DIR;
Validate if the string passed in a valid email or not
returns true or false
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
returnval=emailfilter.test(<Email address to be tested >);
in the below code the 2 can be replaced with n number and \s is for space and \n for new line charecter
$string =~ s/(\s)/(++$count%2==0)?”\n”:$1/ige;
#!/usr/local/bin/perl
my $file_name = “/apps/intranet/ns-home/Apache_Server/Public/TechCouncil/TIITC/2006/data/a0756159_1148893709_Karnataka%20Map.pdf”;
open(FILE, “< $file_name”) or die (“$!”);
while (<FILE>) {
$File .= $_;
}
close FILE;
print “Content-Type: application/pdf”, “\n”;
print “Content-Disposition: Attachment; filename=Abc.pdf”, “\n\n”;
print $File;