Solved

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

Posted on 2001-09-12
7
151 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell  and PSExec = Password failure 5 26
IDE for Python 5 104
size of file 1 36
script to read text file 34 26
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…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 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