#!/usr/bin/perl use strict; use warnings; use utf8; binmode STDIN, ':encoding(UTF-8)'; print "Type some funny characters, they will be saved in text.txt\n"; chomp (my $text = ); print "\n\nYou typed: $text\n"; # open (OUT, ">:encoding(UTF-8)", "text.txt") or die "Can't open file: $!"; open (OUT, ">", "text.txt") or die "Can't open file: $!"; print OUT "$text\n"; close OUT; my ($inputfile_full, $folder, $inputfile, $inputfile_noext, $ext); do { print "\nDrag and drop the input file here and press enter.\n"; chomp ($inputfile_full = ); # strip any leading and trailing spaces and single or double quotes $inputfile_full =~ /^ *[\"\']?(.*)[\/\\]([^\"\']*)[\"\']? *$/; # $1 = everything up to last / or \, $2 = everything from there on to the end except ",' and spaces at the end $folder = $1; $inputfile = $2; $inputfile =~ /(.*)\.(.*)/; $inputfile_noext = $1; $ext = $2; # strip quotes $inputfile_full =~ s/^ *[\"\']?([^\"\']*)[\"\']? *$/$1/; print "\nThe file doesn't seem to exist\nFilename: $inputfile\nPath: $folder\n\nTry again!\n\n" unless (-e "$folder/$inputfile"); }until (-e "$folder/$inputfile"); print "\nFile (${inputfile}) found.\nPath: $folder\nPress enter to continue\n"; ;