Solved

Need help with this Perl Script ( missing Array )

Posted on 2014-03-31
6
236 Views
Last Modified: 2014-04-03
Hello , I have this script that when I run it against this zone file I get this error


==> ms-fix-ad-rrs.pl CMS.LAN.db -v Internal

Can't use an undefined value as an ARRAY reference at /local/bin/ms-fix-ad-rrs.pl line 110, <> line 1709.

Can anyone have a look to see whats the issue?
ms-fix-ad-rrs-.txt
CMS.LAN.txt
0
Comment
Question by:richsark
  • 4
  • 2
6 Comments
 
LVL 28

Expert Comment

by:FishMonger
ID: 39968371
The error message is telling you that $rrs{$zone} is undefined.

More specifically, CMS.LAN (which is what $zone resolves to) is not a key of the %rrs hash.
0
 
LVL 1

Author Comment

by:richsark
ID: 39968415
Ok. So what can I do to make this work ?
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39969281
What is your expected output?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 28

Accepted Solution

by:
FishMonger earned 500 total points
ID: 39969334
Perl is case sensitive, so a hash key of 'CMS.LAN' is not the same key as 'cms.lan'.  Your %rrs hash does have a 'cms.lan' key.

So, maybe all you need to do is lowercase $zone either when it's being assigned or when you use it in the join statement on line 110.

my $dclist = join ( ", " , @{ $rrs{lc $zone} } );

Open in new window

0
 
LVL 1

Author Comment

by:richsark
ID: 39970181
Ok. Just want it to run without an array issue. Can that me done ? Or have the script compensate for capital letters ?
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39970213
My #39969334 post shows how to compensate for capital letters in $zone.

However, since you haven't explained what your output expectation is, I can't say if there are any other adjustments that will be need to be applied.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now