CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Problem with <STDIN>

 



alwayslooking20
New User

May 25, 2011, 10:18 AM

Post #1 of 2 (570 views)
Problem with <STDIN> Can't Post

I am trying to write some code to create a list of file names as such:
{$prefix}_some-stuff_{$postfix}

the code:

Code
 
#!/usr/bin/perl
print "what is the prefix";
$pre=<STDIN>;

$pre = "$pre";
for ($i=1; $i <= 2; $i++) {

$trial = $pre."00".$i;
print "$trial \n";

}

Code
 
I enter pre for $pre.
This is the output.

Code
what is the prefix: pre 
pre
001
pre
002


what is need it it to look like this:


Code
pre001 
pre002


What am I doing wring?


miller
User

May 25, 2011, 11:17 AM

Post #2 of 2 (569 views)
Re: [alwayslooking20] Problem with <STDIN> [In reply to] Can't Post

chomp your input:


Code
chomp(my $pre=<STDIN>);


- Miller

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives