develooper Front page | perl.perl5.porters | Postings from June 2003

Split command using a variable

Thread Previous
From:
SudhakarMallampalli
Date:
June 25, 2003 08:48
Subject:
Split command using a variable
Message ID:
575FEFC63FDA8142A986BB77D0747B963EDAF1@milexc05.slr.com

Hi 

I am trying to use a split command to read a certain field. The file can
come with any type of variable.  Only thing constant is the length of the
first field which is 3 charectors. The forth charector is the field
delimiter for the file.
Can I use the split command like follows? 
@tags=split( /$sep/, $line);

************************************************
while ($line=<INFILE>) {
$sep=substr($line,3,1);
# @tag=split(/:/, $line);
$flag=substr($line,0,3);
if ($flag eq "UNB") {
$EDIFACT = "YES";
$EDI = "NO";
}
if ($EDIFACT eq "YES") {
@tags=split( /$sep/, $line);
$tag = $tags[10];
print ($tag);
  if ($tag eq "T" ) {
     $tflag = "YES";
     print $tag;
	print $tags[10];
   }
  elsif ($tag eq "P" ) {
   $tflag = "NO" ;
   print $tag;
	print $tags[10];
 }
****************************************************

Thank you 

Sudhakar




Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About