Solved

Search a variable and put in a array.... Help !!!!!

Posted on 2001-09-12
7
140 Views
Last Modified: 2013-12-25
Dear everyone ,

I have a variable=

$file = qq!print "Content-type: text/html\n\n";if ($ENV{'QUERY_STRING'} =~ /^album=(\S+);image=(\d+);whatsnew$/) {$dir = $1;$si = $2;$no = $2;!;


Now what i want is the code which scans the whole $file for variables (eg. $no , $dir). It should ignore Numbers (eg $1,$2) and then add their name to a array.

It should not repeat the same variable twice
 in the array.

Thus the array should read something like this -

@array = ("no","si","dir","and so on");

Please help ASAP...

Anant
0
Comment
Question by:anant99
7 Comments
 
LVL 6

Expert Comment

by:Jaymol
ID: 6476730
listening...
0
 
LVL 1

Author Comment

by:anant99
ID: 6477193
I think some one can modify this :-

while ($file) {
if (/\$(\w+)/) {
push(@array,$1);
}

i dont know how to get it working...

Please help !!!

Anant
0
 
LVL 5

Expert Comment

by:amandeep
ID: 6477829
anant99,

Try it this way :

while ($file=~/\$(\w+)/g) {
  my $v=$1;
  push(@array,$v) unless($v=~/^\d+$/);
}

Hope this helps

Aman
:-)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:anant99
ID: 6478612
also can u filter out captial variables like $ENV
0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 6486697
$file = q!print "Content-type: text/html\n\n";if($ENV{'QUERY_STRING'} =~ /^album=(\S+);image=(\d+);whatsnew$/)
{$dir = $1;$si = $2;$no = $2;!;
@array = reverse $file=~/\$([a-z]+)\b/g
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6486698
do you mean just to extract the variable names from the string in $ENV{'QUERY_STRING'}  ?
0
 
LVL 1

Author Comment

by:anant99
ID: 6486874
Thanks !!! This is just what I wanted...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to dynamically set the form action using jQuery.

939 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now