Solved

Perl error with join

Posted on 2011-09-13
2
226 Views
Last Modified: 2012-05-12
I need to set a variable but from the snip I have below I get what I want but also a warning.

#! /usr/bin/perl
use warnings;

$ad=q{CN=John Doe  159657,OU=Users,OU=City-CT0077,OU=GB,OU=EAF,DC=HHH,DC=abc,DC=com};

$krb = join(q{.},$ad=~ m/dc *= *([a-z]+)/ig),qq{\n};
$krb = lc("$krb");
print "$krb\n";

This will print out what I want but with a warning:

Useless use of a constant in void context at ./krb.pl line 6.
hhh.abc.com

I can do a print such as this with no warning:
print lc join(q{.},$ad=~ m/dc *= *([a-z]+)/ig),qq{\n};

What do I need to change when not just printing this and putting what I need in a variable like above?

Thanks,

0
Comment
Question by:bt707
2 Comments
 
LVL 8

Accepted Solution

by:
pwust earned 500 total points
ID: 36528764
just leave out the newline in the composition part of $krb:
$krb = join(q{.},$ad=~ m/dc *= *([a-z]+)/ig);

Open in new window

This newline char is what perl is complaining about within the join command.
0
 

Author Closing Comment

by:bt707
ID: 36528792
I had thought the newline was the problem and tried that but still got the same error, but must of not done it right, it worked now with you line.

Thanks,
0

Featured Post

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

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

17 Experts available now in Live!

Get 1:1 Help Now