[13523] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 933 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 28 17:32:58 1999

Date: Tue, 28 Sep 1999 14:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938552714-v9-i933@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 28 Sep 1999     Volume: 9 Number: 933

Today's topics:
        Assign variable from cgi-lib.pl field? <nospam@thankyou.com>
    Re: Assign variable from cgi-lib.pl field? <emschwar@rmi.net>
    Re: Assign variable from cgi-lib.pl field? <AgitatorsBand@yahoo.com>
    Re: Assign variable from cgi-lib.pl field? <nospam@thankyou.com>
    Re: Assign variable from cgi-lib.pl field? <rootbeer@redcat.com>
        Checking disk space with this script sends unknown erro <csmigaNOcsSPAM@yahoo.com.invalid>
    Re: Checking disk space with this script sends unknown  <vincent.murphy@cybertrust.gte.com>
        Database Help needed <scall@scallynet.co.uk>
    Re: Dealing with "MS-ASCII" - again! (yes, I know it is (Kenny McCormack)
        deiconifying a DOS window <douglas@home.com>
    Re: Error <rootbeer@redcat.com>
    Re: File Upload <isaac.hepworth@dresdner-bank.com>
    Re: gcos/gecos <tech@tburg.net>
    Re: gcos/gecos <rootbeer@redcat.com>
    Re: gcos/gecos (Larry Rosler)
    Re: How to append an extension to a value in a variable <jcreed@cyclone.jprc.com>
    Re: How to save a file as binary? (Larry Rosler)
    Re: How to save a file as binary? <flavell@mail.cern.ch>
    Re: I can't see the error (short bit of code) <sariq@texas.net>
    Re: I can't see the error (short bit of code) <sariq@texas.net>
        kill extra white space in a variable <mikej@1185design.com>
    Re: kill extra white space in a variable <makkulka@cisco.com>
    Re: kill extra white space in a variable <rootbeer@redcat.com>
        LOST NEWBIE <g-preston1@ti.com>
    Re: LOST NEWBIE <rootbeer@redcat.com>
    Re: Match and escape processing Brett.A.Hunsaker@usace.army.mil
    Re: New book: Automating Windows With Perl (Kragen Sitaker)
        Perl Question rthompson4450@my-deja.com
    Re: Piping a file to STDIN of a Perl function (Kragen Sitaker)
    Re: Please compare and contrast C and Perl. <dwozmak@rational.com>
    Re: Problem with eval and lexical scoping (Charles DeRykus)
        Question <ICEMOUNTAIN@prodigy.net>
        question: cgi-script on server a database on server b <thorsten.muschler@uni-essen.de>
    Re: Simple Mail Transfer Protocol ... Not So Simple! <dwozmak@rational.com>
    Re: Splitting into two-character array (Craig Berry)
    Re: threads?? (Kragen Sitaker)
    Re: Unix and Perl script (Trevor Osatchuk)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 28 Sep 1999 14:45:19 -0500
From: "Campos" <nospam@thankyou.com>
Subject: Assign variable from cgi-lib.pl field?
Message-Id: <37f11ac8_3@news1.prserv.net>

When using cgi-lib.pl, is it possible to pass one of the values returned to
a variable?

Here's the code Im trying to get working:

___________________

require "./cgi-lib.pl";

  my (%data, $field);

  &ReadParse(\%data);

  print &PrintHeader;
  print &HtmlTop ("Header");

  print "<HR>";
  print "Your name is $data{'firstname'}";   # This works okay

  print $data{'firstname'};              # This works okay
  $var = '$data{'firstname'}';
   print $var;                                    # This does not work.

etc...




------------------------------

Date: 28 Sep 1999 14:19:15 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Assign variable from cgi-lib.pl field?
Message-Id: <xkfpuz2hjr0.fsf@valdemar.col.hp.com>

"Campos" <nospam@thankyou.com> writes:
> When using cgi-lib.pl

Don't do that.  Use CGI.pm.  cgi-lib.pl is old, decrepit, and seriously
out-of-date.  CGI.pm, on the other hand, is shiny, new, and sparkly
clean, loaded and ready for bear.

> is it possible to pass one of the values returned to
> a variable?

No.  You can never store anything you get passed as a parameter to a CGI
in a variable-- it's just not allowed.  Think of the chaos!

> require "./cgi-lib.pl";

use CGI;

>   my (%data, $field);
> 
>   print &PrintHeader;
>   print &HtmlTop ("Header");

print header,start_html(-title => "Header");

>   print "<HR>";
>   print "Your name is $data{'firstname'}";   # This works okay
> 
>   print $data{'firstname'};              # This works okay
>   $var = '$data{'firstname'}';

$var = param('firstname');

>    print $var;                                    # This does not work.

That's because you used single quotes around the 

$data{'firstname'} 

part.  In fact, it doesn't even compile, because it looks like you're
assigning $var to the string '$data{' followed by firstname, which is a
bareword, followed by the string '}'.  perl -c on the above bit of code
gives: Bad name after firstname:: at /tmp/tmp.pl line 14.

You don't even need either set of quotes-- the hash key doesn't need
quotes if it looks like a Perl identifier, and the outside quotes
explicitly prevent interpolation.

Of course, if you used CGI.pm, you wouldn't have this problem.

-=Eric


------------------------------

Date: Tue, 28 Sep 1999 20:20:59 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Assign variable from cgi-lib.pl field?
Message-Id: <Lq9I3.70$bc.19549@news.shore.net>

Campos <nospam@thankyou.com> wrote:
:   print $data{'firstname'};              # This works okay
:   $var = '$data{'firstname'}';
:    print $var;                                    # This does not work.

Don't use single quotes around $data{'firstname'} .

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


------------------------------

Date: Tue, 28 Sep 1999 15:34:50 -0500
From: "Campos" <nospam@thankyou.com>
Subject: Re: Assign variable from cgi-lib.pl field?
Message-Id: <37f12666_1@news1.prserv.net>


Eric The Read wrote in message ...

>Don't do that.  Use CGI.pm.  cgi-lib.pl is old, decrepit, and seriously
>out-of-date.  CGI.pm, on the other hand, is shiny, new, and sparkly
>clean, loaded and ready for bear.


[snip]

>
>use CGI;
>


[snip]

>Of course, if you used CGI.pm, you wouldn't have this problem.
>
>-=Eric

Okay, okay!  Im sold!

Thanks for the quick answers.

Cheers.




------------------------------

Date: Tue, 28 Sep 1999 13:42:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Assign variable from cgi-lib.pl field?
Message-Id: <Pine.GSO.4.10.9909281337370.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, Campos wrote:

> When using cgi-lib.pl, is it possible to pass one of the values
> returned to a variable?

Probably. But you'd probably be better off using the CGI module instead.

> require "./cgi-lib.pl";

The CGI spec doesn't specify which directory will be the current working
directory when a CGI program is started.

    http://hoohoo.ncsa.uiuc.edu/cgi/

It may be the root directory, the server's working directory, the home
directory for user nobody, the home directory for root, the directory the
program is stored in, the directory the server is stored in, the base
cgi-bin directory, the /tmp directory, a directory you don't have access
to from the shell, a directory named after an annoying character from
Saturday Night Live, a directory chosen at random, or some other
directory.

A CGI program which uses a relative path before chdir()ing to a
non-relative path is in a state of sin.

>   $var = '$data{'firstname'}';

I think you want to remove all four of the quote marks from that line of
code. 

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 28 Sep 1999 13:38:24 -0700
From: Christopher Smiga <csmigaNOcsSPAM@yahoo.com.invalid>
Subject: Checking disk space with this script sends unknown error
Message-Id: <283beef1.e97ac348@usw-ex0108-060.remarq.com>

When I use this PERL script on a Sun system.  I get an
error message that I do not understand.  The script came
from a "PERL 5 How-To" book.  I've included the error and
the script.  Could someone explain to me what is happening.

Thanks,
Christopher Smiga

===== ERROR =====
Identifier "main::opt_t" used only once: possible typo at
checkfs.pl line 15.
Identifier "main::opt_f" used only once: possible typo at
checkfs.pl line 14.

===== PERL CODE =====
#!/usr/local/bin/perl -w

# Purpose:
# This determines if a given filesystem is
# past a given percentage.

# We are going to use the Long command line parameters.
use Getopt::Long;

# Parse the command line options.
GetOptions ('t|threshold=i', 'f|filesystem=s');

# Check the results of the command line options.
my $fsystem = $opt_f || die "Usage: $0 -f Filesystem [-t
Threshold]\n";
my $thresh = $opt_t || 95;

