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…
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…
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…
#!/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…
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…
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, "
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…
$ 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 {
…
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…
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…
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…
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. …
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…