?
Solved

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

Posted on 2001-09-12
7
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And 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 600 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 Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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 …
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 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