# Linux/SunOS/AIX df
# chomp (@dfoutput = `df`);

# HP-UX
# chomp (@dfoutput = `bdf`);

# Solaris df
chomp (@dfoutput = `df -k`);

# Shift the top line off the array.
shift (@dfoutput);

# Start search the output.
foreach $row (@dfoutput)
{
    my ($dev, $blocks, $used, $avail, $cap, $mount) = split
(/\s+/, $row);

    # We need the filesystem asked for.
    next if ($mount ne $fsystem);

    # Take the % sign off the capacity percentge.
    $cap =~ s/%$//;

    # Let's see if they are past the threshold.
    if ($cap > $thresh)
    {
        # We are past the threshold.
        print "The filesystem $fsystem is past the
threshold of $thresh%. (Current: $cap%)\n";

        # Exit with an error.
        exit 1;
    }
    else
    {
        # We are not past the threshold.
        print "The filesystem $fsystem is within the bounds
of the threshold of ${thresh}%. (Current: ${cap}%)\n";

        # Exit cleanly.
        exit 0;
    }
}


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Tue, 28 Sep 1999 20:51:14 GMT
From: Vincent Murphy <vincent.murphy@cybertrust.gte.com>
Subject: Re: Checking disk space with this script sends unknown error
Message-Id: <xjgpuz24v5q.fsf@gamora.ndhm.gtegsc.com>

