#!/usr/bin/perl use warnings; use strict; my $loop = 1; my @nums = (-10,-10,-10,-10); my $idx = 0; my $ecuation = $ARGV[0]; $ecuation =~ s/\_/**/g; sub check{ $ecuation =~ s/a/$_[0]/ge; $ecuation =~ s/b/$_[1]/ge; $ecuation =~ s/c/$_[2]/ge; $ecuation =~ s/d/$_[3]/ge; my @sides = split(/=/,$ecuation); if (eval($sides[0])==eval($sides[1])){ print "a = $_[0] \nb = $_[1]\nc = $_[2]\nd = $_[3]\n"; print "done..\n"; exit; } } while($loop) { &check(@nums); $idx = 0; $nums[$idx]++; while($nums[$idx]>10){ $nums[$idx] = 0; $idx++; if($idx>4) { $loop = 0; last; } $nums[$idx]++; }