PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > passing variable to regular expression (PERL)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

passing variable to regular expression (PERL)

Réponse
 
LinkBack Outils de la discussion
Vieux 07/09/2007, 19h28   #1
krisworld
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut passing variable to regular expression (PERL)

hi all

say I have a target file as
-----
-----
aaaa = { bbbbbbbbbbbbbbbbbbbb}
qqqq ={ dddddddddddd,
cccccccccccccc}
-------
--------
and i need output as
{ bbbbbbbbbbbbbbbbbbbb}
or
{ dddddddddddd,
cccccccccccccc} depending on aaaa or qqqq


so if i use

echo $Result |perl -lne "print if / aaaa ={ /../ }"
i get result

but i need to put it in loop

while read SOMETHING; do

echo $Result |perl -lne "print if / $SOMETHING={ /../ }"

done

I am not able to do it.
Can any one me...
regards
kris

  Réponse avec citation
Vieux 08/09/2007, 01h05   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing variable to regular expression (PERL)

On Fri, 07 Sep 2007 18:28:45 -0000, krisworld
<krishnamurthy.iyer@gmail.com> wrote:
>
>
> hi all
>
> say I have a target file as
> -----
> -----
> aaaa = { bbbbbbbbbbbbbbbbbbbb}
> qqqq ={ dddddddddddd,
> cccccccccccccc}
> -------
> --------
> and i need output as
> { bbbbbbbbbbbbbbbbbbbb}
> or
> { dddddddddddd,
> cccccccccccccc} depending on aaaa or qqqq
>
>
> so if i use
>
> echo $Result |perl -lne "print if / aaaa ={ /../ }"
> i get result
>
> but i need to put it in loop
>
> while read SOMETHING; do
>
> echo $Result |perl -lne "print if / $SOMETHING={ /../ }"
>
> done
>
> I am not able to do it.
> Can any one me...
> regards
> kris
>

while read SOMETHING; do
echo "$SOMETHING" | perl...
done < file

Do you need the while read loop, or can you do the whole thing with
perl?


--
New York is real. The rest is done with mirrors.
  Réponse avec citation
Vieux 08/09/2007, 04h21   #3
krisworld
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing variable to regular expression (PERL)

hi
i understand what u say, but my issue is how to pass a variable in a
Regular Expression

i have
aaaa
qqqq
into "SOMETHING"
now i shall loop the complete data which is in $Result SOMETHING
I shall appreciate if u could me.
kris


and need to extract only values in between { .. } depending on the
value of

On Sep 8, 5:05 am, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On Fri, 07 Sep 2007 18:28:45 -0000, krisworld
>
>
>
> <krishnamurthy.i...@gmail.com> wrote:
>
> > hi all

>
> > say I have a target file as
> > -----
> > -----
> > aaaa = { bbbbbbbbbbbbbbbbbbbb}
> > qqqq ={ dddddddddddd,
> > cccccccccccccc}
> > -------
> > --------
> > and i need output as
> > { bbbbbbbbbbbbbbbbbbbb}
> > or
> > { dddddddddddd,
> > cccccccccccccc} depending on aaaa or qqqq

>
> > so if i use

>
> > echo $Result |perl -lne "print if / aaaa ={ /../ }"
> > i get result

>
> > but i need to put it in loop

>
> > while read SOMETHING; do

>
> > echo $Result |perl -lne "print if / $SOMETHING={ /../ }"

>
> > done

>
> > I am not able to do it.
> > Can any one me...
> > regards
> > kris

>
> while read SOMETHING; do
> echo "$SOMETHING" | perl...
> done < file
>
> Do you need the while read loop, or can you do the whole thing with
> perl?
>
> --
> New York is real. The rest is done with mirrors.- Hide quoted text -
>
> - Show quoted text -



  Réponse avec citation
Vieux 08/09/2007, 04h33   #4
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: passing variable to regular expression (PERL)

In article <1189189725.076359.21350@19g2000hsx.googlegroups.c om>,
krisworld <krishnamurthy.iyer@gmail.com> wrote:

> while read SOMETHING; do
>
> echo $Result |perl -lne "print if / $SOMETHING={ /../ }"


Aren't you missing a / at the end?

>
> done
>
> I am not able to do it.
> Can any one me...
> regards
> kris


while read SOMETHING; do
export SOMETHING
echo $Result | perl -lne 'print if / $ENV{SOMETHING}={ / .. / }/'

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h23.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10180 seconds with 12 queries