Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl error with join

Posted on 2011-09-13
2
Medium Priority
?
235 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 2000 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

Independent Software Vendors: 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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

721 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