Solved

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

Posted on 2001-09-12
7
139 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

746 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

11 Experts available now in Live!

Get 1:1 Help Now