>>>>> "Christopher" == Christopher Smiga <csmigaNOcsSPAM@yahoo.com.invalid> writes:

    Christopher> When I use this PERL script on a Sun system.  I get an
    Christopher> error message that I do not understand.  The script came
    Christopher> from a "PERL 5 How-To" book.  I've included the error and
    Christopher> the script.  Could someone explain to me what is happening.

    Christopher> Thanks,
    Christopher> Christopher Smiga

    Christopher> ===== ERROR =====
    Christopher> Identifier "main::opt_t" used only once: possible typo at
    Christopher> checkfs.pl line 15.
    Christopher> Identifier "main::opt_f" used only once: possible typo at
    Christopher> checkfs.pl line 14.

    Christopher> ===== PERL CODE =====
    Christopher> #!/usr/local/bin/perl -w

    Christopher> # Purpose:
    Christopher> # This determines if a given filesystem is
    Christopher> # past a given percentage.

    Christopher> # We are going to use the Long command line parameters.
    Christopher> use Getopt::Long;

    Christopher> # Parse the command line options.
    Christopher> GetOptions ('t|threshold=i', 'f|filesystem=s');
GetOptions ('t|threshold=i' => \$opt_t, 'f|filesystem=s' => \$opt_f);


perldoc Getopt::Long will give you exactly the information you are looking
for.


--vjm


------------------------------

Date: Tue, 28 Sep 1999 21:36:08 +0100
From: "David Scally" <scall@scallynet.co.uk>
Subject: Database Help needed
Message-Id: <7sr8rk$bee$1@gxsn.com>

Hi,

I help run a website, which has news which has to be updated nearly daily.
We currently use a method of plain HTML editing and FTPing to update the
site, but I was hoping to add make the news section database-driven.
I've seen site which have news items at say:

www.domain.com/news/view_article?32.asp

How hard would it be to do something like this? Would anyone be able to give
me the coding or something to do this?

Thanks.

David Scally




------------------------------

