El Tuesday 19 August 2008 01:17:59 Orson va escriure: > I need to change perl script, but I am new to perl. Script is too long > to copy here, but what I need is construct a reg ex pattern and store > in variable. I need to concatenate this from many other variables. > Then I must use this variable to do a match. Something like this: > while (<>) > { > chomp; > my $pt = "\d" . "\s" . "\d"; > if ( /$pt/ ) > { > print("Match also using variable\n"); > } > > if ( /\d\s\d/ ) > { > print("Match not using variable\n"); > } > } > > The second match work if you give input like "1987 1988", but I > cannot get first match to work. I must be confusing perl with /$pt/ > > but i don't know how to fix. Can someone give some hint, please?
What do you want match in first place? You can store a matched pattern into a varaible using automatic memories as follows : m#(pattern)#; $variable= $1.; -- Xavier Mas ______________________________________________ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/