# File: match0.pl # Title: Take first group of n chars from a string ( # $s =~ m/(.{$n})/; # means match(m) first n chars .{$n} - that is repeat . n times # () means set result in variable $1 # Author: Mihaela Malita # Input string? bioinformatics # Input integer? 3 # Take first n chars from the string: # bio $yesorno = 'y'; while ($yesorno eq 'y') { print "Input string? "; $s = ; chop($s); print "Input integer? "; $n = ; chop($n); print("Take first n chars from the string:\n"); $s =~ m/(.{$n})/; print $1; print("\nContinue(y/n)? "); $yesorno = ; chop($yesorno); } print "Bye"; exit;