473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 => "$searchbas e",
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 => "$searchbas e",
filter => "$searchfilter" ,
attrs => @ARGV;
)

my $searchresults = $ldap->search (
base => "$searchbas e",
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 => "$searchbas e",
filter => "$searchfilter" ,
attrs => $attrs;
)

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

Thanks,

Mark
Mar 7 '06 #1
2 4724
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
3515
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 circular dependencies of DLL's. Does anyone know how to do this, I have tried everything in my book. I have a C++ function GetP: DllExport void...
1
6406
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 the array in fortran and then accessing it in my c++ code. Say in my c++ code I have; extern "C" { void foo_(float **, int &, int &); }
3
6769
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 event. I want to pass the form's name to the the Module subroutine. What is the proper syntax for the textbox event to pass the form name and what is the...
39
7616
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 indicate: a) That I don't know enough b) Passing arguments by ref is bad
7
9546
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 subroutine Let's say theres a sub that creates buttons and I want it to receive as a parameter the address of the sub that handles the OnClick event...
3
2535
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 Object, it throws a cast error. The only way I've been able to get this to work is to return an ArrayList and then use the .CopyTo method of the...
14
5358
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 will be executing the code for four or five fields, I would like to have a generic subroutine to pass the field name parameters to. I have...
2
2648
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: ASPX PAGE -------------------
2
4424
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 * len(id) # id is a list of strings Id_dat=StringVector() for i in range(len(Id)): ....Id_dat=id
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.