Solved

How do I represent a TAB in CGI program.

Posted on 1997-06-03
1
212 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
1 Comment
 

Accepted Solution

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


0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

803 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