Solved

How do I represent a TAB in CGI program.

Posted on 1997-06-03
1
207 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
Comment Utility
Tab is CGI perl is: \t.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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 video discusses moving either the default database or any database to a new volume.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now