#!/your/perl/here use strict; use warnings; my @precio; open PR,'medicines.txt'; @precio=; close PR; chomp(@precio); print("\n** MEDICINE PRICES BY DOSES PER MONTH **\n\n"); my $acumes; foreach my $li (@precio) { next if ($li=~/^[_#\W]/); my ($med,$uni,$pre)=split(/\t/,$li); my $dos; print('Daily dose of ',$med,'? =>'); $dos=<>; $dos=~s/[^\d\.]//g; my $tot=sprintf("%6.2f",$pre/$uni*$dos*31); print(' Costs.................'," \t\t\t$tot \$\/month.\n"); $acumes+=$tot; } my $lit="\nTotal to spend with medicines every month: $acumes \$\n"; print('=' x length($lit),$lit, '=' x length($lit),"\n");