problems reading a file

I am working on a live content-update tool which uses text files to store data for publication.

In several places, I generate these files by using the contents of a variable as part of the generated file's name.

When I try to use the same method to read the file, I receive no error message, but it appears that no information is passed (the contents of the file are not read in, or the file is not found).

More than likely this is something very obvious, but I'm fairly new to Perl, so I'm missing it completely.

I create the files with:

    open (INFO, ">c:/mydir/01$Config{'nmonth'}$Config{'nyear'}_1e.txt");
    print INFO "(content not available in english)\n";    
    close(INFO);

nmonth and nyear are variables passed by a previous form.

I then try to read it with:

  open (READINFO, "c:/mydir/$Config{'numero'}_1e.txt");
  $content1e = <READINFO>;
  close (READINFO);

where numero is the appropriate value (ex:01012003) - I have confirmed that this value is passed properly, but it simply isn't working.
TIA for any help

AaarghAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ddaCommented:
Could you post your code example here? The places where you write and read the file...
0
ventolinCommented:
yes... please post your code.
0
AaarghAuthor Commented:
Edited text of question.
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

ventolinCommented:
$content1e = <READINFO>;

will only read in one line of the file.

you'll need to do this:

# undef input record seperator so we can get whole file
undef $/;

# slurp template into $template
$content1e = <READINFO>;

# set input record seperator back to default newline character
$/ = "\n";

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
#also, check the success of the open:
open (READINFO, "c:/mydir/$Config{'numero'}_1e.txt") or die "can't open c:/mydir/$Config{'numero'}_1e.txt because $!";
0
AaarghAuthor Commented:
Well this wasn't really the solution to my original problem, which was a bug on my part (newline char. being included in the value, and passed on to the filename).

However, I would have run into it immediately after solving the bug, so it definitely helped.

ozo, I had noticed that bit of code in other posts, and was going to try it out - you comfirmed it for me, and that's how I discovered the bug.

Many thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.