From e96bed6b6cfab16933636d46cd54340932978b83 Mon Sep 17 00:00:00 2001
From: Dominyk Tiller <dominyktiller@gmail.com>
Date: Mon, 2 May 2016 19:39:19 +0100
Subject: [PATCH] perl_requirement: add

---
 Library/Homebrew/requirements.rb              |  1 +
 .../Homebrew/requirements/perl_requirement.rb | 28 +++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 Library/Homebrew/requirements/perl_requirement.rb

diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index 153140000c..7e5b7898c7 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -6,6 +6,7 @@ require "requirements/minimum_macos_requirement"
 require "requirements/maximum_macos_requirement"
 require "requirements/mpi_requirement"
 require "requirements/osxfuse_requirement"
+require "requirements/perl_requirement"
 require "requirements/python_requirement"
 require "requirements/java_requirement"
 require "requirements/ruby_requirement"
diff --git a/Library/Homebrew/requirements/perl_requirement.rb b/Library/Homebrew/requirements/perl_requirement.rb
new file mode 100644
index 0000000000..79d5e8e926
--- /dev/null
+++ b/Library/Homebrew/requirements/perl_requirement.rb
@@ -0,0 +1,28 @@
+class PerlRequirement < Requirement
+  fatal true
+  default_formula "perl"
+
+  def initialize(tags)
+    @version = tags.shift if /^\d+\.\d+$/ === tags.first
+    raise "PerlRequirement requires a version!" unless @version
+    super
+  end
+
+  satisfy(:build_env => false) do
+    which_all("perl").detect do |perl|
+      perl_version = Utils.popen_read(perl, "--version")[/\(v(\d+\.\d+)(?:\.\d+)?\)/, 1]
+      next unless perl_version
+      Version.new(perl_version.to_s) >= Version.new(@version)
+    end
+  end
+
+  def message
+    s = "Perl #{@version} is required to install this formula."
+    s += super
+    s
+  end
+
+  def inspect
+    "#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
+  end
+end
-- 
GitLab