Print Time – Perl

A key requirement for any log is to log the time and date of any action taking place in a script.  The command below will print the time to your log in a readable format print LOG scalar localtime; The output of this in a log will be as follows; Thu Nov 27 14:48:48 2008 [...]

By |2008-11-27T15:50:57+01:00November 27th, 2008|Perl|0 Comments

Change a word in many files

The below one liner will open all files in its path and change the word 'MOO' in any of the files to the word 'BOO'. find . -type f | xargs /usr/iw-home/iw-perl/bin/iwperl -i -p -e 's/MOO/BOO/g;' This script has only been lightly tested so please make a backup of your files before running this!

By |2008-09-27T14:23:24+01:00September 27th, 2008|Magic One Liners, Perl|0 Comments

Find all Branches in TeamSite

The below script will look through all the branches in a TeamSite file system and simply list only the branches, not workareas or files and so on. This script is by no means optimised and could run alot faster by doing checks in the "wanted" sub routine, but it does the job :) This [...]

By |2017-10-05T16:15:22+01:00September 25th, 2008|Perl, TeamSite|0 Comments

A simple log in Perl

I know this is really easy but I get asked it so often, I thought I would note it down. The best way to create a log file from Perl is to use log4perl, but it has a bit of a learning curve so try the simple approach for now which is as follows: open [...]

By |2008-09-23T23:58:43+01:00September 23rd, 2008|Perl|0 Comments

Perl Simple File Find

The below example runs and simply prints the file names of files inside the c:temp folder, you will need to add the behaviour you require on the "print" line: Command line call: perl.exe c:find.pl c:temp Script use strict; use File::Find; my ($area) = @ARGV; my(@files, $file); find(&wanted, $area); foreach $file(@files){ if (-f $file){ print "File: [...]

By |2008-08-27T16:56:15+01:00August 27th, 2008|Perl|0 Comments

Perl Magic One Liners

This page is dedicated to all the quick one line utilities that are useful when managing an Interwoven system or any other system that uses many files. Find all files without metadata of content_type: find . -name '*.xml' -exec /iw-home/iw-perl/bin/iwperl -e '$file=shift;system("/iw-home/bin/iwextattr", -g=> "TeamSite/Metadata/content_type", $file);warn "$filen" if $?' {} ';' >/dev/null Regenerate Recursively find . [...]

By |2008-07-02T09:25:53+01:00July 2nd, 2008|Magic One Liners, Perl|0 Comments