473,657 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assign value to variable

Is there any way I can use a function to create a variable and assign
a value to it? I have a Perl script that returns some LDAP
information:

sn=Shore
givenname=Mike
logintime=20041 008153445Z
logindisabled=F ALSE

Instead of parsing this text and assigning the values, I was wondering
if a function exists where I can pass a variable name and a value, and
the variable would be created.

ie. somefunc("sn", "Shore")

Would create the variable $sn and assign the value "Shore" to it.
Jul 17 '05 #1
9 8381
In article <d3************ **************@ posting.google. com>, Mike wrote:
Is there any way I can use a function to create a variable and assign
a value to it? I have a Perl script that returns some LDAP
information:

sn=Shore
givenname=Mike
logintime=20041 008153445Z
logindisabled=F ALSE

Instead of parsing this text and assigning the values, I was wondering
if a function exists where I can pass a variable name and a value, and
the variable would be created.


The output looks like what i see in a ini file, so you could consider
using ini_get?
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2
In article <2s************ *@uni-berlin.de>, Tim Van Wassenhove wrote:
In article <d3************ **************@ posting.google. com>, Mike wrote:
Is there any way I can use a function to create a variable and assign
a value to it? I have a Perl script that returns some LDAP
information:

sn=Shore
givenname=Mike
logintime=20041 008153445Z
logindisabled=F ALSE

Instead of parsing this text and assigning the values, I was wondering
if a function exists where I can pass a variable name and a value, and
the variable would be created.


The output looks like what i see in a ini file, so you could consider
using ini_get?


I meant http://www.php.net/parse_ini_file

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #3
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
ie. somefunc("sn", "Shore")

Would create the variable $sn and assign the value "Shore" to it.


function somefunc($var,$ value){
global $$var;
$$var=$value;
}
somefunc("sn", "Shore");
print $sn;

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Works like a charm. It was that double $$ that I could not wrap my
head around. Thanks very much!

Geoff Berrow <bl******@ckdog .co.uk> wrote in message news:<qh******* *************** **********@4ax. com>...
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
ie. somefunc("sn", "Shore")

Would create the variable $sn and assign the value "Shore" to it.


function somefunc($var,$ value){
global $$var;
$$var=$value;
}
somefunc("sn", "Shore");
print $sn;

Jul 17 '05 #5
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
Works like a charm. It was that double $$ that I could not wrap my
head around. Thanks very much!


Ah, variable variables. Yep they are fun. :-)
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
Okay all you gurus, here is my next challenge :-)

I need to convert a Perl LDAP query result to an array. So far I have
been able to create an variable name; for example
$name = "ret[8]['givenname'][0]";
$value = "Mike"

What I want to do now is assign the $value to the $name, as in

$$name = $value;

but that does not work. I need the end result to be:
$ret[8]['givenname'][0] = "Mike";

Geoff Berrow <bl******@ckdog .co.uk> wrote in message news:<hs******* *************** **********@4ax. com>...
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
Works like a charm. It was that double $$ that I could not wrap my
head around. Thanks very much!


Ah, variable variables. Yep they are fun. :-)

Jul 17 '05 #7
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
I need to convert a Perl LDAP query result to an array


I don't suppose you could use the PHP LDAP functions and save some
bother?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8
Hi Geoff,

I originally had everything written in PHP and it worked fine on my
own test server, but then I tried it on the "official" test server it
would not work.

From what I have been told by our server guys, our Solaris server
comes with a built in LDAP module for Netscape directories, and does
not support PHP's LDAP module. So I needed to rewrite all my LDAP code
in Perl, which *is* supported by the Solaris server, and then call the
Perl code from LDAP, then parse the results back in PHP. *** sigh ***

Geoff Berrow <bl******@ckdog .co.uk> wrote in message news:<i7******* *************** **********@4ax. com>...
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
I need to convert a Perl LDAP query result to an array


I don't suppose you could use the PHP LDAP functions and save some
bother?

Jul 17 '05 #9
I noticed that Message-ID:
<d3************ **************@ posting.google. com> from Mike contained
the following:
From what I have been told by our server guys, our Solaris server
comes with a built in LDAP module for Netscape directories, and does
not support PHP's LDAP module. So I needed to rewrite all my LDAP code
in Perl, which *is* supported by the Solaris server, and then call the
Perl code from LDAP, then parse the results back in PHP. *** sigh ***


Just an idea because I don't know much about Perl. I do know Perl
scripts echo html so why can't a perl script echo php? If this was
then saved as a file it could be simply included in any php script you
want.

Apologies if I am wildly wrong here.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #10

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

Similar topics

25
4324
by: Rim | last post by:
Hi, I have been thinking about how to overload the assign operation '='. In many cases, I wanted to provide users of my packages a natural interface to the extended built-in types I created for them, but the assign operator is always forcing them to "type cast" or coerce the result when they do a simple assign for the purpose of setting the value of a variable. Borrowing an example from this newgroup, the second assignment below ereases...
2
8325
by: Matt | last post by:
If I assign VBScript server side variable a to javascript variable x, it is fine. <% Dim a, b a = 10 %> var x = <%= a %>; alert(x); But if I do the other way around, then it has 500 error. any ideas??
4
8989
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have added a sample of that below (there would be many more rows). I'm wondering if there is a way to dynamically generate the variable names (ie: T1val, T2val, etc.) in my function 'calc', based on the argument 'regnum' that I pass it. The problem...
4
12567
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; document.getElementById('myelement') = new Function("myfnc(param1,param2,param3)");
2
6235
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the problem. Any suggestings are welcomed. Jim ************* You tried to assign the Null value to a variable that is not a Variant data type. Description: An unhandled exception occurred during the execution of the current web request. Please...
6
2259
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1") txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2") ..... txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10") ------code ------- Dim field As String = "Q"
2
3401
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for better understanding: page1.asp ---session("PaymentMethod") page2.asp ---Depending on the radio button selected the payment
6
4093
by: Don Lancaster | last post by:
I need to progrmatically do this inside a loop this.fh03.value = fixFloat (Harms, numPoints) ; with the numbers changing per an index. If I try curHvals = "03" ; // (derived from index to provide leading zero)
2
3149
by: Birky | last post by:
Assign the output of a select to a variable? I am unable to find a way to assign the results of an SQL statement to a variable. I know how to assign the SQL statement to a variable but again no luck assigning the results. I have the need to assign the primary key of a table, which is an auto number data type) therefore a numeric value. My select is very basic for I am just looking for the primary key where two options are met. "SELECT...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2731
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
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.