• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

How do I represent a TAB in CGI program.

I was wondering if anybody knew how to represent a TAB stop in a Perl CGI Program.  I have a simple cgi program that manipulates a d-base when a link is followed (or image is clicked).  It works great when the DBASE is PIPED between fields.  I need it to work when the d-base is TABBED.  Any reply would be greatly appreciated.

Here is the Code if you need it.  The areas that I need TABBED instead of PIPED are marked with.

#-=-=-=-=-=-=-=-TAB should take place of PIPE Here.-=-=-=-=-=-=-=-


<----------------Begin Code--------------------->

#!/usr/bin/perl
$MINBAK = "min/min.bak";
$MINCNT = "min/min.cnt";
$MINDAT = "min/min.dat";
$MINLOG = "min/min.log";
$MINFLK = "flk/min.flk";

$command   = "IMG"; # set default
$minNbr = 0;     # set default
$minUrl = "/cgi-localbin/min";
$scriptUrl = "/cgi-localbin/minmat.cgi";


######################################################################
# Read the QUERY STRING

if ($ENV{'QUERY_STRING'})
{ ($command,$minNbr) = split (/=/,$ENV{'QUERY_STRING'});
}

######################################################################
# Case: Send Image to browser

if ($command eq "IMG")
{
  # Get the min info
  &lock ($MINFLK);
  open (DAT,"<$MINDAT");
  @minFile = <DAT>;
  close (DAT);

#-=-=-=-=-=-=-=-TAB should take place of PIPE Here.-=-=-=-=-=-=-=-
  @minLine = split(/\|/,$minFile[$minNbr]);
 
  # send HTML to browser
  print "Content-type: text/html\n\n";
  print "<a href=\"$scriptUrl?URL=$minNbr\"><font size=1>PLEASE CLICK HERE:</font><br>\n";
  print "<img src=\"$minLine[1]\" border=1></a>\n";


} # end Case IMG

######################################################################
# Case: Send browser to the image's URL

elsif ($command eq "URL")
{
  # Get the min info
  &lock ($MINFLK);
  open (DAT,"<$MINDAT");
  @minFile = <DAT>;
  close (DAT);

#-=-=-=-=-=-=-=-TAB should take place of PIPE Here.-=-=-=-=-=-=-=-
  @minLine = split(/\|/,$minFile[$minNbr]);

  # send browser to URL corresponding to IMG
  print "Location: $minLine[0]\n";
  print "Content-type: text/html\n\n";

  # subtract one from dbase field
  $minLine[2] --;

#-=-=-=-=-=-=-=-TAB should take place of PIPE Here.-=-=-=-=-=-=-=-
  $minFile[$minNbr] = join ("\|",@minLine);
 
  # backup and update min file
  if (-s $MINDAT) {print `cp $MINDAT $MINBAK`;}
  open (DAT,">$MINDAT");
  print (DAT @minFile);
  close (DAT);
  &unlock ($MINFLK);

} # end Case URL

##################################################################
# Sub: File locks prevent simultaneous changes

sub lock
{ $LOCKFILE = $_[0];
  if (-e $LOCKFILE)
  { $endTime = time + 3;
    while (-e $LOCKFILE && time < $endTime)
    { sleep 1;
    }
  }
  open (LOCK,">$LOCKFILE");
  print (LOCK "busy");
  close (LOCK);
} # end lock

sub unlock
{ $LOCKFILE = $_[0];
  if (-e $LOCKFILE)
  { unlink ($LOCKFILE);
  }
} # end lock
0
jfuller
Asked:
jfuller
1 Solution
 
yxw1Commented:
Tab is CGI perl is: \t.


0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now