[11764] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5364 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 18:07:22 1999

Date: Mon, 12 Apr 99 15:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 12 Apr 1999     Volume: 8 Number: 5364

Today's topics:
    Re: CGI embedded in html (Steve Linberg)
        Examples of slow regexes? (was: Re: Perl regexps compar (Bart Lateur)
    Re: Executing perl code from separate files (Steve Linberg)
    Re: Getting long filename from 8.3 filename? <All@n.due.net>
        guestbook with CGI script <vkaasa@c2i.net>
        guestbook with CGI script <vkaasa@c2i.net>
    Re: Hash symbol '%' a stylized what? <jason.holland@dial.pipex.com>
    Re: Hash symbol '%' a stylized what? (Larry Rosler)
        how can i send perl -c output to a file instead of STDE <smith.will@epa.gov>
    Re: how can i send perl -c output to a file instead of  <tchrist@mox.perl.com>
    Re: how can i send perl -c output to a file instead of  (Bart Lateur)
    Re: How do I delete text in a file? (Tad McClellan)
    Re: How do I simply delete a file in CGI? (Daniel Beckham)
    Re: How do I simply delete a file in CGI? (Larry Rosler)
        looking for a particular script.... <rlally1@nycap.rr.com>
    Re: looking for a particular script.... (Larry Rosler)
        Multipel dimension (Claes Bjorklund)
        pattern matching bing-du@tamu.edu
    Re: pattern matching <fuchin@mail.nwos.lucent.com>
    Re: Problems connecting to Oracle 8 from Perl using DBI (Bill Morgan)
    Re: Where I Can Learn About Pearl And CGI Scripting? (Tad McClellan)
        Y2k issues with perl DBI? <kkwiatek@nist.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 12 Apr 1999 17:37:08 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: CGI embedded in html
Message-Id: <linberg-1204991737080001@ltl1.literacy.upenn.edu>

In article <37125D86.F3A2C70A@dial.pipex.com>, Jason Holland
<jason.holland@dial.pipex.com> wrote:

> What's the "gif trick"? Never heard of it...

It's a great way to piss off system administrators and get your account
revoked.  :)  I'm not sure that broadcasting it here is a great idea.  Not
all servers are vulnerable to it, as well.  I'm sure a quick deja news
search would turn up the info, maybe that should be the bar people need to
jump over to find out about it.

Saving the world one server at a time,

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Mon, 12 Apr 1999 21:03:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Examples of slow regexes? (was: Re: Perl regexps compared to Python regexps)
Message-Id: <37125e8e.946742@news.skynet.be>

David Cassell wrote:

>... and Friedl's tests suggest that well-written Perl regexes
>should be much faster [although badly-written Perl regexes can be pain-
>fully slow - a potential problem in any NFA regex engine].

I have, until now, never encountered a Perl regex that is "painfully
slow", or not even "rather on the slow side". Can anybody please give an
example of such a beast, point out the reason for it's slowness, and
possibly even recipes on what to avoid?

	Bart.


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

Date: Mon, 12 Apr 1999 17:33:09 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Executing perl code from separate files
Message-Id: <linberg-1204991733090001@ltl1.literacy.upenn.edu>

In article <371202FE.C32B3E6B@rocketmail.com>, Kubla Khan
<kubla_khan@rocketmail.com> wrote:

> Does that mean there is a way I can eval a file without opening a file handle
> and reading it in?  If so, how?

Whoops, I meant "do".  You can use this to execute a file of perl commands
- similar to "require."  See the documentation of these functions for
complete info.

do 'foo.pl';    # execute perl commands in foo.pl

It's probably safer to explicitly open the file, read the contents,
examine them, and do an eval if you're comfortable with what's there. 
Even safer would be to tokenize your verbs so that people couldn't plug
malicious stuff in your foo.pl that you would go ahead and execute
blindly, but restrict them to a subset of actions.  Fill in a hash of
actions, for example, and execute them one by one as you decide they're
OK.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Mon, 12 Apr 1999 21:58:08 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: Getting long filename from 8.3 filename?
Message-Id: <Q%tQ2.6892$gr5.4361@news.rdc1.ct.home.com>

