Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 26th, 2009, 05:06 AM
jch09 jch09 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 jch09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 33 sec
Reputation Power: 0
Simple Regular Expression Q

Hello to all community,

I am newbie to Perl & Regular Expresiions too and I was looking
for an answer to the following problem...

I am trying to read a line of the form: xxyyzzz.pdf or xx.yy.zzz.pdf etc

Originally I used $line=~ s/^.*\///; to capture the filename but
this doesn't work in the second case, when dot(s) are inside the filename.

How I can do that with a regular expression ?


many thanks,

John Ch.

Reply With Quote
  #2  
Old October 26th, 2009, 05:17 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 37 m 21 sec
Reputation Power: 3885
The regexp you've posted removes everything up to (and including) the first '/' character in the string. There aren't any '/' characters in the filenames you've posted.

Reply With Quote
  #3  
Old October 26th, 2009, 05:26 AM
jch09 jch09 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 jch09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 33 sec
Reputation Power: 0
Regexp newbie

ok let me reformylate my question:

Assuming that I have strings of the form xx.yy.zzz.pdf

Which is the regexp to get the filenames including dots (i.e capture the "xx.yy.zzz") ?

thanks ishnid for your immediate answer!

Reply With Quote
  #4  
Old October 26th, 2009, 05:37 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 37 m 21 sec
Reputation Power: 3885
You could do this:
Code:
my ( $no_extension ) = $filename =~ /^(.+)\./;

Or if they always end in .pdf you could just strip that from the end directly.

The main problem with capturing everything up to the last dot in your string is that you can get some filenames with double file extensions, such as "foo.tar.gz". Something to keep in mind.
Comments on this post
Axweildr agrees!

Reply With Quote
  #5  
Old October 26th, 2009, 12:01 PM
shawnhcorey's Avatar
shawnhcorey shawnhcorey is offline
wizard
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Location: The Great White North
Posts: 75 shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 18 h 51 m 11 sec
Reputation Power: 136
Quote:
Originally Posted by jch09
ok let me reformylate my question:

Assuming that I have strings of the form xx.yy.zzz.pdf

Which is the regexp to get the filenames including dots (i.e capture the "xx.yy.zzz") ?

thanks ishnid for your immediate answer!


It would be better to use a module for it. Both File::Basename and File::Spec could and both are standard modules; they come with Perl.
__________________
__END__

I love Perl; it's the only language where you can bless your thingy.

Reply With Quote
  #6  
Old October 26th, 2009, 12:14 PM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 37 m 21 sec
Reputation Power: 3885
Don't you need to expressly supply a suffix (i.e. '.pdf' in this case) for File::Basename?

Reply With Quote
  #7  
Old October 26th, 2009, 02:13 PM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,652 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 6 h 21 sec
Reputation Power: 1170
Quote:
Originally Posted by ishnid
Don't you need to expressly supply a suffix (i.e. '.pdf' in this case) for File::Basename?


No, you can use a regex.

Taken from the perldoc.
Code:
If @suffixes are given each element is a pattern (either a string or a qr//) matched against the end of the $filename. The matching portion is removed and becomes the $suffix.

     # On Unix returns ("baz", "/foo/bar/", ".txt")
     fileparse("/foo/bar/baz.txt", qr/\.[^.]*/);

Reply With Quote
  #8  
Old October 26th, 2009, 02:49 PM
shawnhcorey's Avatar
shawnhcorey shawnhcorey is offline
wizard
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Location: The Great White North
Posts: 75 shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level)shawnhcorey User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 18 h 51 m 11 sec
Reputation Power: 136
Quote:
Originally Posted by FishMonger
No, you can use a regex.

Taken from the perldoc.
Code:
If @suffixes are given each element is a pattern (either a string or a qr//) matched against the end of the $filename. The matching portion is removed and becomes the $suffix.

     # On Unix returns ("baz", "/foo/bar/", ".txt")
     fileparse("/foo/bar/baz.txt", qr/\.[^.]*/);


Wouldn't that be?
perl Code:
Original - perl Code
  1. # On Unix returns ("baz", "/foo/bar/", ".txt")
  2. fileparse("/foo/bar/baz.txt", qr/\.[^.]*$/);

Reply With Quote
  #9  
Old October 31st, 2009, 04:49 AM
thangdd thangdd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 thangdd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 7 sec
Reputation Power: 0
How to convert string to an expression in PERL

I have a quesion for my problem with using mysql and perl programming.

- data from mysql is logic expression. After query I get it's value on string format:

my $data = "$sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/";

In this expression $sex,$age,$optid is variables

- How to make Perl understanding this function?
my $sex,$age,$optid;
if ($data) {
........
........
}

as

if ($sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/) {
........
........
}

help me please!

Reply With Quote
  #10  
Old October 31st, 2009, 05:22 AM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,874 Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)  Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 1 Day 20 h 28 m 56 sec
Reputation Power: 6421
Send a message via Google Talk to Axweildr
Orkut
you would need to parse that logic expression, and break on &&
Code:
(@atoms)=split(/&&/, $data);
$if_string="if (";
while (@atoms) {
  $if_string.="($_) && ";
}
#remove the last two & and a space
$if_string=substr($if_string, 0, -3).") {";
print $if_string;
This what you're after, NOT TESTED BTW
__________________
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
-- Jamie Zawinski
Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE

