Solved

Perl error with join

Posted on 2011-09-13
2
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…

733 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