synchronisation entre perl et bash
Bobjour ,
J'ai le problème suivant :
je parcours mon fichier a l'aide d'un script perl ligne apres ligne.
il se peut que mon fichier change entre deux lecture de ligne.
Comment forcer perl a raffraichir son buffer.
voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| open(FICIN,"+>$cell.cdl") or die ("open: $!");
$myauxiliary = select (FICIN);
$|=1;
select($myauxiliary);
while (defined ($line = <FICIN>))
{
chomp($line);
if ($line=~ m/.SUBCKT/)
{
@tab1 = split (/ +/,$line);
chomp($tab1[1]);
$mysubckt = $tab1[1];
if($line!~ m/$cell /)
{
while ($line!~ m/.ENDS/)
{
if ($line=~ m/VDD/) { $VDD=1;}
if ($line=~ m/GND/) { $GND=1;}
if ($line=~ m/V0IO/) { $V0IO=1;}
if ($line=~ m/V33IO/) { $V33IO=1;}
if ($line=~ m/V25IO/) { $V25IO=1;}
$line = <FICIN>;
chomp($line);
}
$myvar="";
if ($VDD==1) { $VDD =0; $myvar .= "VDD ";}
if ($GND==1) { $GND=0;$myvar .= "GND ";}
if ($V0IO==1) { $V0IO=0;$myvar .= "V0IO ";}
if ($V33IO==1) {$V33IO=0;$myvar .= "V33IO ";}
if ($V25IO==1) {$V25IO=0;$myvar .= "V25IO ";}
@args = ("sed -i \"s|\\(.SUBCKT $mysubckt .*\\)|\\1 $myvar|g\" $cell2" );
system(@args) == 0 or die "system @args failed: $?";
@args = ("sed -i \"s|\\(X[0-9a-zA-Z_ ]*\\)\\(\\/ $mysubckt\\)|\\1$myvar\\2|g\" $cell2" );
system(@args) == 0 or die "system @args failed: $?";
}
}
}
close (FICIN); |
je fais un appel systeme avec un sed , et je voudrais que les changements fais par cet appel system soit pris en compte des la prochaine ligne de lecture ( que perl actualise son buffer en gros ) .
j'ai éssayé avec l'option autoflush ($|) mais ca ne marche pas.
merci d'avance