- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Perl processing issue Interesting name charact...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 02:42 AM
11-13-2005 02:42 AM
------begin code snippet-----
foreach $L1 (A..z) {
foreach $L2 (A..z) {
$L = $L1.$L2 ;
-----end code snippet---------
#
#
# $L is the first two characters of someones name.
What happens after this is a ldapsearch for a list of names. Basically an ldap search requeset is built based on the first two letters of the last name.
Question at hand is what happens if someone's name has a non-standard character in it what happens?
Lets say the users last name is:
D'gostino?
I'm betting I know the answer to this one, which is that D'gostino up there never gets processed.
Bunny for confirmation of this.
If there is a quick modification of the first two lines of code that will include those with aprostrophe's in the name please re-write and post.
Bunny for this after I test the code and nothing else breaks.
This seems like a job for procura or A. Clay.
Regards,
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 03:58 AM
11-13-2005 03:58 AM
SolutionOf course, the loop shown will never produce $L with a "non-standard" character such as an apostrophe. You could amend the isolated snippet to something covering a larger set like this:
foreach $L1 (A..Z) {
foreach $L2 (a..z, qw(')) {
$L = $L1.$L2 ;
}
}
This generates combinations that begin with an uppercase letter (only) and follow that with an uppercase, a lowercase, or an apostrophe, covering names like: "DeBusk", "D'gostino", "Protter", etc.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 04:01 AM
11-13-2005 04:01 AM
Re: Perl processing issue Interesting name characters.
Looks like you got both bunnies with one post.
I'll test it in the morning(Israel time).
Thanks for your help.
Bunnie@JRF
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 04:06 AM
11-13-2005 04:06 AM
Re: Perl processing issue Interesting name characters.
Global symbol "$L1" requires explicit package name at xx.pl line 6.
Global symbol "$L2" requires explicit package name at xx.pl line 7.
Global symbol "$L" requires explicit package name at xx.pl line 8.
Global symbol "$L1" requires explicit package name at xx.pl line 8.
Global symbol "$L2" requires explicit package name at xx.pl line 8.
Bareword "A" not allowed while "strict subs" in use at xx.pl line 6.
Bareword "z" not allowed while "strict subs" in use at xx.pl line 6.
Bareword "A" not allowed while "strict subs" in use at xx.pl line 7.
Bareword "z" not allowed while "strict subs" in use at xx.pl line 7.
Execution of xx.pl aborted due to compilation errors.
No lexicals, barewords and ranges that include characters that are not supposed to be included ('A' .. 'z' includes '[', '\', ']', '^', '_', and '`'), and it's not portable to EBCDIC
Now let's start with rewriting it to proper Perl:
--8<---
#!pro/bin/perl
use strict;
use warnings;
foreach my $L1 ('A' .. 'z') {
foreach my $L2 ('A' .. 'z') {
my $L = $L1.$L2;
}
}
-->8---
Code rewrite:
foreach my $l1 ('A' .. 'Z', 'a' .. 'z')Â {
foreach my $l2 (map { chr } 32 .. 127) {
my $L = "$l1$l2";
}
}
I do not have enough LDAP knowledge to verify the LDAP questions.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 04:10 AM
11-13-2005 04:10 AM
Re: Perl processing issue Interesting name characters.
foreach $L1 (A..z) {
foreach $L2 (32..126) {
$L = $L1.chr($L2) ;
}
}
Regards LiPEnS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 04:22 AM
11-13-2005 04:22 AM
Re: Perl processing issue Interesting name characters.
Merijn, I don't quite understand your post and it looks partially distorted by itrc.
I guess another good question is besides apostrophe's are there any other strange characters I have to look for?
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 05:45 AM
11-13-2005 05:45 AM
Re: Perl processing issue Interesting name characters.
foreach my $l2 (map { chr } 32 .. 127) {
my $L = "$l1$l2";
}
}
JRF was a faster typer.
1. I think you should *ALWAYS* program/script strict-safe: use lexicals, use strict, use -w or warnings
2. The range bounds should be quoted
3. The range should be explicit: 'A'..'z' IS NOT the same as 'A'..'Z','a'..'z'
4. The inner foreach ranges from space (character 32 or 0x20) to DEL (character 127 or 0x7F)
$l1.$l2 is exaclty the same as $l1.$l2
As a side note, what do you do with diacriticals?
à (A-acute), à (A-ring), Š(l-stroke), ë (e-diaeresis), etc, etc
They usually fall outside of ASCII, so you will need to know how your LDAP source stores it in order to get it. Unicode (UTF-8, UTF-16, ...), iso-8859-??, iso-10646-1, ...
FWIW Names *starting* with a character outside of the range 'A'..'Z','a'..'z' also drop out of my stats, because HP does not have them in the index pages :)
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 06:04 AM
11-13-2005 06:04 AM
Re: Perl processing issue Interesting name characters.
Merijn wrote that "JRF was a faster typer" and perhaps that's true, *BUT* Merijn's pointers really complete the lesson, as they always do.
*ALWAYS* using the 'strict' and 'warnings' pragmas saves everyone in the long run. Haste makes waste and discipline in code developement gives not only the code, but the maintainer too, a long career. :-))
Regards to you both!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 06:27 AM
11-13-2005 06:27 AM
Re: Perl processing issue Interesting name characters.
Kewl.
ITRC. There is no better place.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2005 07:01 PM
11-13-2005 07:01 PM
Re: Perl processing issue Interesting name characters.
Even though he acknowledges it could be improved upon, its a production problem and the simple solution makes the production problem go away.
I will try and build a better solution that takes into account future strangeness in last name definition.
Aside,
JRF, A pleasure to work with you. Your Perl skills obviously exceed mine, but you gave me the confidence to test a solution and confirmed my problem definition.
I know life changes and people do to, but It is a pleasure to have you back and I learn from every post you make that I read.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com