I'm trying to make a program which has a menu doing two things:
(1) Read data from an input file
(2) Write certain pieces of the most recently read data to an output file
(3) Exit
The user needs to be able to keep repeating choice 1 for as long as he/she wants, and then use choice 2 to write...
I have a list of files named 'test1.txt', 'test2.txt', 'test3.txt'... etc to 'test35.txt'. I want perl to open test1, perform some operation, then do the same to test2, and so on.
This is my code fragment:
...
...
for ($a = 1; $a <=35; $a++) {
my $input = "test" . "$a" . ".txt";
open...
No, this is not school/course work. I'm learning perl on my own, and I couldn't figure out a way to do this. I'm sorry about leaving the other threads hanging - I'll properly thank the people who help me and tell them that I solved my problem in the future.
How would I test whether a number is divisible by a certain combination of numbers (say 2 and 3?)
The number 4 fits, because it divides by 2, and then by 2.
The number 12 fits, because it divides by 3, then by 2 twice.
The number 15 doesn't fit because after dividing by 3, 5 is not divisible by...
I have a question on how to print to different files, say, out.1.txt, out.2.txt, etc.
If i have
open (OUTP, ">out.txt")
print OUTP "$_";
in some sort of loop, then out.txt only stores the information in the last iteration of the loop because all the other attempts were overwritten. What I'm...
When I try to use your code, I seem to get this message:
Modification of non-creatable array value attempted, subscript -1 at testscript.pl line 15, INPUT line 1.
Why is this?
The segment of code in question is:
Let's say input.txt consists of the lines:
file_name_1.txt
file_name_2.txt
file_name_3.txt
What I want the script to do is open each of these files, and invoke a certain subroutine with each one. Would that work?
Hi, I'm a newbie to perl. I just started learning it a few days ago. The short script that I made is:
The file that it takes as input, sample.txt is something like as follows:
What I want the script to do is to display only the numbers containing "KEYWORD" so for this case, I just want it to...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.