Date: 28 Sep 1999 14:56:36 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: Dealing with "MS-ASCII" - again! (yes, I know it is a bad term, but we're stuck with it)
Message-Id: <7sr6hk$62d$1@yin.interaccess.com>

In article <Pine.HPP.3.95a.990928202830.22229C-100000@hpplus01.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>If you visit the unicode web site you can view images of unicode
>characters alongside their code values (the four-digit hex values
>you see in those mapping tables you downloaded from the ftp site).
>See for instance
>http://charts.unicode.org/Unicode.charts/normal/U0100.html

OK, will check it out.  But you understand that the goal here isn't so much
to get something pretty as it is to get some that is 7 bit clean.

>Excuse me for pointing this out after you've done the work, but Lynx
>(the web browser, not the realtime operating system!) actually has
>something like what you're presenting here, built into it for the
>purpose of displaying what it calls "7-bit approximations" when run in a
>presentation situation (terminal emulation etc.) that has nothing richer
>available.

Does that mean I could do something like: lynx -dump MS-ASCIIfile > file.txt
and lynx would do the cleaning for me?

That would be good, since it should be clear that I really don't want to do
this myself and/or re-invent any wheels.


------------------------------

Date: Tue, 28 Sep 1999 19:33:56 GMT
From: Douglas Galbraith <douglas@home.com>
Subject: deiconifying a DOS window
Message-Id: <37F11814.1D289601@home.com>

When I execute the script below, the DOS window becomes iconified. How
do  I deiconify it?


use Tk;
my $mw = MainWindow->new;
$mw->title("Hello World");
$mw->Button(-text => "Done", -command => sub { exit })->pack();
MainLoop;


thanks for the help;
DGalbra862@aol.com


------------------------------

Date: Tue, 28 Sep 1999 12:58:51 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Error
Message-Id: <Pine.GSO.4.10.9909281256090.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, Ajay Khanna wrote:

> Subject: Error

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I have written a perl program which when tried to run on a browser
> gives an "Internal Server Error".

That means that your webserver is trying to tell you something. It's not a
perl problem, though; it's a webserver problem.

> The error written in the error_log is : 
> [Mon Sep 27 16:44:09 1999] [error] (8)Exec format error: exec of
> /home/imsc2/www/cgi-bin/calendar-show.pl failed

Sounds as if something tried to exec that file, and that failed. Could the
permission bits of that file be incorrect? Could the first line of that
file not be a proper #! line for your system? Don't ask anyone here - only
you or your local expert can answer those questions.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 28 Sep 1999 20:50:51 +0100
From: "Isaac Hepworth" <isaac.hepworth@dresdner-bank.com>
Subject: Re: File Upload
Message-Id: <7sr61d$7503@ln1p0207inf.dresdnerkb.com>

Peter Icaza <picaza@chsi.com> wrote in message
news:7sr0lb$32j0$1@pike.uhc.com...
>
> Burt Hwang <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com> wrote in message
> news:Pe2I3.7$_X2.365@client...
> > Sorry if this is a silly question but what is "Jeopardy style"?  In case
> I'm
> > doing it, I want to know so that I don't do it again.
> >
>
> "Jeopardy style" is when you post a response in front of/on top of the
> original post.  as in Jeopardy, you get the answer first, bad dog!
>

Ah, but what he posted at the top *this* time was a question, not an answer.





------------------------------

Date: Tue, 28 Sep 1999 15:32:57 -0400
From: "Robert W. Byrd" <tech@tburg.net>
Subject: Re: gcos/gecos
Message-Id: <37F117E9.2BCEF3A@tburg.net>

Peter Icaza wrote:
> 
> hi,
> 
> on page 163 of the llama book it mentions the gcos field of the passwd file.
> i have seen this refered to as gecos as well.  clearly it refers to the
> comment filed of the passwd file, but what does g[e]?cos stand for?  nothing
> returned my man -k, kornshell, UNIX in a nutshell, the UNIX programming env,
> the camel book, mastering regex's etc.

GECOS = General Electric Computer Operating System.

 .rob.

-- 
Robert W. Byrd | Completely Computer Friendly
tech@tburg.net | 67-B Oxford St., Tillsonburg, ON CA N4G 2G3
------------------------------------------------------------
Nothing clever here          }|{         ereh revelc gnihtoN


------------------------------

Date: Tue, 28 Sep 1999 13:03:59 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: gcos/gecos
Message-Id: <Pine.GSO.4.10.9909281300450.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, Peter Icaza wrote:

> on page 163 of the llama book it mentions the gcos field of the passwd
> file. i have seen this refered to as gecos as well.  clearly it refers
> to the comment filed of the passwd file, but what does g[e]?cos stand
> for?

It's called this for historical reasons. Only the hopelessly curious would
care that some say it stood for General Electric Common Operating System.
I am not sufficiently ancient to confirm or deny this rumor.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 28 Sep 1999 12:56:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: gcos/gecos
Message-Id: <MPG.125abd4eeb085e36989fef@nntp.hpl.hp.com>

In article <7sr338$nfu$1@pike.uhc.com> on Tue, 28 Sep 1999 14:58:11 -
0400, Peter Icaza <picaza@chsi.com> says...
> on page 163 of the llama book it mentions the gcos field of the passwd file.
> i have seen this refered to as gecos as well.  clearly it refers to the
> comment filed of the passwd file, but what does g[e]?cos stand for?  nothing
> returned my man -k, kornshell, UNIX in a nutshell, the UNIX programming env,
> the camel book, mastering regex's etc.

General (Electric) Comprehensive? Operating System

Offered in the late '60s by GE for their 635 and 645 computers as an 
alternative to the MULTICS system under development by GE, MIT and Bell 
Labs.  GE sold their computer business to Honeywell Information Systems, 
Inc., who continued to develop GCOS on the Honeywell 66/60 and others.  
These were all 36-bit-word computers.

Unix (described then as the UNIX(TM) Operating System) was developed 
simultaneously at Bell Labs as a manageable, scalable, portable 
alternative to the pachydermous Multics, on 16-bit DEC PDP-7 computers.  
I implemented a GCOS shell and ported many Unix commands, and gave a 
paper titled "The Best of UNIX on GCOS" at the Honeywell Large Systems 
Users' Association meeting in 1978.

Any and all 'facts' above are subject to the vagaries of decades of 
neuron decay.  The only reference material immediately at hand is 
"User's Guide to the Programming Language B on the Honeywell 66/60", 
1978.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 28 Sep 1999 16:37:49 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: How to append an extension to a value in a variable
Message-Id: <a1hfkeu602.fsf@cyclone.jprc.com>

Tom Phoenix <rootbeer@redcat.com> writes:

> On Tue, 28 Sep 1999, David wrote:
> 
> > I need to add an extension (.wav) to a scaler variable value.
> 
> If I were giving you a fish, I'd say "period". As I'd prefer to teach you
> to fish, I'll say "the perlop manpage". Cheers!

Oh, but if only they asked how to report warnings from the point
of view of the caller...

---Jason
-- 
"Category #5: Puns; Actually, puns aren't funny" 
 - http://www.rinkworks.com/funny/


------------------------------

Date: Tue, 28 Sep 1999 12:03:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to save a file as binary?
Message-Id: <MPG.125ab0c01a36ec7d989fee@nntp.hpl.hp.com>

In article <7sr0ol$43r0@yuma.ACNS.ColoState.EDU> on Tue, 28 Sep 1999 
12:19:03 -0600, Tim Renner <loc@holly.colostate.edu> says...
> Offhand, I can't get perl to just load in a .GIF and save an exact copy of
> it... it cooks out after saving 1k (on a 39k GIF ;)  It seems like it's
> loading or saving as an ASCII file and I'd like to be able to do it in
> binary.

perldoc -f binmode

It would be *so* nice if the educators and writers told people always to 
use *binmode* before reading or writing a binary file, just as they tell 
them to always check the result of 'open()'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 28 Sep 1999 22:20:48 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How to save a file as binary?
Message-Id: <Pine.HPP.3.95a.990928220853.22229D-100000@hpplus01.cern.ch>

On Tue, 28 Sep 1999, Larry Rosler wrote:

> It would be *so* nice if the educators and writers told people always to 
> use *binmode* before reading or writing a binary file,

The trouble is that the majority of commentators on this topic appear to
be unix bigots, and if they mention binmode at all, it's usually only to
carp that you wouldn't need it with a "real" operating system.

The idea of systematically putting it in, in the interests of
portability, even when it "does nothing", somehow doesn't seem to appeal
to them.  I've seen educational material that explicitly recommends
leaving it out when using unix-oid OSes.

Which is a pity, in the interests of portability.  IMHO.

Don't mind me: I have no objection to unix-oid OSes, quite the contrary;
but I also have to use other operating systems too (and glorified task
monitors lurking behind a windowing UI, if you take my drift).  Anything
that can minimise the confusion is to be applauded. 

Now I suppose I'd better get down behind the parapet before the
brickbats start getting hurled.  ;-)



