![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 06:05 PM |
| How to Turn perl one-liners into full perl script? | EDALBNUG | UNIX for Dummies Questions & Answers | 1 | 02-04-2009 10:49 AM |
| [Perl] Accessing array elements within a sed command in Perl script | userix | Shell Programming and Scripting | 2 | 10-03-2008 01:05 PM |
| [PERL] Running unix commands within Perl Scripts | userix | Shell Programming and Scripting | 1 | 05-28-2008 07:06 PM |
| Perl: Run perl script in the current process | vino | Shell Programming and Scripting | 10 | 12-09-2005 10:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Perl reg exp
Hi, I am using the following piece of code for extracting some data from in between some tags ... Code:
$text =~ /<TAG1>(.*)<\/TAG1>.*<TAG2>(.*)<\/TAG2>.*<TAG3>(.*)<\/TAG4>.*<TAG5>(.*)<\/TAG5>/; $tag1=$1; print "\n$tag1"; But I am getting an error like Use of uninitialized value in concatenation (.) or string. The script is running fine on Perl 5.8 but not on 5.6. Is this a version issue? If so then what is the workaround for it? |
|
||||
|
Well, if it works on one and not the other, it could be a version issue but I don't know for sure. The regexp is probably better written like so: Code:
$text =~ /<TAG1>(.*?)<\/TAG1>.*?<TAG2>(.*?)<\/TAG2>.*?<TAG3>(.*?)<\/TAG4>.*?<TAG5>(.*?)<\/TAG5>/; $tag1 = defined $1 ? $1 : 'no match found'; print "\n$tag1"; If you reall only want to capture $1 you should remove all the other parentheses from the regexp as they are aslo capturing pattern matches and storing them in memory for no reason. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|