in reply to Re: Removing non-printing (hex codes) from text files
in thread Removing non-printing (hex codes) from text files

Slowly figuring this out. I've got a full pathname in a variable that I'm trying to prepend some of the same information to. E:\triggers\...E:\triggers.

How do I just get the actual filename without all of the path information into a variable?

  • Comment on Re^2: Removing non-printing (hex codes) from text files

Replies are listed 'Best First'.
Re^3: Removing non-printing (hex codes) from text files
by toolic (Bishop) on Feb 06, 2014 at 18:14 UTC

      Finally got it working. Thanks all!!

      use strict; use warnings; use File::Basename; # Declare package names my $work_file; my $out_file; my @files = <E:\\triggers\\1_MERGE_3326\\tests\\*.hl7>; #$work_file = pop; # If work_file comes from command line, uncomment my $inPath = "E:\\triggers\\1_MERGE_3326\\pass"; my $outPath = "E:\\triggers\\1_MERGE_3326\\converted"; foreach $work_file (@files) { print "$work_file\n"; open (WORK, "<$work_file") or die "Couldn't open $work_file."; # Open +the working file my $outFile = basename($work_file); print "$outFile\n"; open (OUT, ">$outPath\\$outFile") or die "Couldn't open $outPath\\$out +File."; # open an output file while (<WORK>) { chomp; $_ =~ tr/\000-\011\013\014\016-\037//d; print OUT map {"$_\n"} ($_); } # end while close WORK; close $work_file; } # end foreac