473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing a list as an arg to a subroutine

Hi all. I've been using Perl for many years now, but I am a "use it and
learn it as you need it" type. I having some trouble passing a list to
the "search" subroutine from Net::LDAP.

I am trying to pass a list of attributes to be returned by search. The
basic method call is:

my $searchresults = $ldap->search(OPTIONS)

One of the options is "attrs =>" which the documentation describes as "A
list of attributes to be returned for each entry that matches the search
filter.".

I am able to do something like this no problem:

my $searchresults = $ldap->search (
base => "$searchbase",
filter => "$searchfilter",
attrs => [ 'uid', 'cn' ];
)

That works just fine.

But what I now want to do is provide the list of attributes to be
returned on the command line much like the way ldapsearch works. @ARGV
is the list of attributes to be returned. I am not sure how to pass
@ARGV to search. I've tried just passing the array, references to the
array, but nothing is working for me. The search completes, but, looking
at the directory logs, the search is requesting ALL attributes rather
than just the ones I want.

my $searchresults = $ldap->search (
base => "$searchbase",
filter => "$searchfilter",
attrs => @ARGV;
)

my $searchresults = $ldap->search (
base => "$searchbase",
filter => "$searchfilter",
attrs => \@ARGV;
)

I am sure I am just using a ref when I shouldn't be, or not using a ref
when I should, or simply referencing the array incorrectly but I am not
sure which one it is!

I actually have the same problem if I try to define the attributes
outside the subroutine call. e.g., if I do this:

my $attrs = [ 'cn', 'uid' ];
my $searchresults = $ldap->search (
base => "$searchbase",
filter => "$searchfilter",
attrs => $attrs;
)

That is not working for me either. Something is broken in my understanding.

Thanks,

Mark
Mar 7 '06 #1
2 4700
Cancel that, finally figured out what I was doing wrong. I was trying to
pass

"\@ARGV"

rather than

\ARGV

I was tripping over the "\" which of course has special meaning inside
the double quotes!

Mark
Mar 7 '06 #2
In article <Ct******************************@magma.ca>,
ma**@gangwarily.ca wrote:
Cancel that, finally figured out what I was doing wrong. I was trying to
pass

"\@ARGV"

rather than

\ARGV

I was tripping over the "\" which of course has special meaning inside
the double quotes!


And that's why you should ceck out

perldoc -q quoting
What's wrong with always quoting "$vars"?

Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it this way as our build process does not allow...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
3
by: Scott | last post by:
What is the proper syntax for sending an argument from a form contol to a subroutine in a module? For instance, from a textbox on a form I call a module subroutine from the textbox's OnUpdate...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
14
by: bgreenspan | last post by:
I have a form with a subform. In the subform I have several fields to which I am assigning links to documents on the file server. I learned (from this list :-) how to add the links. Because I...
2
by: mj.redfox.mj | last post by:
Hi, Pretty basic question, apologies but being a bit of a newbie I still don't know the answer to this kind of thing! I have a repeater which, upon databind calls a subroutine, as below: ...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.