Solved

How do I represent a TAB in CGI program.

Posted on 1997-06-03
1
221 Views
Last Modified: 2012-06-21
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
Comment
Question by:jfuller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
yxw1 earned 50 total points
ID: 1204204
Tab is CGI perl is: \t.


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question