How to allow input from terminal to contain spaces in perl -


i trying create program allows name entered user , prints name , whether or not found in column of file , how many times found. have far allows user enter name since names have spaces returns name not found because can't detect exact string. here's have:

#!/usr/bin/perl use warnings; use strict;  %author; $input; $firstauthor; open ($input, "<", 'gwas_catalog_v1.0-downloaded_2015-07-21.tsv') || die(); while (<$input>) {     @r = split (/\t/);     $firstauthor = $r[2];     $author{"$firstauthor"}++; }  print "\nenter name: "; $usrin = <stdin>; chomp $usrin; if (exists $author{"$usrin"}) {     print "$usrin seen $author{"$usrin"} time(s).\n\n"; } if (!exists $author{"$usrin"}) {     print "$usrin isn't author of contained in file.\n\n"; } 

the problem solved adding quotation marks surround $usrin inside $author{"$usrin"}.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -