Solved

Perl error with join

Posted on 2011-09-13
2
228 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Port 80 requests 16 95
Is it possible to get a piece of info in a line from a big text file with perl? 7 69
Question about @INC variable in perl 1 58
Perl string filter 5 78
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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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