------------------------------

Date: Tue, 28 Sep 1999 14:32:42 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: I can't see the error (short bit of code)
Message-Id: <37F117DA.45AD37D9@texas.net>

Daniel Vesma wrote:
> 
> Hi,
> 
> I've been looking at this code for ages, and I can't see what's wrong with
> it.
> 
>    $ShopID = param("ShopID") . "rem";
>    $Filename = param("Filename");
>    open(Products, "products.txt");
> 
>    while(<Products>)
>    {
>       $data = $data . $_;
>     }
> 
>     close(Products);
> 
>     $data =~ s/$ShopID/$Filename/g;
> 
>     open(Products, ">products.txt");
>     print Products $data;
>     close(Products);
> 
> It should open products.txt replace every instance of $ShopID (including the
> "rem") and replace it with $Filename. $ShopID is a string of numbers passed
> from the user, and filename is also provided by the user.
> 
> The problem is, it doesn't appear to do anything. The file is not changed.
> Any idea why?

There are many possibilities.

Your best bet is to read 'The Idiot's Guide to Solving Perl CGI
Problems' by Tom Christiansen.

Once you've tried all the suggestions provided in that document, your
problems will most likely be solved.  But if you're still having
problems, feel free to come back.

- Tom


------------------------------

Date: Tue, 28 Sep 1999 14:34:18 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: I can't see the error (short bit of code)
Message-Id: <37F1183A.BAA30938@texas.net>

Tom Briles wrote:
> 
> Your best bet is to read 'The Idiot's Guide to Solving Perl CGI
> Problems' by Tom Christiansen.
> 

That's available at:

http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html

as well as other places, I'm sure.

- Tom


------------------------------

Date: Tue, 28 Sep 1999 13:26:51 -0700
From: mikej <mikej@1185design.com>
Subject: kill extra white space in a variable
Message-Id: <37F12473.99DEB73@1185design.com>

Hi all,

I have a piece of code which gives me an element of an array, like this:

$myimage[$arrayposition]

I get the array from a flat text file, and so far there is only one item
that should be in the array, an image name called "one.gif".

The weird thing is that when the script returns the value for
$myimage[$arrayposition], which in this case would be
$myimage[0], there is a space that gets put on the end of the variable,
so when I try to add an extension onto the name such as ".data", it
gives me the value:

one.gif .data

instead of what I need, which is:

one.gif.data

I dont know why its giving me the space. The flat file doesnt seem to
have any white space after the name. Any ideas on what is causing this
phantom space? Thanks.

mike



------------------------------

Date: Tue, 28 Sep 1999 13:37:20 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: kill extra white space in a variable
Message-Id: <37F12700.63CE9119@cisco.com>

