Skip to content
Advertisement

Tag: perl

open command in perl

I am try to use open command in perl. But getting and error as follows. Command open(IN_TRIALS, ‘<‘, “F:/2010_nist_sre_test_set/data/eval/keys/coreext-coreext.trialkey.csv”) or die “cannot open trials list”; Error cannot open trials. how to fix this? Answer First, make sure the file exists in the location: F:/2010_nist_sre_test_set/data/eval/keys/coreext-coreext.trialkey.csv. Use a modern way to read a file, using a lexical filehandle: If you’re reading a

Recursively change file name in folder and subfolders without changing file path

I have files in a format like 639486572_016b0f3d-9ec3-4ad1-84ae-c98b68390322.wav. The files reside in a folder and sub-folder format that resembles a date. ./2019/05/31/639486572_016b0f3d-9ec3-4ad1-84ae-c98b68390322.wav. The goal is to remove everything before and including the _. Which im able to do with rename -v ‘s/$.+_//’ But when I try to couple this with find it seems to rename all the files found in

need perl to die when implicit open fails

I’m trying to migrate a sed script to a perl one-liner, because perl supports non-greedy regexp. I’ve taken advices from Non greedy (reluctant) regex matching in sed? and Why is my Perl in-place script exiting with a zero exit code even though it’s failing? I need my oneliner to exit with non-zero status if it failed to open the file.

How to extract multiple *.tgz files to multiple directories using PERL?

I am learning PERL lang. I have forced (and little confused) the issue with extracting *.tgz files. My point which I want to achieve is to extract multiple *.tgz files to multiple folders. So the structure comes: I want to extract these files to directories: Can someone help me with this, or give some hints how to achieve it? Answer

Redirect STDERR to a file from Perl in Linux

So, I was trying to catch the error messages from running some basic Linux command, using Perl. For example, I try to catch the STDERR when running the ldd command: But, even if the output of the ldd command does contain error messages such as ldd: warning: you do not have execution permission for, it won’t print them in to

Replacement of PS1 variable in .bashrc using Sed or Perl

I am trying to replace a line in file and am running in to issues. Original File: Command I am running: Error message: I also tried sed: Result with Sed: Expected Result File: End Result This doesn’t have much to do with the question except to show folks what the PS1 will look like when working properly Answer For sed,

Advertisement