http://www.perlmonks.org?node_id=1006174


in reply to subroutine help

A few things to help you out:

#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use Data::Printer; print "Enter a chemical formula: "; chomp( my $form = <> ); my %weight = $form =~ /[A-Z][a-z]?|\d+/ig; p %weight; __END__ Enter a chemical formula: C12H22O11 { C 12, H 22, O 11 }

Replies are listed 'Best First'.
Re^2: subroutine help
by perlguru22 (Acolyte) on Nov 29, 2012 at 08:04 UTC
    Sorry I think my kindle modified it and removed the ;
      Oh, those pesky kindles! (I wonder whatever happened to the 'dog ate my semi-colon' excuse?)