Allan M. Due <Allan@due.net> wrote in message
news:7etf4v$leh$1@camel29.mindspring.com...
: hgelman@ntia.doc.gov wrote in message <7et9kl$q3$1@nnrp1.dejanews.com>...
: :
: :I have a short perl script that will run under Windows, and I've made it
: into
: :an executable through perl2exe.  Ideally, I'd like to drag a file onto
the
: :executable, and then process that file in the perl script.
Unfortunately,
: :the Windows Explorer is stupidly passing the 8.3 filename (e.g.,
: :"this is a long file.txt" becomes "thisis~1.txt").  That's useless to me,
: :since I actually need to extract info from the filename.  I did a
Dejanews
: :search and found other people who had this problem, but the solutions
: offered
: :were always Visual Basic or Visual C.  Does anyone know of a way I can
get
: :the full, long filename from ActiveState Perl?
: :
: :I don't mind if it's somewhat ugly -- a small executable written in any
: :language which would let me drag a file onto it and then it would run my
: :program with the correct filename would be acceptable.
:
: Here is a snippet I posted a while back you can use as an example.  If you
: make the following a bat file using pl2bat then you can drag a long file
: name onto it and it writes the short and the long file names into a file
: named temp.dat in the original directory.  The idea should work for you.
: For your actual application, @files should only have one file name in it
so
: once you check to make sure that is the case you can manipulate it as you
: like.
:
:
: #!/usr/local/bin/perl -w
: use strict;
: use Win32;
: use File::Basename;
: my $fullname = shift @ARGV;
: my ($name,$path) = fileparse($fullname);
: opendir (DIR,"$path") or warn "$!\n";
: my @files = grep {Win32::GetShortPathName("$path$_") eq $fullname}
: readdir(DIR);
: close (DIR);
: open (FH,">${path}temp.dat") or warn "$!\n";
: print FH "The shortened name of the file is [$name] which was part of
: [$fullname] with path $path\n";
: print FH "The matched long file names [there really should only be one]
are:
: @files\n";
: close (FH);


Ok, I messed with this a bit because I found that Windoze\activestate have
produced an annoying little quirk with GetShortPathName.  It returns all
caps for the file name but can leave the drive letter lower case.  Anyway,
here are a couple of subs that will deal with finding the long file name for
a short one.  The first is more conservative, the second quicker if you are
confident that there is only one way that your file name can match (I can't
think of a way there will be more than one match but that is not to say it
couldn't happen).

--------------8<----------------------
 #!/usr/local/bin/perl -w
use strict;
use Win32;
use File::Basename;

sub get_long_name {
    my $fullname = shift @_;
    my ($name,$path) = fileparse($fullname);
    opendir (DIR,"$path") or warn "$!\n";
    my @files = grep {uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname)} readdir(DIR);
    close(DIR);
    if ($#files == 0) {return $files[0]}
    else {warn "Error finding the long file name for $name: ",$#files > 0 ?
'too many ' : 'no ','files were found.'; return ()}
}


sub get_long_name2 {
    my $found;
    my $fullname = shift @_;
    my ($name,$path) = fileparse($fullname);
    opendir (DIR,"$path") or warn "$!\n";
    my @files = readdir (DIR);
    close(DIR);
    foreach (@files) {
        $found = $_ and last if uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname);
    }
    if ($found) {return $found;}
    else {warn "Error finding the long file name for $name\n"; return ()}
}

#my $out = get_long_name('c:\EDIT3P~1.BAK');
my $out = get_long_name(shift @ARGV) if @ARGV;
-----------------------

AmD

--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
'Help save the world!'
   Larry Wall in README





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

Date: Tue, 13 Apr 1999 00:16:15 +0200
From: "Vegard Kesa" <vkaasa@c2i.net>
Subject: guestbook with CGI script
Message-Id: <7etq4e$cot$1@romeo.dax.net>

I'm trying to make a guestbook in perl. I've been using the book"CGI
Programming on the world wide web, by O'Reilly and Associates. (the one with
the mouse on the front).

I get a server error when I try to run the script. Does anyone know what's
wrong?

The associated HTML page is located at
http://home.c2i.net/vkaasa/guestbook.html

The code for the script is here:



#!C:/perl/bin/perl

$webmaster = "u940129\@studbo\.hit\.no";
$method = $ENV{'REQUEST_METHOD'};
$script = $ENV{'SCRIPT_NAME'};
$query  = $ENV{'QUERY_STRING'};

