function inc_field( $field, increment ) {
var val = parseInt($field.val());
val += increment;
if (val > 0) {
$field.val(val).change();
}
}
$(document).on('click', '.quantity .plus', function(e) {
inc_field ($(this).prev('input.qty'), +1);
inc_field ($(this).next('input.qty'), -1);
});
$(document).on('click', '.quantity .minus', function(e) {
inc_field ($(this).prev('input.qty'), -1);
inc_field ($(this).next('input.qty'), +1);
});
use Modern::Perl;
use Readonly;
use File::Slurper qw( read_text write_text );
Readonly my $STR => "45788-4rbf-77458-ik-90-98";
Readonly my $OFFSET => 10;
Readonly my $INFILE => "/home/in.txt";
Readonly my $OUTFILE => "/home/out.txt";
my @insertions = split( m/\n/, read_text(INFILE) );
my $result = '';
for my $insertion ( @insertions ) {
$result .= substr($STR, 0, $OFFSET). $insertion. substr($STR, $OFFSET). "\n";
}
# а можно так
my $result = join("\n", map {
substr($STR, 0, $OFFSET). $_. substr($STR, $OFFSET)
} @insertions;
write_text(OUTFILE, $result);