topher-j
topher-j

Reputation: 2281

Notepad++ and Perl, End STDIN. Ctrl+Z in the console not working

** Title original said Ctrl+D

I have perl set up to execute and run in Notepad++.

Here's the Execute command:

NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
C:\strawberry\perl\bin\perl "$(FILE_NAME)"

I'm trying to work through an example that reads in a list via STDIN, but I can't end the input, because CTRL+Z doesn't appear to work in Notepad++'s console. I press it and nothing happens, it doesn't continue the program, or end. I eventually have to terminate.

Here's the code I'm running

#!perl

use warnings;
use strict;

my @list_of_strings = <STDIN>;

@list_of_strings = reverse @list_of_strings;

print @list_of_strings;

Upvotes: 0

Views: 1070

Answers (2)

ysth
ysth

Reputation: 98398

http://sourceforge.net/p/notepad-plus/discussion/482781/thread/db271da3/:

While your program is executing press F6 (again), in string "Exit message" type EOF's ASCII code < alt>+<26> and press "Send" button.

I'm not completely sure what that means, and don't have windows to try it, but that's the first hit from a google search on "notepad++ console end of file".

Upvotes: 2

TLP
TLP

Reputation: 67910

In Windows cmd shell I use Ctrl-Z for end of file, while reading from STDIN, so it sounds likely that that would work for you too. Assuming of course that you have some prompt to type into when executing through Notepad++.

Otherwise, you could use the diamond operator instead, which would allow you to insert debug input through a file instead. The diamond operator uses both STDIN and file content, depending on whether @ARGV is empty or not, and the functionality is identical, which is ideal for debugging purposes.

Your script could just be

print reverse <>;

Which will allow you to apply it to files as well as STDIN. I.e.:

C:\strawberry\perl\bin\perl "$(FILE_NAME)" "$(INPUT_FILE)"

Or you could patch your program to add your test input file directly:

@ARGV = "input.txt";

This will work exactly as if you gave the file name as argument to the program.

Upvotes: 1

Related Questions