From 6cb64cd1aef06d22ca89c415ef8f75dea17274ac Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 3 Nov 2009 00:03:05 +0100 Subject: [PATCH] Add UUID parsing & printing --file works --- hostuuid.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hostuuid.pl b/hostuuid.pl index ee15744..e93322d 100755 --- a/hostuuid.pl +++ b/hostuuid.pl @@ -34,11 +34,25 @@ sub print_help() { exit 0; } +sub print_hostuuid() { + open (F, "< $file") or die "$program\: Could not open file: $file\: $!\n"; + while () { + if (/([0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12})/i) { + print "$1\n"; + close (F); + exit 0; + } + } + print STDERR "$program\: Could not find UUID in $file\n"; + exit 100; +} + sub main() { print_version() if $version; print_help() if $help; print "file: $file\n"; + print_hostuuid(); } main(); -- 2.11.4.GIT