Questions tagged [perl-io]

Input/Output in Perl

Perl Input/Output modules and methods.

29 questions
1
vote
1 answer

Reading one line from a Unix domain socket

I have a server running socat with this command: socat ABSTRACT-LISTEN:test123 PIPE I can open a socket to this server, send one line, read one line, and print it with this code: #!/usr/bin/perl use strict; use warnings; use IO::Socket::UNIX; my…
robbie
  • 1,219
  • 1
  • 11
  • 25
1
vote
2 answers

Perl's IO::File and use open qw(:utf8)

IO::File->open() doesn't seem to respect use open() in the following program, which is odd to me and seems to be against the documentation. Or maybe I'm doing it wrong. Rewriting my code to not use IO::File shouldn't be difficult. I expect the…
Michael
  • 8,446
  • 4
  • 26
  • 36
0
votes
2 answers

how do I link PerlIO Perl package without "installing it"

I'm trying to add the PerlIO::eol package as part of my project without installing it, this way all dependencies can be packaged with my script without having to reinstall them on each machine. How can I do it for PerlIO::eol I don't understand the…
user391986
  • 29,536
  • 39
  • 126
  • 205
0
votes
1 answer

How to test if PerlIO::fse works on file test operators?

#!/usr/local/bin/perl use warnings; use strict; use utf8; use Encode qw(encode); my $dir = '/data/Delibes, Léo'; if ( -d $dir ) { print "OK\n"; } if ( -d encode 'utf8', $dir ) { print "OK\n"; } This prints 2 times OK; I suppose this is…
sid_com
  • 24,137
  • 26
  • 96
  • 187
0
votes
1 answer

Perl Config::Tiny->read() doesn't handle CRLF

I am using Perl with Ubuntu under Windows 10. I want to use the Perl Config::Tiny module to read filenames and other configuration data. When I read a config file created under Windows within Linux, it leaves the Carriage Returns at the end of the…
Wes
  • 423
  • 3
  • 12
0
votes
2 answers

trying to open a file located in D drive on command prompt using perl

I am trying to learn file handling in Perl, I want to open a .txt file located in D: drive on the terminal on Windows in read mode, so the code I am using is as: open(DATA, "
0
votes
1 answer

Determine if perl scalar originally had one backslash or two

I have data that I obtain from a network service. It is valid for data to have a \\ in it. Also it is valid for data to have a single \ in it. Consider the following valid data inputs to my perl program. I'm not sure how I determine which data…
mikew
  • 912
  • 2
  • 11
  • 22
0
votes
1 answer

How do I access environment variables correctly in Perl?

$ cat flaglist.log flag1 flag2 flag3 flag4 $ Perl code my $infile = "flaglist.log"; open my $fpi, '<', $infile or die "$!"; while (<$fpi>) { chomp; if ($ENV{$_}) { # something wrong here func($_); } else { …
Lazer
  • 90,700
  • 113
  • 281
  • 364
0
votes
4 answers

Need to print the last occurrence of a string in Perl

I have a script in Perl that searches for an error that is in a config file, but it prints out any occurrence of the error. I need to match what is in the config file and print out only the last time the error occurred. Any ideas? Wow...I was not…
Patrick
  • 1
  • 1
  • 1
0
votes
4 answers

Why does this program not find the word 'error' in my text file?

open(LOG,"logfile.txt") or die "Unable to open $logfile:$!"; print "\n"; while(<$LOG>){ print if /\berror\b/i; } close(LOG);
Steve
  • 1
  • 1
0
votes
3 answers

Why do I get this syntax error in my code generating program?

I want to generate some lines of Perl code by using file handling in Perl, for example: open(FILEHANDLE, ">ex.pl") or die "cannot open file for reading: $!"; print FILEHANDLE "use LWP::UserAgent;" .... .... some code is here .... print FILEHANDLE…
Eve
  • 41
  • 1
  • 6
0
votes
2 answers

FTP + uncompress + readline

I want to extract some data from a large-ish (3+ GB, gzipped) FTP download, and do this on-the-fly, to avoid dumping then full download on my disk. To extract the desired data I need to examine the uncompressed stream line-by-line. So I'm looking…
kjo
  • 33,683
  • 52
  • 148
  • 265
0
votes
0 answers

copy all files from folders and sub folders in perl?

I want to copy the text file from all folders and sub-folders and keep it in different locations. I write the code, but it doesn't work. It is not able to recognize sub-folders. It reads the text, but not recognize is it a file or folder. …
user230391
  • 53
  • 7
-1
votes
1 answer

Program dies on umlauts in filename

I hope you can help me, I can't find the reason why my code stops. I'd be grateful for every enhancement, I have to work with Perl and I've never done it before! Also I have to work on a Windows File System. Error: Could not open file '' No such…
zhengphor
  • 3
  • 3
1
2