Reply With Quote
  #11  
Old October 31st, 2009, 05:23 AM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,874 Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)  Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 1 Day 20 h 28 m 56 sec
Reputation Power: 6421
Send a message via Google Talk to Axweildr
Orkut
something seems to have gone a tad arseways here, these two threads just collided???

Reply With Quote
  #12  
Old October 31st, 2009, 05:54 AM
thangdd thangdd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 thangdd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 7 sec
Reputation Power: 0
How to convert string to an expression in PERL

Quote:
Originally Posted by Axweildr
you would need to parse that logic expression, and break on &&
Code:
(@atoms)=split(/&&/, $data);
$if_string="if (";
while (@atoms) {
  $if_string.="($_) && ";
}
#remove the last two & and a space
$if_string=substr($if_string, 0, -3).") {";
print $if_string;
This what you're after, NOT TESTED BTW


------------------------------------------------------------
Thank for your helped, but I want to make that perl understanding


my $data = "$sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/";

my $sex,$age,$optid;
if ($data) {
........
........
}


Likes

if ($sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/) {
........
........
}


Ex:

Code:
my $age=1;#wrong data for expression -> return fales
my $sex = 0;
my $optid = 100;#Wrong data for expression  -> return fales
my $data = "$sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/";
if ($data) {
  print "True1";
} else {
  print "False1";
}

if ($sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/) {
  print "True 2";
} else {
  print "false 2";
}

I wanted the same value printed as

false 1
false 2


But the first expression - $data is a string and is defined so the result is "True 1"
True 1
false 2


your final result is string too, not my target

Reply With Quote
  #13  
Old October 31st, 2009, 06:09 AM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,874 Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)  Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 1 Day 20 h 28 m 56 sec
Reputation Power: 6421
Send a message via Google Talk to Axweildr
Orkut
perl Code:
Original - perl Code
  1. #!/usr/bin/perl
  2. $data="test2";
  3. if ($data) {
  4.     print "[$data]OK\n";
  5. } else {
  6.     print "[$data]NOK\n";
  7. }
  8. $data="x";
  9. if ($data) {
  10.     print "[$data]OK\n";
  11. } else {
  12.     print "[$data]NOK\n";
  13. }
  14. $data="";
  15. if ($data) {
  16.     print "[$data]OK\n";
  17. } else {
  18.     print "[$data]NOK\n";
  19. }
The code above shows what's happening to your if statements, you need to eval your if statement in an if block as per below
perl Code:
Original - perl Code
  1. my $data = '$sex < 1 && $age >= 17 && $age <= 40 && \',1,2,3,\' =~m/(,)$optid(,)/';
  2. print $data;
  3. print "=====================================\n";
  4. (@atoms)=split(/&&/, $data);
  5. $if_string="if (";
  6. for (@atoms) {
  7.   $if_string.="($_) && ";
  8. }
  9. #remove the last two & and a space
  10. $if_string=substr($if_string, 0, -3).") {\n";
  11. $if_string.=" print \"True2\";
  12. } else {
  13.   print \"false 2\";
  14. }
  15. ";
  16. print $if_string;
  17. eval ($if_string);
Hope that helps
--Ax

Reply With Quote
  #14  
Old October 31st, 2009, 06:13 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,652 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 6 h 21 sec
Reputation Power: 1170
perldoc -f eval

This Q is cross posted to at least one other forum.
perlguru.com

Reply With Quote
  #15  
Old November 1st, 2009, 09:10 PM
thangdd thangdd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 thangdd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 7 sec
Reputation Power: 0
How to convert string to an expression in PERL

Quote:
Originally Posted by Axweildr
perl Code:
Original - perl Code
  1. #!/usr/bin/perl
  2.  ......
  3. print $if_string;
  4. eval ($if_string);
Hope that helps
--Ax


It works - thank you very much!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Simple Regular Expression Q

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap