summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2016-07-17 21:47:33 +0200
committercos <cos>2016-07-17 21:47:33 +0200
commit683816f89e81bd064bee6b3f477ec98a1fecad77 (patch)
tree6e4bb20b0fd49f6ea89a1d5dcffaf0a212c29234
parentb1f1845e834fa768bacbe90d2bc80ac1686e94c8 (diff)
parent255a31c21a215bd06cd1884f958130b8e63d3322 (diff)
downloadmat-683816f89e81bd064bee6b3f477ec98a1fecad77.zip
Merge branch 'master' into debian
-rwxr-xr-xauthenticate_session15
-rwxr-xr-xcgi-bin/lada-20150110110
-rwxr-xr-xcgi-bin/lada.cgi109
-rwxr-xr-xcgi-bin/mat.cgi56
-rwxr-xr-xcgi-bin/mat.cgi-package125
-rwxr-xr-xcgi-bin/relocatehook.sh3
-rwxr-xr-xmat66
-rwxr-xr-xsheetprint54
8 files changed, 486 insertions, 52 deletions
diff --git a/authenticate_session b/authenticate_session
index 8995080..4ff6ace 100755
--- a/authenticate_session
+++ b/authenticate_session
@@ -2,4 +2,17 @@
AUTH="'authenticated' => 'yes'"
-sed "s/\('_SESSION_REMOTE_ADDR'\)/$AUTH, \1/"
+replace_stream()
+{
+ sed "s/\('_SESSION_REMOTE_ADDR'\)/$AUTH, \1/"
+}
+
+if [ "$1" ];
+then
+ cd /tmp
+ mv "$1" "$1".unauthenticated
+ cat "$1".unauthenticated|replace_stream > "$1"
+ chown www-data.www-data "$1"
+else
+ replace_stream
+fi
diff --git a/cgi-bin/lada-20150110 b/cgi-bin/lada-20150110
new file mode 100755
index 0000000..793671a
--- /dev/null
+++ b/cgi-bin/lada-20150110
@@ -0,0 +1,110 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Config::Simple;
+use CGI::Simple;
+use CGI::Session;
+use DBI;
+
+tie my %Config, "Config::Simple", '/etc/mat.conf';
+
+my $q = new CGI::Simple;
+my $id = $q->param('id');
+my $action = $q->param('action');
+my $storage = $q->param('storage');
+my $session = CGI::Session->new(undef, undef, {Directory =>
+ $Config{'session_directory'}});
+
+sub misconfigured
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "This system is misconfigured.\n";
+ exit 1;
+}
+
+sub invalid_input()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Invalid input.\n";
+ exit 1;
+}
+
+sub unauthorized()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Not authorized!\n";
+ exit 1;
+}
+
+sub send_cookie()
+{
+ print $session->header(-type => 'text/html', -charset => 'utf8');
+}
+
+sub cmd_view($)
+{
+ my ( $id ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ my $recipe_row = $db->selectrow_arrayref("SELECT name, storage, uri FROM ".
+ "recipes AS r JOIN inventory AS i ON i.recipe_id=r.id WHERE i.id=".$id.
+ ";");
+
+ print $id, "<br />", $$recipe_row[0], "<br />", $$recipe_row[1], "<br />";
+ if(substr($$recipe_row[2], 0, 4) eq "http") {
+ print '<a href="'.$$recipe_row[2].'">'.$$recipe_row[2].'</a>', "<br />";
+ } else {
+ print $$recipe_row[2], "<br />";
+ }
+ if ($session->param('authenticated') eq "yes") {
+ print "<font size=20>\n";
+ for my $store ( split(" ", $Config{'relocate_stores'}) ) {
+ print " <a href=".$Config{'label_id_prefix'}."$id/relocate/$store>".
+ "$store</a> \n";
+ }
+ print "</font>";
+ }
+}
+
+sub cmd_relocate($$)
+{
+ my ( $id, $storage ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ $db->do('UPDATE inventory SET storage="'.$storage.'" WHERE id='.$id);
+
+ cmd_view($id);
+}
+
+### MAIN PROGRAM ##############################################################
+
+misconfigured unless ($Config{'database'});
+misconfigured unless $session;
+invalid_input unless ($id and $action);
+
+invalid_input unless (($id =~ m/^[0-9]+$/) and ($action =~ m/^view|relocate$/) and
+ ($storage =~ /^[a-z0-9]*$/));
+send_cookie;
+
+for ($action) {
+ if (/^view$/) {
+ cmd_view($id);
+ }
+ elsif (/^relocate$/) {
+ if ($session->param('authenticated') eq "yes") {
+ $session->expire("5y");
+ cmd_relocate($id, $storage);
+ } else {
+ unauthorized();
+ }
+ }
+ else {
+ invalid_input;
+ }
+}
diff --git a/cgi-bin/lada.cgi b/cgi-bin/lada.cgi
new file mode 100755
index 0000000..f3b2554
--- /dev/null
+++ b/cgi-bin/lada.cgi
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Config::Simple;
+use CGI::Simple;
+use CGI::Session;
+use DBI;
+
+tie my %Config, "Config::Simple", '/etc/mat.conf';
+
+my $q = new CGI::Simple;
+my $id = $q->param('id');
+my $action = $q->param('action');
+my $storage = $q->param('storage');
+my $session = CGI::Session->new(undef, undef, {Directory =>
+ $Config{'session_directory'}});
+
+sub misconfigured
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "This system is misconfigured.\n";
+ exit 1;
+}
+
+sub invalid_input()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Invalid input.\n";
+ exit 1;
+}
+
+sub unauthorized()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Not authorized!\n";
+ exit 1;
+}
+
+sub send_cookie()
+{
+ print $session->header(-type => 'text/html', -charset => 'utf8');
+}
+
+sub cmd_view($)
+{
+ my ( $id ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ my $recipe_row = $db->selectrow_arrayref("SELECT name, storage, uri FROM ".
+ "recipes AS r JOIN inventory AS i ON i.recipe_id=r.id WHERE i.id=".$id.
+ ";");
+
+ print $id, "<br />", $$recipe_row[0], "<br />", $$recipe_row[1], "<br />";
+ if(substr($$recipe_row[2], 0, 4) eq "http") {
+ print '<a href="'.$$recipe_row[2].'">'.$$recipe_row[2].'</a>', "<br />";
+ } else {
+ print $$recipe_row[2], "<br />";
+ }
+ if ($session->param('authenticated') eq "yes") {
+ print '<font size="20">';
+ print "<a href=https://mat.netizen.se/portion/$id/relocate/magen>magen</a> ";
+ print "<a href=https://mat.netizen.se/portion/$id/relocate/hemkyl>hemkyl</a> ";
+ print "<a href=https://mat.netizen.se/portion/$id/relocate/jobbfrys>jobbfrys</a> ";
+ print "<a href=https://mat.netizen.se/portion/$id/relocate/jobbkyl>jobbkyl</a>";
+ print '</font>';
+ }
+}
+
+sub cmd_relocate($$)
+{
+ my ( $id, $storage ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ $db->do('UPDATE inventory SET storage="'.$storage.'" WHERE id='.$id);
+
+ cmd_view($id);
+}
+
+### MAIN PROGRAM ##############################################################
+
+misconfigured unless ($Config{'database'});
+misconfigured unless $session;
+invalid_input unless ($id and $action);
+
+invalid_input unless (($id =~ m/^[0-9]+$/) and ($action =~ m/^view|relocate$/) and
+ ($storage =~ /^[a-z0-9]*$/));
+send_cookie;
+
+for ($action) {
+ if (/^view$/) {
+ cmd_view($id);
+ }
+ elsif (/^relocate$/) {
+ if ($session->param('authenticated') eq "yes") {
+ cmd_relocate($id, $storage);
+ } else {
+ unauthorized();
+ }
+ }
+ else {
+ invalid_input;
+ }
+}
diff --git a/cgi-bin/mat.cgi b/cgi-bin/mat.cgi
index 793671a..d8845f7 100755
--- a/cgi-bin/mat.cgi
+++ b/cgi-bin/mat.cgi
@@ -14,6 +14,7 @@ my $q = new CGI::Simple;
my $id = $q->param('id');
my $action = $q->param('action');
my $storage = $q->param('storage');
+my $password = $q->param('password');
my $session = CGI::Session->new(undef, undef, {Directory =>
$Config{'session_directory'}});
@@ -50,15 +51,18 @@ sub cmd_view($)
my $db = DBI->connect($Config{'database'}, "", "",
{HandleError => \&misconfigured, AutoCommit => 1});
- my $recipe_row = $db->selectrow_arrayref("SELECT name, storage, uri FROM ".
- "recipes AS r JOIN inventory AS i ON i.recipe_id=r.id WHERE i.id=".$id.
- ";");
+ my $portion = $db->selectrow_hashref("SELECT name, storage, uri, amount, ".
+ "energy FROM recipes AS r JOIN inventory AS i ON i.recipe_id=r.id ".
+ "WHERE i.id=".$id.";");
- print $id, "<br />", $$recipe_row[0], "<br />", $$recipe_row[1], "<br />";
- if(substr($$recipe_row[2], 0, 4) eq "http") {
- print '<a href="'.$$recipe_row[2].'">'.$$recipe_row[2].'</a>', "<br />";
+ print $id, "<br />", $portion->{name}, "<br />\n";
+ print $portion->{storage}, "<br />\n";
+ print $portion->{amount} ? $portion->{amount}." g<br />" : "", "<br />\n";
+ print $portion->{energy} ? $portion->{energy}." kJ<br />" : "", "<br />\n";
+ if(substr($portion->{uri}, 0, 4) eq "http") {
+ print '<a href="'.$portion->{uri}.'">'.$portion->{uri}.'</a>', "<br />\n";
} else {
- print $$recipe_row[2], "<br />";
+ print $portion->{uri}, "<br />\n";
}
if ($session->param('authenticated') eq "yes") {
print "<font size=20>\n";
@@ -66,7 +70,7 @@ sub cmd_view($)
print " <a href=".$Config{'label_id_prefix'}."$id/relocate/$store>".
"$store</a> \n";
}
- print "</font>";
+ print "</font>\n";
}
}
@@ -82,29 +86,51 @@ sub cmd_relocate($$)
cmd_view($id);
}
+sub cmd_login($)
+{
+ my ( $password ) = @_;
+
+ if ( $password and ($password eq $Config{'password'} )) {
+ $session->param('authenticated', "yes");
+ print "welcome.";
+ } else {
+ print "<form>\n";
+ print "<input name=password>\n";
+ print "<input type=submit>\n";
+ print "</form>\n";
+ }
+}
+
### MAIN PROGRAM ##############################################################
misconfigured unless ($Config{'database'});
misconfigured unless $session;
-invalid_input unless ($id and $action);
+invalid_input unless $action;
+
+if ($action eq "view") {
+ invalid_input unless ($id and $id =~ m/^[0-9]+$/);
+} elsif ($action eq "relocate") {
+ invalid_input unless (($id =~ m/^[0-9]+$/) and ($storage =~ /^[a-z0-9]*$/));
+} elsif ($action eq "login") {
+} else {
+ invalid_input;
+}
-invalid_input unless (($id =~ m/^[0-9]+$/) and ($action =~ m/^view|relocate$/) and
- ($storage =~ /^[a-z0-9]*$/));
send_cookie;
for ($action) {
if (/^view$/) {
cmd_view($id);
- }
- elsif (/^relocate$/) {
+ } elsif (/^relocate$/) {
if ($session->param('authenticated') eq "yes") {
$session->expire("5y");
cmd_relocate($id, $storage);
} else {
unauthorized();
}
- }
- else {
+ } elsif (/^login$/) {
+ cmd_login($password);
+ } else {
invalid_input;
}
}
diff --git a/cgi-bin/mat.cgi-package b/cgi-bin/mat.cgi-package
new file mode 100755
index 0000000..15ad893
--- /dev/null
+++ b/cgi-bin/mat.cgi-package
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+
+package cgi::mat;
+
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(misconfigured);
+
+use strict;
+use warnings;
+
+use Config::Simple;
+use CGI::Simple;
+use CGI::Session;
+use DBI;
+
+tie my %Config, "Config::Simple", '/etc/mat.conf';
+
+my $q = new CGI::Simple;
+my $id = $q->param('id');
+my $action = $q->param('action');
+my $storage = $q->param('storage');
+my $session = CGI::Session->new(undef, undef, {Directory =>
+ $Config{'session_directory'}});
+
+sub misconfigured
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "This system is misconfigured.\n";
+ exit 1;
+}
+
+sub invalid_input()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Invalid input.\n";
+ exit 1;
+}
+
+sub unauthorized()
+{
+ print "Content-Type: text/plain; charset=utf-8\n\r\n\r";
+ print "Not authorized!\n";
+ exit 1;
+}
+
+sub send_cookie()
+{
+ print $session->header(-type => 'text/html', -charset => 'utf8');
+}
+
+sub cmd_view($)
+{
+ my ( $id ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ my $recipe_row = $db->selectrow_arrayref("SELECT name, storage, uri, ".
+ "amount, energy FROM recipes AS r JOIN inventory AS i ".
+ "ON i.recipe_id=r.id WHERE i.id=".$id.";");
+
+ print $id, "<br />", $$recipe_row[0], "<br />", $$recipe_row[1], "<br />";
+ print $$recipe_row[3] ? $$recipe_row[3]." g<br />" : "", "<br />";
+ print $$recipe_row[4] ? $$recipe_row[4]." kJ<br />" : "", "<br />";
+ if(substr($$recipe_row[2], 0, 4) eq "http") {
+ print '<a href="'.$$recipe_row[2].'">'.$$recipe_row[2].'</a>', "<br />";
+ } else {
+ print $$recipe_row[2], "<br />";
+ }
+ if ($session->param('authenticated') eq "yes") {
+ print "<font size=20>\n";
+ for my $store ( split(" ", $Config{'relocate_stores'}) ) {
+ print " <a href=".$Config{'label_id_prefix'}."$id/relocate/$store>".
+ "$store</a> \n";
+ }
+ print "</font>";
+ }
+}
+
+sub cmd_relocate($$)
+{
+ my ( $id, $storage ) = @_;
+
+ my $db = DBI->connect($Config{'database'}, "", "",
+ {HandleError => \&misconfigured, AutoCommit => 1});
+
+ $db->do('UPDATE inventory SET storage="'.$storage.'" WHERE id='.$id);
+
+ cmd_view($id);
+}
+
+### MAIN PROGRAM ##############################################################
+
+sub run
+{
+ misconfigured unless ($Config{'database'});
+ misconfigured unless $session;
+ invalid_input unless ($id and $action);
+
+ invalid_input unless (($id =~ m/^[0-9]+$/) and ($action =~ m/^view|relocate$/) and
+ ($storage =~ /^[a-z0-9]*$/));
+ send_cookie;
+
+ for ($action) {
+ if (/^view$/) {
+ cmd_view($id);
+ }
+ elsif (/^relocate$/) {
+ if ($session->param('authenticated') eq "yes") {
+ $session->expire("5y");
+ cmd_relocate($id, $storage);
+ } else {
+ unauthorized();
+ }
+ }
+ else {
+ invalid_input;
+ }
+ }
+}
+
+__PACKAGE__->run( @ARGV ) unless caller();
+
+__END__
diff --git a/cgi-bin/relocatehook.sh b/cgi-bin/relocatehook.sh
new file mode 100755
index 0000000..19cc279
--- /dev/null
+++ b/cgi-bin/relocatehook.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+date "+%s|%Y%m%d %H%M|$1|$2|$3|$4|$5|$6" >> /var/tmp/relocatelogg.txt
diff --git a/mat b/mat
index 707a675..2ec9415 100755
--- a/mat
+++ b/mat
@@ -14,6 +14,7 @@ use Text::Iconv;
use utf8;
binmode(STDOUT, 'utf8:');
+# FIXME die on non-existant config
tie my %Config, "Config::Simple", '/etc/mat.conf';
#use Data::Dumper;
@@ -126,7 +127,7 @@ my @schedule = (
sub convert_to_unit {
my ( $out_unit, $id, $in_amount, $in_unit ) = @_;
my %out_amount;
- my %convert;
+ my %convert; # volume [l], weight [g], piece [st]
# SELECT DISTINCT unit FROM contents;
# msk, krm, dl, tsk, cl, l, ml, nypa
@@ -139,6 +140,10 @@ sub convert_to_unit {
$convert{'volume'} = $in_amount;
} elsif ($in_unit eq "dl") {
$convert{'volume'} = $in_amount / 10;
+ } elsif ($in_unit eq "cl") {
+ $convert{'volume'} = $in_amount / 100;
+ } elsif ($in_unit eq "ml") {
+ $convert{'volume'} = $in_amount / 1000;
} elsif ($in_unit eq "msk") {
$convert{'volume'} = $in_amount * 0.015;
} elsif ($in_unit eq "tsk") {
@@ -164,17 +169,18 @@ sub convert_to_unit {
if ( $convert{'volume'} ) {
$volume = 0.001 * $convert{'volume'}; # m³
if ($ingredient->{density}) {
- $out_amount{'weight'} = 1000 * $density * $volume; # g
+ $out_amount{'weight'} = $density * $volume * 1000; # g
}
} elsif ( $convert{'weight'} ) {
- $weight = $convert{'weight'} / 1000; # kg
+ $weight = $convert{'weight'}; # g
+ $out_amount{'weight'} = $weight;
if ($ingredient->{'piece_weight'}) {
$piece_weight = $ingredient->{'piece_weight'}; # g/piece
$out_amount{'piece'} = $convert{'weight'} /
$ingredient->{'piece_weight'}; # piece
}
if ($ingredient->{density}) {
- $out_amount{'volume'} = 1000 * $weight / $density; # g
+ $out_amount{'volume'} = $weight / $density; # g
}
} elsif ( $convert{'piece'} ) {
if ($ingredient->{'piece_weight'}) {
@@ -184,6 +190,12 @@ sub convert_to_unit {
}
if ($out_unit eq "g") {
+ if($out_amount{'weight'}) {
+ return $out_amount{'weight'};
+ } else {
+ return
+ }
+ } elsif ($out_unit eq "kg") {
return $out_amount{'weight'};
} elsif ($out_unit eq "st") {
return $out_amount{'piece'};
@@ -297,6 +309,7 @@ sub cmd_inventory {
$sql .= " WHERE storage='$storage'" if ( $storage );
$sql .= " GROUP BY storage, preparation_date, recipe_id";
+ $total{'all'} = 0;
my $all = $db->selectall_arrayref($sql);
foreach my $row (@$all) {
$total{'all'} += @$row[1];
@@ -901,7 +914,7 @@ sub cmd_shoppinglist {
my $servings_col = $db->selectcol_arrayref("SELECT servings FROM recipes WHERE id=".$recipe.";");
my $servings;
- if(defined(@$servings_col[0])) {
+ if(defined(@$servings_col[0]) && (@$servings_col[0]) gt 0) {
$servings = @$servings_col[0];
} else {
$servings = 1;
@@ -924,7 +937,7 @@ sub cmd_shoppinglist {
for my $content ( keys(%$contents)) {
my %shop;
# print %$contents, "\n";
- my $ingredientcol = $db->selectcol_arrayref("SELECT name FROM ingredients WHERE id=".$content.";");
+ my $ingredientrow = $db->selectrow_arrayref("SELECT name, primary_unit FROM ingredients WHERE id=".$content.";");
# print $content, " ", @$ingredientcol[0], "\n";
# print $$contents{$content}{unit}, $content, " ", @$ingredientcol[0], "\n";
# print keys(%$contents), "\n";
@@ -932,12 +945,34 @@ sub cmd_shoppinglist {
$shop{quantity} = $$contents{$content}{quantity};
# $shop{shop_position} =
$shop{unit} = $$contents{$content}{unit};
- $shop{ingredient} = @$ingredientcol[0];
+ $shop{ingredient} = @$ingredientrow[0];
+ $shop{primary_unit} = @$ingredientrow[1];
$shop{recipe}[0] = $recipe;
push @shop_ingredients, \%shop;
}
}
- my @sorted_ingredients = sort { $a->{ingredient} cmp $b->{ingredient} } @shop_ingredients;
+
+
+ my @converted_ingredients;
+ for my $ingredient ( @shop_ingredients )
+ {
+ my $convert_unit;
+ my $convert_result;
+
+ $convert_unit = "g";
+
+ if ($convert_unit) {
+ $convert_result = convert_to_unit($convert_unit, $ingredient->{'id'},
+ $ingredient->{'quantity'}, $ingredient->{'unit'});
+ if ( $convert_result ) {
+ $ingredient->{'unit'} = $convert_unit;
+ $ingredient->{'quantity'} = $convert_result;
+ }
+ }
+ push @converted_ingredients, $ingredient;
+ }
+
+ my @sorted_ingredients = sort { $a->{ingredient} cmp $b->{ingredient} } @converted_ingredients;
my @squeezed_ingredients;
for my $squeeze ( @sorted_ingredients )
{
@@ -948,10 +983,21 @@ sub cmd_shoppinglist {
push @squeezed_ingredients, $squeeze;
}
}
-# for my $shop ( @sorted_ingredients )
for my $shop ( @squeezed_ingredients )
{
- printf "%4s %-8s %-40s", $shop->{quantity}, $shop->{unit}, $shop->{ingredient};
+ my $convert_result;
+ if ($shop->{'primary_unit'}) {
+ $convert_result = convert_to_unit($shop->{'primary_unit'}, $shop->{'id'},
+ $shop->{'quantity'}, $shop->{'unit'});
+ }
+
+ printf "%4s %-8s ", $shop->{quantity}, $shop->{unit};
+ if ($convert_result) {
+ printf "%4.4s %-8s ", $convert_result, $shop->{'primary_unit'};
+ } else {
+ printf "%4.4s %-8s ", "", "";
+ }
+ printf "%-40s", $shop->{ingredient};
for ( @{$shop->{recipe}} ) {
print get_recipe_name($_), ", ";
}
diff --git a/sheetprint b/sheetprint
index f0052f5..701b9b5 100755
--- a/sheetprint
+++ b/sheetprint
@@ -26,37 +26,39 @@ my $white = $a4->colorAllocate(255,255,255);
my $black = $a4->colorAllocate(0,0,0);
$a4->fill(0, 0, $white);
-# Draw a cross
-$a4->line(0, 0, $a4->width(), $a4->height, $black);
-$a4->line($a4->width(), 0, 0, $a4->height, $black);
+sub draw_rulers()
+{
+ # Draw a cross
+ $a4->line(0, 0, $a4->width(), $a4->height, $black);
+ $a4->line($a4->width(), 0, 0, $a4->height, $black);
-# Draw some rulers
-for ( my $i = 1; $i < 297; $i++) {
- if ( $i % 10 == 0 ) {
- $a4->line(0, mm2dots($i), 20, mm2dots($i), $black);
- $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 20, mm2dots($i), $black);
- } elsif ( $i % 5 == 0 ) {
- $a4->line(0, mm2dots($i), 15, mm2dots($i), $black);
- $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 15, mm2dots($i), $black);
- } else {
- $a4->line(0, mm2dots($i), 10, mm2dots($i), $black);
- $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 10, mm2dots($i), $black);
+ for ( my $i = 1; $i < 297; $i++) {
+ if ( $i % 10 == 0 ) {
+ $a4->line(0, mm2dots($i), 20, mm2dots($i), $black);
+ $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 20, mm2dots($i), $black);
+ } elsif ( $i % 5 == 0 ) {
+ $a4->line(0, mm2dots($i), 15, mm2dots($i), $black);
+ $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 15, mm2dots($i), $black);
+ } else {
+ $a4->line(0, mm2dots($i), 10, mm2dots($i), $black);
+ $a4->line(mm2dots(105), mm2dots($i), mm2dots(105) + 10, mm2dots($i), $black);
+ }
}
-}
-for ( my $i = 1; $i < 210; $i++) {
- if ( $i % 10 == 0 ) {
- $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 20, $black);
- $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 20, $black);
- } elsif ( $i % 5 == 0 ) {
- $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 15, $black);
- $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 15, $black);
- } else {
- $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 10, $black);
- $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 10, $black);
+ for ( my $i = 1; $i < 210; $i++) {
+ if ( $i % 10 == 0 ) {
+ $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 20, $black);
+ $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 20, $black);
+ } elsif ( $i % 5 == 0 ) {
+ $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 15, $black);
+ $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 15, $black);
+ } else {
+ $a4->line(mm2dots($i), mm2dots(297), mm2dots($i), mm2dots(297) - 10, $black);
+ $a4->line(mm2dots($i), mm2dots(149), mm2dots($i), mm2dots(149) - 10, $black);
+ }
}
}
-my $skip = 2;
+my $skip = 0;
my $x = mm2dots(25);
my $y = mm2dots(32) + $skip * mm2dots(25);