[ mikej wrote:

> I get the array from a flat text file, and so far there is only one item
> that should be in the array, an image name called "one.gif".

If you post the code for getting the array from the flat file maybe someone
will
figure out how that extra space is getting into the variable.
--



------------------------------

Date: Tue, 28 Sep 1999 13:59:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: kill extra white space in a variable
Message-Id: <Pine.GSO.4.10.9909281357280.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, mikej wrote:

> Any ideas on what is causing this phantom space?

Since I can't see your code, I could only make a guess. Perhaps you should
cut your code down to a small example, and post that. Ideally, it should
be no more than, say, half a dozen lines of stand-alone code which others
could run to see what you're seeing. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 28 Sep 1999 14:53:58 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: LOST NEWBIE
Message-Id: <37F11CD6.FA1385C3@ti.com>

I need to get by current working dir, cd to another dir, read the dir, find
the latest file, the file will not have an ext or it will be 0..999. Then read
the file.  Any ideas would be appreciated.

Thanks,

Jerry



------------------------------

Date: Tue, 28 Sep 1999 13:44:30 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: LOST NEWBIE
Message-Id: <Pine.GSO.4.10.9909281343150.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, Jerry Preston wrote:

> Subject: LOST NEWBIE

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I need to get by current working dir, cd to another dir, read the dir,
> find the latest file, the file will not have an ext or it will be
> 0..999. Then read the file.  Any ideas would be appreciated.

Perl should be able to do this. Reading some of the books mentioned in the
perlbook manpage would be a good start. If you get stuck, be sure to tell
us at which point you've gotten stuck. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 28 Sep 1999 20:21:42 GMT
From: Brett.A.Hunsaker@usace.army.mil
Subject: Re: Match and escape processing
Message-Id: <7sr809$nt6$1@nnrp1.deja.com>

Ok, I'm awake now.  My model of how m// worked had it interpolating the
variable and then treating it as a literal rather than a regular
expression itself.  Duh!  I didn't know about the -Dr switch -- thanks
for the lesson!

In article <uu2og3qjg.fsf@prodigy.net>,
  rabm@prodigy.net wrote:
> >>>>> "Brett" == Brett A Hunsaker <Brett.A.Hunsaker@usace.army.mil>
writes:
>
>     Brett> A simple question - I would think the following statement
would always
>     Brett> be true:
>
>     Brett> $xyz =~ m/$xyz/
>
>     Brett> But if the string contains a backslash, it returns false.
Can someone
>     Brett> explain what is happening?
>
>     Brett> Thanks.
>
>     Brett> $xyz = 'C:\\DOSFILE.TXT';
>     Brett> print "Hi!\n" if ( $xyz =~ m/$xyz/ );
>
> This doesn't seem so simple: I ran it with -Dr (regular expression
> debugging) and it looks like the slash is doing funky things. The
parser
> seems to be looking at part of the variable.
>
> E:\howto>perl -Dr -e "$xyz = 'C:\\DOSFILE.TXT'; print qq(Hi!\n) if
$xyz =~ \
> /${xyz}/; print qq(DEBUG: $xyz\n)
>
> Omitting $` $& $' support.
>
> EXECUTING...
>
> Compiling REx `C:\DOSFILE.TXT'
> size 10 first at 1
> rarest char F at 2
>    1: EXACT <C:--¦,?>(3)
>    3: NDIGIT(4)
>    4: EXACT <OSFILE--¦??>(7)
>    7: REG_ANY(8)
>    8: EXACT <TXT-¦>(10)
>   10: END(0)
> anchored `OSFILE' at 3 (checking anchored) minlen 13
> Guessing start of match, REx `C:\DOSFILE.TXT' against `C:
\DOSFILE.TXT'...
> Found anchored substr `OSFILE' at offset 4...
> Guessed: match at offset 1
> Matching REx `C:\DOSFILE.TXT' against `:\DOSFILE.TXT'
>   Setting an EVAL scope, savestack=3
>    1 <C> <:\DOSFILE.T>    |  1:  EXACT <C:--¦,?>
> DEBUG: C:\DOSFILE.TXT
> Freeing REx: `C:\DOSFILE.TXT'
> .
> $xyz = 'C:\\DOSFILE.TXT';
>
> E:\howto>perl -Dr -e "$xyz = 'C:/DOSFILE.TXT'; print qq(Hi!\n) if
$xyz =~ \
> /${xyz}/; print qq(DEBUG: $xyz\n);
> Omitting $` $& $' support.
>
> EXECUTING...
>
> Compiling REx `C:/DOSFILE.TXT'
> size 8 first at 1
> rarest char F at 6
>    1: EXACT <C:/DOSFILE--¦??>(5)
>    5: REG_ANY(6)
>    6: EXACT <TXT-¦>(8)
>    8: END(0)
> anchored `C:/DOSFILE' at 0 (checking anchored) minlen 14
> Guessing start of match, REx `C:/DOSFILE.TXT' against
`C:/DOSFILE.TXT'...
> Found anchored substr `C:/DOSFILE' at offset 0...
> Guessed: match at offset 0
> Matching REx `C:/DOSFILE.TXT' against `C:/DOSFILE.TXT'
>   Setting an EVAL scope, savestack=3
>    0 <> <C:/DOSFILE.T>    |  1:  EXACT <C:/DOSFILE--¦??>
>   10 </DOSFILE> <.TXT>    |  5:  REG_ANY
>   11 </DOSFILE.> <TXT>    |  6:  EXACT <TXT-¦>
>   14 </DOSFILE.TXT> <>    |  8:  END
> Hi!
> DEBUG: C:/DOSFILE.TXT
> Freeing REx: `C:/DOSFILE.TXT'
>
>     Brett> Sent via Deja.com http://www.deja.com/
>     Brett> Before you buy.
>
> --
> Vinny Murphy
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 28 Sep 1999 19:25:49 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: New book: Automating Windows With Perl
Message-Id: <1D8I3.1604$w32.123191@typ11.nn.bcandid.com>

In article <UM6I3.247$hs.15796@monger.newsread.com>,
Scott McMahan <scott@aravis.softbase.com> wrote:
>I don't want to blatantly advertise, but I want to get the word out.
>There hasn't been much buzz about this book since its release Sept. 1,
>so I wanted to let the Perl community know it had been published.
>I have a new book called Automating Windows With Perl.

OK; here are my impressions from the web site:
- the author likes bright colors;
- the author is probably mostly familiar with Microsoft Windows -- not
  in itself an indictment of his competence -- because he refers to "the
  Microsoft concept of Automation" on the web page;
- the author claims Randal reviewed a draft of the book, which is an excellent
  sign, but he misspells Randal's name :)
- I tried to download "Source Code From The Book" from the web site, and ended
  up downloading a Delphi-built executable without source called "Run
  Control 98".  Then I noticed he said the Source Code From The Book was not
  yet on the web page.
- the publisher is "R&D Books", rdbooks.com, which appears to be a subsidiary
  of Miller Freeman books.  I've never heard of them before, so I have no
  idea of their quality or lack thereof.  (Not that it's all that relevant;
  I've occasionally seen good books from terrible presses.)

I'll read the book -- or at least some of it -- when my bookstore gets
a copy and post my impressions.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 28 1999
43 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Tue, 28 Sep 1999 20:50:44 GMT
From: rthompson4450@my-deja.com
Subject: Perl Question
Message-Id: <7sr9mv$p7h$1@nnrp1.deja.com>

Hello - I have a perl question for  comp.lang.perl newsgroup.

I have a string varible called $test_proj_n_page =
gridSearch/pgHomeDefault?

I am trying to do the following:

1) drop the ? from the end of the line.
2) split the remaining 'gridSearch/pgHomeDefault' into
    two variables containing the following:

   $test_projectname = gridSearch
   $test_pagename    = pgHomeDefault

I have the O'Reilly book 'Prgramming Perl' and I have not run across a
way to do this
or I am overlooking the answer to it. If you have a suggestion on how to
do this
I would greatly appreciate it.

Rob Thompson


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 28 Sep 1999 19:31:08 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Piping a file to STDIN of a Perl function
Message-Id: <0I8I3.1607$w32.123666@typ11.nn.bcandid.com>

In article <938540885.16643.0.nnrp-03.9e98e5bc@news.demon.co.uk>,
Clyde Ingram <cingram-at-pjocs-dot-demon-dot-co-dot-uk> wrote:
>Thats fine if I invoke the Perl function from a Perl script which is itself
>called from the shell like:
>
>    script.pl textfile
>
>because the contents of textfile are supplied to STDIN of the perl script,
>which passes this on to STDIN of the Perl function.

No, they are supplied to the null filehandle of the perl script, aka
ARGV.  If you do script.pl < textfile then you get the textfile on STDIN.

>But what I want to pipe a file into a Perl function, form the middle of a
>Perl script?  Surely this is easy?

If you want to attach it to STDIN, you can say

open STDIN, "<filename" or die "filename: open: $!";

You might want to save STDIN's current value in another filehandle with
<& first, so you can restore it when you return.

>Or is this not the Perl way?  i.e., would I be better to modify my function
>to explicitly open the textfile.

It's better to pass the filename or an open filehandle to the routine
-- easier to understand and less errorprone.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 28 1999
43 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Tue, 28 Sep 1999 16:09:45 -0400
From: David Wozmak <dwozmak@rational.com>
Subject: Re: Please compare and contrast C and Perl.
Message-Id: <37F12089.17C2B0B8@rational.com>



Neil wrote:
> 
> Please compare and contrast the two languages.
> 
> I am aware that Larry Wall wrote Perl in C.
> 
> Thanks
> 
> --
> 
> Neil


1) C is a full-featured language in which it is very easy to hang one's
self.
1a) Perl is a full-featured language in which it is very easy to hang
one's self.

2) C Can either be written in an object-oriented style, or not.
2a) Perl can either be written in an object-oriented style, or not.

3) A runnable C program is a compiled binary executable.
3a) A runnable Perl program is {$_="an interpreted command list";}

Does that help? 
:-)

dwoz


------------------------------

Date: Tue, 28 Sep 1999 19:29:25 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Problem with eval and lexical scoping
Message-Id: <FIsBH1.1Ds@news.boeing.com>

In article <37eff311.0@news.victoria.tc.ca>,
Cody Jones <ua025@vtn1.victoria.tc.ca> wrote:
>According to the perlsub man page, "An eval()... can see the
>lexical variables of the scope it is being evaluated in so long as the
>names aren't hidden by declarations within the eval() itself."
>
>However, the following program fails to run:
>  
>  #!/usr/bin/perl -w
>  
>  use strict;
>  
>  my $outer_eval = '{ my $x = 1; eval \'print $x\'; }';
>  eval $outer_eval;
>
>It fails with the error "Global symbol "x" requires explicit package name
>at (eval 2) line 1."  I am using 5.004_04.  The second eval is being
>executed in the same scope as "my $x = 1", so why can't it see $x?
>

Works in 5.005_03 as previously noted, but with 5.004_04
the following slight change works too:

   my $outer_eval = '{ my $x = 1; eval "print $x" }';

--
Charles DeRykus


------------------------------

Date: Tue, 28 Sep 1999 16:34:54 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: Question
Message-Id: <7sr90a$qt4$1@newssvr04-int.news.prodigy.com>

This is the part of the script that shows the cars five at a time.
Everything works except the next link. If you have time to look it over, can
you and see if you can find out what the problem is. Thanks in advance for
any help.

$MaxDisplay = 5;

%model = ("RS" => "rs",
                   "Iroc-Z" => "iroc-z",
                   "Z28" => "z28",
                   "Berlinetta" => "berlinetta");

open (ENTRIES, "gallerydata.file") || die ("Couldn't open camaro gallery
entries file.");
         @entries = <ENTRIES>;
close (ENTRIES);

$Total = @entries;
$LastArrayNumber = $Total - 1;
if ($Total < $MaxDisplay) {
 $MaxDisplay = $Total;
}

@sortentries = (@entries);
$TotalEntries = @sortentries;

if ($FORM{'startwith'} eq "") {
$startarraynum = "0";
$start = "1";
}  else {
$startarraynum = $in{'startwith'};
$start = $startarraynum + 1;
}
$MaxDisplay--;

$endarraynum = $startarraynum + $MaxDisplay;
$end = $endarraynum + 1;
if ($end > $Total) {
$endarraynum = $Total - 1;
$end = $Total;
}
$startwith = $endarraynum + 1;


if ($startwith < $Total) {
 $ContinueWording = qq(<img src=/image/blank.jpg" height=10 width=1><br><A
HREF="gallerysearch.cgi?model=$FORM{'model'}\&startwith=$startwith">Next</A>
);
}  else {
 $ContinueWording = "";
}

for $thisentry(@finalarray)  {
@entryline = split(/\|\|/, $thisentry);
chomp($entryline[6]);

if ($FORM{'model'} eq $entryline[1]) {

print <<GUTS;
<tr><td align="center">
<a
href="http://www.3gc.net/cgi-bin/scripts/gallerysearch.cgi?action=desc\&mode
l=$FORM{'model'}\&year=$entryline[2]\&num=$entryline[3]">
<img
src="/gallery/$model{$FORM{'model'}}/images/$entryline[2]$entryline[3]\small
 .jpg" height="150" width="$entryline[4]" border="0" alt="Click for larger
image and description"></a>
</td></tr>
<tr><td align="center">
<a
href="http://www.3gc.net/cgi-bin/scripts/gallerysearch.cgi?action=desc\&mode
l=$FORM{'model'}\&year=$entryline[2]\&num=$entryline[3]">
19$entryline[2] $entryline[1]</a>
</td></tr>
GUTS
;
}
}




------------------------------

Date: Tue, 28 Sep 1999 21:06:45 +0200
From: "Thorsten Muschler" <thorsten.muschler@uni-essen.de>
Subject: question: cgi-script on server a database on server b
Message-Id: <7sr3k9$ihl$1@fu-berlin.de>

hi!

a have got a small problem:

a have web-space on server a and a
cgi-directory on server b.

my cgi-script on server b reads and writes a
txt file on server a.

the cgi is written like the txt file
is on the same server in the same directory.

now i have to modify it but don´t know how:

here is the relevant part of the script:

$fields = 7;                       # Number of fields in each record
$filename = "urls.txt";      # The database text file
$results = 1000;               # maximum number of results to display


for example the urls.txt file should be  stored
on the server http://www.myserver.de/datebase/urls.txt

how do i have to modify and how?

kind regards

thorsten muschler




------------------------------

Date: Tue, 28 Sep 1999 17:04:09 -0400
From: David Wozmak <dwozmak@rational.com>
Subject: Re: Simple Mail Transfer Protocol ... Not So Simple!
Message-Id: <37F12D49.26652799@rational.com>

Majid:

You've got to check the form that is sending the data to the script.  In
the HTML, did you name the field for Account Name "AcctName", exactly,
upper and lower case, exact?  This is a common error... your script is
READING a form field named "AcctName" and your form is SENDING a field
named "accountname".

dwoz



Majid Sharif wrote:
> 
> Dear helper,
> 
> Can someone Please help!
> Thanks

This is where the problem is:

> 
>     my $EmailSubject = $Cgi->param('AcctName'). " Account Product Approval";
>     my $EmailTitle = "The following product items for the " .
> $Cgi->param('AcctName'). " Account have been Approved:\n\n";


------------------------------

Date: Tue, 28 Sep 1999 20:57:52 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Splitting into two-character array
Message-Id: <rv2augbc3i565@corp.supernews.com>

Greg Bacon (gbacon@itsc.uah.edu) wrote:
: In article <378D264A.CD986767@email.com>,
: 	Jordan Hiller <hiller@email.com> writes:
: : But is there a quick-and-dirty way to split by every two characters
: : instead of one? For example @array would equal ('ab', 'cd') instead
: : of ('a', 'b', 'c', 'd'). 
: 
:     @array = $str =~ /(..?)/g;

Probably want to add the 's' match modifier to make . match \n.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


------------------------------

Date: Tue, 28 Sep 1999 19:36:03 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: threads??
Message-Id: <DM8I3.1611$w32.124316@typ11.nn.bcandid.com>

In article <37F103F9.9843EDE6@americasm01.nt.com>,
Marshall Culpepper  <marshalc@americasm01.nt.com> wrote:
>$done = 0;
>
>$SIG{'CHLD"} = {$done = 1}

This is wrong in two ways.  One is that it contains an unterminated
''-delimited string with a " in it, but perl would have told you that
if you had tested it like you said you did.  The other is that when you
run it, it executes the block, which means executing the statement
{$done = 1}, which sets $done to 1.  Then it takes the return value of
that statement (1) and returns that as the value of the block.  Then it
assigns that to $SIG{'CHLD'}, which isn't going to do you any good; 1
is generally one of the special signal things like SIG_IGN or SIG_DFL.

You want sub {$done = 1}, I think.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 28 1999
43 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Tue, 28 Sep 1999 19:45:12 GMT
From: fybar@junctionnet.com (Trevor Osatchuk)
Subject: Re: Unix and Perl script
Message-Id: <37f11b4b.160763115@news.telusplanet.net>

I have solved the problem that I was having by passing the list of
files that I wanted backed up to tar in as a list  file as opposed to
the convoluted series of finds that I had used previously.  Thanks for
all of the input!!

On Tue, 14 Sep 1999 23:59:52 GMT, fybar@junctionnet.com (Trevor
Osatchuk) wrote:

>I am trying to write a backup script for a Unix machine using Perl as
>I can only pass a finite number of filenames to a tar at a time.  The
>Unix command that I want to use is:
>
>find ./usr -name "bin" -print > files.list
>
>The best I can come up with is this:
>
>open (FILES_LIST,"|find ./usr -name "bin" -print >files.list");
>
>I have used the same type of command with an ls, but I cannot get the
>syntax right for the find.
>
>trev



------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 933
*************************************


home help back first fref pref prev next nref lref last post