$document_root = "C:/progra~1/apache~1/apache/htdocs";
$guest_file = "guestbook.html";
$full_path = $document_root . $guest_file;
$exclusive_lock = 2;
$unlock = 8;

	if ($method eq "GET") {
		if ($query eq "add"){


$date_time = $get_date_time();

$MIME_header ("text/html", "My guestbook");

print <<End_Of_Guestbook_Form;

This is a guestbook CGI script that allows people to leave a
message for others to see. Please enter all requested information,
<B>and</B> if you have a www server, enter the adress so a hypertext
link can be displayed.
<P>
The current time is: $date_time
<HR>
<FORM METHOD="POST">
<PRE>
	<EM>Name:</EM>  	<INPUT TYPE="text" NAME="name" SIZE="40">
	<P>
	<EM>Email adress:</EM>	<INPUT TYPE="text" NAME="from" SIZE="40">
	<P>
	<EM>Homepage:</EM>	<INPUT TYPE="text" NAME="www" SIZE="40">
	</PRE>
	<EM>Please enter the information that you'd like to add</EM><BR>
	<TEXTAREA ROWS=3 COLS=60 NAME="comments">
	</TEXTAREA>
	<P>
	<INPUT TYPE="SUBMIT" VALUE="Add to guestbook">
	<INPUT TYPE="RESET" VALUE="Clear Information"><BR>
	<P>
</FORM>
<HR>

End_Of_Guestbook_Form

	} else{
	if ( open(GUESTBOOK, "<" . $full_path )) {
		flock (GUESTBOOK, $exclusive_lock);
	}
	&MIME_header ("text/html", Here is my guestbook");

	while (<GUESTBOOK>) {
		print;
	}

	flock (GUESTBOOK, $unlock);
	close (GUESTBOOK);

	} else {
		&return_error (500, "Guestbook File Error", "Cannot read from the
guestbook file [$full_path].");
	}

}

}elseif ($method eq "POST"){
	if ( open (GUESTBOOK, ">>" .$full_path) ) {
		flock (GUESTBOOK, $exclusive_lock);

		$date_time = &get_date_time();
		$parse_form_data (*FORM);

		$FORM{'name'} = "Anonymous User"	if !$FORM{'name'};
		$FORM{'from'} = $ENV{'REMOTE_HOST'}	if !$FORM{'from'};
		$FORM{'comments'} =~ s/\n/<BR>/g;

		print GUESTBOOK <<End_Of_Write;

<P>
<B>$date_time:</B><BR>
Message from <EM>$FORM{'name'}</EM> at <EM>$FORM{'from'}</EM>:
<P>
$FORM{'comments'}

End_Of_Write

	if ($FORM{'www'}) {
		print GUESTBOOK <<End_Of_Web_Adress;


<P>
$FORM{'name'}can also be reached at:
<A HREF="$FORM{'www'}">$FORM{'WWW'}</A>

End_of_Web_Adress

	}

	print GUESTBOOK "<P><HR>";

	flock (GUESTBOOK,$unlock);
	close(GUESTBOOK);

&MIME_header ("text/html", "Thank You!");

print <<End_Of_Thanks;

Thanks for signing my guestbook. If you would like to view it, click <A
HREF="$guest_file">here</A>
(actual guestbook HTML file), or <A HREF="$script">here</A>(guestbook script
without a query).

End_Of_Thanks

}else {
	&return_error (500, "Guestbook file error", "Cannot write to the guestbook
file [$full_path].");

	}

}else {

	&return_error (500, "Server Error", "Server uses unsupported method");
}
exit(0);


sub MIME_header
{
	local ($mime_type, $title_string, $header) = @_;

	if (!$header) {
		$header = $title_string;
	}

	print "Content-type: ", $mime_type, "\n\n";
	print "<HTML>, "\n";
	print "<HEAD>,<TITLE>, $title_string, "</TITLE></HEAD>", "\n";
	print "<BODY>", "\n";
	print "<H1>", $header, "</H1>";
	print "<HR>";
}

sub get_date_time
{
	local ($months, $weekdays, $ampm, $time_string);
	$months
="January/February/March/April/May/June/July/August/September/October/Novemb
er/December";
	$weekdays = "Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
Satureday";

	local ($sec, $min, $hour, $day, $nmonth, $year, $wday, $yday, $isdst) =
localtime(time);

	if ($hour >12){

		$hour -= 12;
		$ampm = "pm";

	} else {

		$ampm = "am";
	}

	if ($hour == 0) {
		$hour = 12;
	}

	$year += 1900;

	$week = (split("/", $weekdays))[$wday];
	$month = (split("/", $months))[$nmonth];
	$time_string = sprintf("%s, %s %s, %s - %02d:%o2d:%o2d %s",
				$week, $month, $day, $year,
				$hour, $min, $sec, $ampm);

	return ($time_string);
}

sub parse_form_data
{
	local (*FORM_DATA) =@_;
	local ($request_method, $post_info, @key_value_pairs,
		$key_value, $key, $value);

	read (STDIN, $post_info, $ENV{'CONTENT_LENGTH'});

	@key_value_pairs = split (/&/, $post_info);

	foreach $key_value(@key_value_pairs){
		($key, $value) = split (/=/, $key_value);
		$value =~ tr/+/ /;
		$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;

		if (defined($FORM_DATA{$key})) {
			$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
		}else {
			$FORM_DATA{$key} = $value;
		}
	}
}








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

Date: Tue, 13 Apr 1999 00:17:34 +0200
From: "Vegard Kesa" <vkaasa@c2i.net>
Subject: guestbook with CGI script
Message-Id: <7etq6q$cu3$1@romeo.dax.net>

I'm trying to make a guestbook in perl. I've been using the book"CGI
Programming on the world wide web, by O'Reilly and Associates. (the one with
the mouse on the front).

I get a server error when I try to run the script. Does anyone know what's
wrong?

Thanks for all help,
cheers,
Vegard

The associated HTML page is located at
http://home.c2i.net/vkaasa/guestbook.html

The code for the script is here:



#!C:/perl/bin/perl

$webmaster = "u940129\@studbo\.hit\.no";
$method = $ENV{'REQUEST_METHOD'};
$script = $ENV{'SCRIPT_NAME'};
$query  = $ENV{'QUERY_STRING'};

$document_root = "C:/progra~1/apache~1/apache/htdocs";
$guest_file = "guestbook.html";
$full_path = $document_root . $guest_file;
$exclusive_lock = 2;
$unlock = 8;

if ($method eq "GET") {
if ($query eq "add"){


$date_time = $get_date_time();

$MIME_header ("text/html", "My guestbook");

print <<End_Of_Guestbook_Form;

This is a guestbook CGI script that allows people to leave a
message for others to see. Please enter all requested information,
<B>and</B> if you have a www server, enter the adress so a hypertext
link can be displayed.
<P>
The current time is: $date_time
<HR>
<FORM METHOD="POST">
<PRE>
<EM>Name:</EM>  <INPUT TYPE="text" NAME="name" SIZE="40">
<P>
<EM>Email adress:</EM> <INPUT TYPE="text" NAME="from" SIZE="40">
<P>
<EM>Homepage:</EM> <INPUT TYPE="text" NAME="www" SIZE="40">
</PRE>
<EM>Please enter the information that you'd like to add</EM><BR>
<TEXTAREA ROWS=3 COLS=60 NAME="comments">
</TEXTAREA>
<P>
<INPUT TYPE="SUBMIT" VALUE="Add to guestbook">
<INPUT TYPE="RESET" VALUE="Clear Information"><BR>
<P>
</FORM>
<HR>

End_Of_Guestbook_Form

} else{
if ( open(GUESTBOOK, "<" . $full_path )) {
flock (GUESTBOOK, $exclusive_lock);
}
&MIME_header ("text/html", Here is my guestbook");

while (<GUESTBOOK>) {
print;
}

flock (GUESTBOOK, $unlock);
close (GUESTBOOK);

} else {
&return_error (500, "Guestbook File Error", "Cannot read from the
guestbook file [$full_path].");
}

}

}elseif ($method eq "POST"){
if ( open (GUESTBOOK, ">>" .$full_path) ) {
flock (GUESTBOOK, $exclusive_lock);

$date_time = &get_date_time();
$parse_form_data (*FORM);

$FORM{'name'} = "Anonymous User" if !$FORM{'name'};
$FORM{'from'} = $ENV{'REMOTE_HOST'} if !$FORM{'from'};
$FORM{'comments'} =~ s/\n/<BR>/g;

print GUESTBOOK <<End_Of_Write;

<P>
<B>$date_time:</B><BR>
Message from <EM>$FORM{'name'}</EM> at <EM>$FORM{'from'}</EM>:
<P>
$FORM{'comments'}

End_Of_Write

if ($FORM{'www'}) {
print GUESTBOOK <<End_Of_Web_Adress;


<P>
$FORM{'name'}can also be reached at:
<A HREF="$FORM{'www'}">$FORM{'WWW'}</A>

End_of_Web_Adress

}

print GUESTBOOK "<P><HR>";

flock (GUESTBOOK,$unlock);
close(GUESTBOOK);

&MIME_header ("text/html", "Thank You!");

print <<End_Of_Thanks;

Thanks for signing my guestbook. If you would like to view it, click <A
HREF="$guest_file">here</A>
(actual guestbook HTML file), or <A HREF="$script">here</A>(guestbook script
without a query).

End_Of_Thanks

}else {
&return_error (500, "Guestbook file error", "Cannot write to the guestbook
file [$full_path].");

}

}else {

&return_error (500, "Server Error", "Server uses unsupported method");
}
exit(0);


sub MIME_header
{
local ($mime_type, $title_string, $header) = @_;

if (!$header) {
$header = $title_string;
}

print "Content-type: ", $mime_type, "\n\n";
print "<HTML>, "\n";
print "<HEAD>,<TITLE>, $title_string, "</TITLE></HEAD>", "\n";
print "<BODY>", "\n";
print "<H1>", $header, "</H1>";
print "<HR>";
}

sub get_date_time
{
local ($months, $weekdays, $ampm, $time_string);
$months
="January/February/March/April/May/June/July/August/September/October/Novemb
er/December";
$weekdays = "Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
Satureday";

local ($sec, $min, $hour, $day, $nmonth, $year, $wday, $yday, $isdst) =
localtime(time);

if ($hour >12){

$hour -= 12;
$ampm = "pm";

} else {

$ampm = "am";
}

if ($hour == 0) {
$hour = 12;
}

$year += 1900;

$week = (split("/", $weekdays))[$wday];
$month = (split("/", $months))[$nmonth];
$time_string = sprintf("%s, %s %s, %s - %02d:%o2d:%o2d %s",
$week, $month, $day, $year,
$hour, $min, $sec, $ampm);

return ($time_string);
}

sub parse_form_data
{
local (*FORM_DATA) =@_;
local ($request_method, $post_info, @key_value_pairs,
$key_value, $key, $value);

read (STDIN, $post_info, $ENV{'CONTENT_LENGTH'});

@key_value_pairs = split (/&/, $post_info);

foreach $key_value(@key_value_pairs){
($key, $value) = split (/=/, $key_value);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;

if (defined($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
}else {
$FORM_DATA{$key} = $value;
}
}
}










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

Date: Mon, 12 Apr 1999 21:01:09 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <37125F15.F9900A91@dial.pipex.com>

John Callender wrote:
> 
> I recall reading something somewhere (in a man page? an O'Reilly book?)
> that gave a mnemonic device for remembering which symbols go with which
> types of Perl variables:
> 
> $ is a stylized 's' for 'scalar'
> @ is a stylized 'a' for 'array'
> 
> but I can't remember what, if anything, the hash's '%' was supposed to
> represent, and I haven't been able to track down the original source.
> 
> I have a vague sense that this was Larry Himself promulgating this
> wisdom, but I could be wrong.
> 
> Anyway, I'm sure there are about 150 people (at least) who will
> remember where this came from more or less instantly. If one or more of
> those people will take pity on me and tell me where I can look up the
> original, I'd appreciate it. Thanks.
> 
> --
> John Callender
> jbc@west.net
> http://www.west.net/~jbc/


A hash is a key/value pair right?

The little dot thing on the top left is the key symbol, whilst the
little circle thing on the bottom right is the value symbol.

It isn't a mnemonic device at all; it's a little picture of a key/value
pair.

Bye!


-- 
sub jasonHolland {
    my %hash = ( website =>
'http://dspace.dial.pipex.com/jason.holland/',
                 email   => 'jason.holland@dial.pipex.com' );
}


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

Date: Mon, 12 Apr 1999 14:08:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <MPG.117c00ab72765d4598989c@nntp.hpl.hp.com>

In article <37125F15.F9900A91@dial.pipex.com> on Mon, 12 Apr 1999 
21:01:09 +0000, Jason Holland <jason.holland@dial.pipex.com> says...
 ...
> A hash is a key/value pair right?
> 
> The little dot thing on the top left is the key symbol, whilst the
> little circle thing on the bottom right is the value symbol.
> 
> It isn't a mnemonic device at all; it's a little picture of a key/value
> pair.

No, no no.  It's the fraction that is printed when you do:

    print scalar %hash;

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


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

Date: Mon, 12 Apr 1999 15:55:14 -0600
From: "William Smith" <smith.will@epa.gov>
Subject: how can i send perl -c output to a file instead of STDERR
Message-Id: <7etj4d$hue1@valley.rtpnc.epa.gov>

When perl finds syntax errors they are sent to STDERR. I want to send them
to a file.
How can I do this?

Thanks
smith.will@epa.gov




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

Date: 12 Apr 1999 14:58:30 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how can i send perl -c output to a file instead of STDERR
Message-Id: <37125e76@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "William Smith" <smith.will@epa.gov> writes:
:When perl finds syntax errors they are sent to STDERR. I want to send them
:to a file.
:How can I do this?

perl -e 'system "man", $ENV{SHELL} =~ m#([^/]+)$#'

--tom
-- 
  "Contempt, rather than celebration, is the proper response to 
   advertising and the system that makes it possible." --Neil Postman


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

Date: Mon, 12 Apr 1999 21:20:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how can i send perl -c output to a file instead of STDERR
Message-Id: <3713610f.1587002@news.skynet.be>

William Smith wrote:

>When perl finds syntax errors they are sent to STDERR. I want to send
>them to a file.
>How can I do this?

Open a file with STDERR as the filehandle.

Oh wait! Syntax errors! That means you have to do that before
compilation even starts!

Lucky you, Perl allows that. Put the open() statement in a BEGIN block
at the start of the file, and you're set.

	BEGIN {
		open STDERR, ">errors.log" 
			or die "Can't create errorlog file: $!";
	}

You can also send syntax errors to STDOUT, by using this instead (in a
BEGIN block, naturally):

	open STDERR, '>&STDOUT';

ALternatively, put this one statement in a separate file, accessible
through @INC, and ".pm" as extension, e.g. "ErrToLog.pm", add "1;" at
the end, and put this at the start of the script:

	use ErrToLog;

Note that you don't need the BEGIN block in this case, because the
module is "required" as if in a BEGIN block (i.e. before anything else
is compiled).

   HTH,
   Bart.


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

Date: Mon, 12 Apr 1999 11:03:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I delete text in a file?
Message-Id: <vv1te7.vj3.ln@magna.metronet.com>

Gabriel Richards (grichard@uci.edu) wrote:
: Is there a function which will allow me to delete text from a file? I want
: to delete all the tags in an HTML file just leaving the content.


   Perl FAQ, part 5:

      "How do I change one line in a file/
       delete a line in a file/
       insert a line in the middle of a file/
       append to the beginning of a file?"


   Perl FAQ, part 9:

      "How do I remove HTML from a string?"



   People have already been where you are going.

   Best if you go see what they found out rather than
   inventing your own wheel...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 12 Apr 1999 16:13:36 -0500
From: danbeck@qual.net (Daniel Beckham)
Subject: Re: How do I simply delete a file in CGI?
Message-Id: <MPG.117c1dff68552385989682@news.idt.net>

Just as a FYI, CGI is the Common Gateway Interface and has nothing in the 
world to do with perl.  You can write CGI apps in python, VB <shudder>, 
C/C++ and pretty much any other language that can read from STDIN and 
write to STDOUT.  

To answer your question though, try the unlink() function.  Gotta think 
in unix terms my friend, unix terms.

In article <7ebcb7$sbm$1@news.worldonline.nl>, Moritz@warzone.com says...
> Am I stupid, or did they really forget to put that in the Perl language
> reference?
> 
> 
> 


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

Date: Mon, 12 Apr 1999 13:55:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I simply delete a file in CGI?
Message-Id: <MPG.117bfd7a2f653a3798989b@nntp.hpl.hp.com>

In article <MPG.117c1dff68552385989682@news.idt.net> on Mon, 12 Apr 1999 
16:13:36 -0500, Daniel Beckham <danbeck@qual.net> says...
> Just as a FYI, CGI is the Common Gateway Interface and has nothing in the 
> world to do with perl.  You can write CGI apps in python, VB <shudder>, 
> C/C++ and pretty much any other language that can read from STDIN and 
> write to STDOUT.  

<Perl commercial>

Notably, I implemented my first CGI program using csh!  When I saw how 
'fast' that ran, I bought my first Perl books and tried again.  Those 
books have now been thrown out, but the program survives.

It ran so much faster that I didn't care how slow it might be relative 
to C.  And I have managed to keep it acceptably fast as the volume of 
data has scaled up, by tuning data structures and algorithms (which is 
lots easier to do than in other languages) and by heavy benchmarking.

</Perl commercial>

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


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

Date: Mon, 12 Apr 1999 20:05:37 GMT
From: "Bob Lally" <rlally1@nycap.rr.com>
Subject: looking for a particular script....
Message-Id: <lmsQ2.1493$b73.89150@paloalto-snr1>

Hi:

At one time I saw a script that would take as input a set of keywords and an
HTML file.  The script would find each keyword and add <B></B>  around each
keyword.  It would then output the HTML file to the client.

I can not seem to locate this script anyplace.  Does anyone know of this
script and where it can be found?

Thanks.

Bob




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

Date: Mon, 12 Apr 1999 14:26:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: looking for a particular script....
Message-Id: <MPG.117c04f2769ded8c98989d@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <lmsQ2.1493$b73.89150@paloalto-snr1> on Mon, 12 Apr 1999 
20:05:37 GMT, Bob Lally <rlally1@nycap.rr.com> says...
> At one time I saw a script that would take as input a set of keywords and an
> HTML file.  The script would find each keyword and add <B></B>  around each
> keyword.  It would then output the HTML file to the client.
> 
> I can not seem to locate this script anyplace.  Does anyone know of this
> script and where it can be found?

Does this really need a canned program?

my %keywords;
@keywords{qw(foo bar baz)} = ();

while (<FILE>) {
    s%(\w+)%exists $keywords{lc $1} ? "<B>$1</B>" : $1%eg;
    print;
} 
__END__

All you need to add is the details of getting the keywords into the hash 
and opening the HTML file.

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


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

Date: Mon, 12 Apr 1999 23:27:41 +0200
From: claes@canit.se (Claes Bjorklund)
Subject: Multipel dimension
Message-Id: <claes-1204992327410001@p20.one.canit.se>

I would like to make a multipel dimensions frequencies table, for instance 
I am using this $freq{$val0}{$val1}{$val2}++ to do  a three dimensional table
But I want to do that in a general case. Have read in perldoc perlref, perlol
have even search in dejanews. Below is my script where I generate the code
and then evaluate the code, is there any simplier way to solve this, I am
sorry if this question too simple, but I can't solve it by myself.

\Claes

#!perl -w

@list=(1,5,3);
while (<DATA>){
  chop;
  push @LoL,[split];
}

for $i (0..$#LoL){
  for $j (@list){
    $u=$LoL[$i][$j];
    $M[$j]{$u}++;
  }
}

$cod1=loop1(@list);
eval $cod1;
print $cod1;

$cc = fetch(@list);
print $cc;

for $i (0..$#LoL){
@k=@{$LoL[$i]};
eval $cc;
#$freq{$k[5]}{$k[1]}{$k[3]}++;
}

print "\n";
$co=loop2(@list);
eval $co;
print $co;
1;
###########
sub loop1 {
my @list=@_;
for $n (@list){
  $code.="for \$k$n (sort keys %{\$M[$n]}){\n";
}
$code.="\$freq";
for $n (@list){
  $code.="{\$k$n}";
}
$code.="{count}=0;\n";

for $n (@list){
  $code.="}\n";
}
return $code;
}

sub fetch {
my @list=@_;
$cc.="\$freq";
for $n (@list){
  $cc.="{\$k[$n]}";
}
$cc.="{count}++;";
return $cc;
}
sub loop2 {
my @list=@_;
for $n (@list){
  $co.="for \$k$n (sort keys %{\$M[$n]}){\n";
}
$co.="print \$freq";
for $n (@list){
  $co.="{\$k$n}";
}
$co.="{count};\n";
$co.="}\nprint \"\n\";";
for $n (0..$#list-1){
  $co.="}\n";
}
return $co;
}

__DATA__
1 2 1 7 7 4
1 1 1 5 6 5
3 5 1 7 5 6
1 2 1 5 4 7
3 4 1 3 5 8
5 4 1 6 6 3
2 4 1 6 7 4
2 1 1 4 4 5
2 1 1 4 4 5
1 1 1 1 1 1


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

Date: Mon, 12 Apr 1999 20:21:04 GMT
From: bing-du@tamu.edu
Subject: pattern matching
Message-Id: <7etkj8$ahf$1@nnrp1.dejanews.com>

Hello there,

How to judge if a variable is composed of digits only?

Thanks in advance for your hints.

Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 12 Apr 1999 17:06:52 -0400
From: Fu Chin Liu <fuchin@mail.nwos.lucent.com>
Subject: Re: pattern matching
Message-Id: <3712606C.1176F10@mail.nwos.lucent.com>

Try /^\d+$/ .

bing-du@tamu.edu wrote:

> Hello there,
>
> How to judge if a variable is composed of digits only?
>
> Thanks in advance for your hints.
>
> Bing
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Mon, 12 Apr 1999 19:12:40 GMT
From: wmorgan@nswc.navy.mil (Bill Morgan)
Subject: Re: Problems connecting to Oracle 8 from Perl using DBI
Message-Id: <1999Apr12.190939.12534@relay.nswc.navy.mil>

I ran tnsping80 my_db 
and it pinged correctly with no errors.  So I know the tnsnames.ora file is 
ok.  I can also connect to my_db via SQL Plus.
I'm at a loss as to what is wrong!  :-(
In article <NNXQvSjg#GA.94@rejz.ij.net>, "Ted" <thill@ij.net> wrote:
>Try:
>
>tnsping80 my_db
>
>if you get the ORA-3121, then check the entry for my_db in tnsnames.ora
>
>Nick Kean wrote in message <7ejl42$iuv$1@newsource.ihug.co.nz>...
>>In article <7edbpe$3ks$1@oanews.nswc.navy.mil>, Bill Morgan wrote:
>>>I am running the latest version of Active State Perl under NT 4.0 and
>trying
>>>to connect to
>>>an Oracle 8 database with DBI.  Here is the code I am using:
>>>
>>>use DBI;
>>>
>>>$ENV{'ORACLE_HOME'}  = "E:\ORANT";
>>>$ENV{'ORACLE_SID'} = "ORCL";
>>>
>>>$dbh = DBI->connect("dbi:Oracle:my_db", "username", "password");
>>>
>>>if ( !defined $dbh) {
>>>  die "Cannot connect to Oracle database: $DBI::errstr\n";
>>>}
>>>
>>>exit;
>>>
>>>I get the following error message:
>>>
>>>Cannot connect to Oracle database: ORA-03121: no interface driver
>connected -
>>>function not performed (DBD: login failed)
>>>
>>>I can connect via ODBC using these statements:
>>>
>>>use Win32::ODBC;
>>>$database = "DRIVER={Oracle ODBC
>Driver};DBQ=my_db;UID=username;PWD=password";
>>>$db = new Win32::ODBC($database)
>>>
>>>so I know my database connectivity is there,
>>>but I can't figure out what I am doing wrong with DBI.  Any help you can
>>>provide would be greatly appreciated!  Please email any replies as well as
>>>posting to this group.
>>
>>  Using DBI to connect to a remote (works for local too) database on our
>>Solaris system, I use :
>>
>>$sid  = 'foo1';
>>$user = 'scott';
>>$pass = 'tiger';
>>die "$DBI::errstr"
>>  unless ( $dbh = DBI->connect($sid, $user, $pass, 'Oracle') );
>>
>>--
>>We are quite confident that all of our systems are Year 2000
>>Compliant.  However, we have over a two year backlog of Year 2000
>>Compliance forms to fill out, so according to our scheduling
>>database, you should hear back from us in June, 1900.
>
>

---------------------------------------------------------------------------
William E. Morgan       NAVAL SURFACE WARFARE CENTER
Code N84                     email: wmorgan@nswc.navy.mil
17320 Dahlgren Rd.     phone: (540)653-6088
Dahlgren, VA  22448   fax: (540)653-1810



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

Date: Mon, 12 Apr 1999 11:05:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <842te7.vj3.ln@magna.metronet.com>

BarneyXter (barneyxter@aol.com) wrote:
: The Title Says It All.  I Want To Learn How To Make A Chat Room And Have Pages
: That I Can Input Text From...


   Then you need to learn a programming language to implement
   your CGI programs in.

   Do you know any programming languages already?

   If so, then use that.

   If not, then consider learning Perl.

   I have no experience with Pearl, and so I cannot comment
   on the suitability of that language.


   Perl FAQ, part 3:

      "Where can I learn about CGI or Web programming in Perl?"



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 12 Apr 1999 17:58:34 +0100
From: "Keith Kwiatek" <kkwiatek@nist.gov>
Subject: Y2k issues with perl DBI?
Message-Id: <7etoo2$2hg$1@news.nist.gov>

Any y2k issues with Perl and DBI I need to be aware of?






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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5364
**************************************

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