[13928] in Perl-Users-Digest

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

No subject found in mail header

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 17:48:10 1999

Date: Mon, 8 Nov 1999 21:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942123911-v9-i1324@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 Nov 1999     Volume: 9 Number: 1324

Today's topics:
    Re: <!--#exec cgi="/dir/any.cgi"-->(how to execute from (David Efflandt)
        Alternative to <*> vitanut@my-deja.com
    Re: Binary FTP using Net::FTP package? <mj.stevenson@auckland.ac.nz>
    Re: C++ Free Compiler for Win32? (d.k. henderson)
    Re: cgi debug (David Efflandt)
        copyleft notice? <d.learner@gte.net>
    Re: copyleft notice? <wyzelli@yahoo.com>
    Re: Debugging CGI under NT... (Eric Bohlman)
    Re: expect module <wh9coos@nc.itntl.bhp.com.au>
    Re: FAQ 8.31: Can I use perl to run a telnet or ftp ses steven_ellis@my-deja.com
        FAQs everywhere? <dove@synopsys.com>
    Re: Help with HTML forms and MYSQL insert (Abigail)
    Re: Help with IF statements <wyzelli@yahoo.com>
        Help: Pulling a File/Page from another server <sangiro@dropzone.com>
    Re: Help: Pulling a File/Page from another server <qumsieh@sympatico.ca>
    Re: How do U parse from the end of the line? (Rob Manchester)
    Re: How do U parse from the end of the line? <wyzelli@yahoo.com>
        How to use stat function ? <Achin@inprise.com>
    Re: Large hash: advice? <jon@midnightbeach.com>
    Re: Loading modules <dove@synopsys.com>
    Re: Need nifty code for displaying Web Graphics <schuette@umr.edu>
    Re: perl as first language? (Abigail)
    Re: perl as first language? <uri@sysarch.com>
    Re: Perl forgot 3 lines of the script <jomagam@yahoo.com>
    Re: Perl/Tk looping question. <qumsieh@sympatico.ca>
    Re: Problem with eval and lexical scoping (Charles DeRykus)
        Problems with a perl socket listener steven_ellis@my-deja.com
        setting environment variables <bakrishn@cisco.com>
        symbolics was [Re: FAQ 5.5: How can I manipulate fixed- lee.lindley@bigfoot.com
    Re: symbolics was [Re: FAQ 5.5: How can I manipulate fi <uri@sysarch.com>
    Re: tutorial or help on HTML parser <skilchen@swissonline.ch>
    Re: what is the difference between my() and local()? (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 9 Nov 1999 04:11:14 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: <!--#exec cgi="/dir/any.cgi"-->(how to execute from browser created by cgi)
Message-Id: <slrn82f7n0.1i0.efflandt@efflandt.xnet.com>

On 05 Nov 1999 03:50:27 GMT, Gigabytr <gigabytr@aol.com> wrote:
>I have a cgi program that loads a header.html and a footer.html files and the
>middle content is dynamically created by cgi. I have placed the <!--#exec
>cgi="/dir/any.cgi"--> in the header.html file but the browser won't exec the
>cgi due to the cgi printing the file to the browser.
># Print the HTML header
>sub print_header {
>print "Content-type: text/html\n\n";
>
>open (HEADER,"$basepath$delim$header") || print "Could not open
>$basepath$delim$header $! \n";
>while (<HEADER>) {
>print $_;
>	}
>close(HEADER);	
>}
>## END print_header;
>
>Please help! Very stuck!
>I would appreciate any help with getting the "exec" command to work.
>
>Thanks,
>gigabytr@aol.com

Webservers do not parse CGI for SSI since you can just as easily do
everything you need to do from the CGI.  I believe that Perl can use "/"
for delimiters even if your system uses something else.

# More simply
if (open (HEADER,"$basepath/$header")) { print <HEADER>; close HEADER; }
    else { print "Can't open$basepath/$header $! \n"; }

# For the include (note backticks, not quotes)
print `full_or_relative_system_path_to/any.cgi`;

You just need to comment out the Content-type in any.cgi

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Tue, 09 Nov 1999 02:55:38 GMT
From: vitanut@my-deja.com
Subject: Alternative to <*>
Message-Id: <8082f8$28c$1@nnrp1.deja.com>

I have a script that reads the contents of the current working
directory into an array with the following code:

@array = <*>;

This script is on a Concentric Host server which uses a cgi management
system called VDE. I believe that the VDE is not allowing the script to
execute this code. Does anyone know how to get around this? Is there a
system call I can use from my script instead? Concentric has not been
able to help me so far.


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


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

Date: Tue, 09 Nov 1999 15:33:48 +1300
From: Matthew Stevenson <mj.stevenson@auckland.ac.nz>
Subject: Re: Binary FTP using Net::FTP package?
Message-Id: <3827880C.72749419@auckland.ac.nz>

joneill wrote:
> 
> I'm using the Net::FTP package to transfer files from an FTP site to my
> Win32 machine. The line feeds in the original file get changed to
> carriage return/line feeds in the downloaded file. It's important the I
> don't change the contents of these files at all and I think the answer
> is using binary transfer. I tried a couple of different things based on
> the sparse documentation, but nothing worked. I think it's there ... I
> just need a little guidance to the answer.

$ftp = Net::FTP->new($host);
$ftp->login("who","what");
$ftp->cwd("/usr/local/bin");
print $ftp->pwd,"\n";
$ftp->binary();  ## change to binary
$ftp->get($file_to_get);
$ftp->quit;

This works for me. Note no check on return values.

Matthew
-- 

Matthew Stevenson
University of Auckland
mj.stevenson@auckland.ac.nz


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

Date: Tue, 09 Nov 1999 03:13:34 GMT
From: dalekh@hotmail.com (d.k. henderson)
Subject: Re: C++ Free Compiler for Win32?
Message-Id: <8E78E201Bdkhenderson@207.14.233.19>

www.egroups.com/groups/mingw32 discusses the free C++ compiler and has links 
to the free downloads


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

Date: 9 Nov 1999 04:46:19 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: cgi debug
Message-Id: <slrn82f9op.1i0.efflandt@efflandt.xnet.com>

On Fri, 05 Nov 1999 19:13:32 GMT, Rogerio Sodre <rsodre@hotmail.com> wrote:
>I have some sites at VirtualAvenue free server and use perl cgi a lot.
>But their support people are a little stupid, they say that their
>support is just to ensure that my site is up and can't answer any cgi
>question.
>
>So, can anyone please tell me how can I debug a perl cgi script that's
>running on my server? If there's an error on the script, I just get
>"Server error" or something.

You get what you pay for (free).  For info on CGI::Carp on virtualave see
"MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW" in:

http://cgi-help.virtualave.net/pub/findpmod.cgi?man=CGI/Carp.pm

You could also easily write a CGI script like this to test another CGI
script (the 2>&1 on the end of the command below redirects
STDERR > STDOUT > browser:

#!/usr/local/bin/perl
print "Content-type: text/plain\n\n";
# Note backticks (``) not quotes
print `./some.cgi 2>&1`; 

Just remember to ftp all scripts as ASCII, not binary.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Tue, 09 Nov 1999 03:34:35 GMT
From: "Donald \"Don\" Learner" <d.learner@gte.net>
Subject: copyleft notice?
Message-Id: <fDMV3.1411$Vg6.32253@dfiatx1-snr1.gtei.net>

I have come across a reference in a database textbook about Perl being "the
only software product on the market to have a copyleft notice." What does
this mean? I have looked in several books but can not find it as a command
or reserved word. Thanks!




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

Date: Tue, 9 Nov 1999 14:15:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: copyleft notice?
Message-Id: <FFNV3.22$kK3.2886@vic.nntp.telstra.net>

Donald "Don" Learner <d.learner@gte.net> wrote in message
news:fDMV3.1411$Vg6.32253@dfiatx1-snr1.gtei.net...
> I have come across a reference in a database textbook about Perl being
"the
> only software product on the market to have a copyleft notice." What does
> this mean? I have looked in several books but can not find it as a command
> or reserved word. Thanks!
>

I think you might find it to be a pun on copyright!

Wyzelli




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

Date: 9 Nov 1999 04:56:11 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Debugging CGI under NT...
Message-Id: <8089hb$vdi$1@nntp2.atl.mindspring.net>

Matthew Miller (namille2@news.vt.edu) wrote:
: Me and a friend were debugging a CGI script under NT 4 and noticed some odd
: behavior. The first thing is that while debugging the script we entered the
: the name=value pairs for the CGI we couldn't get the script to continue. On
: my linux box typing cntl-d ends the input of the name-value pairs and the
: debugging session continues. We were using Activesite build 519. We couldn't
: find any way to continue execution. We found no clues under perldoc CGI.
: What is done at this point?

Use Ctrl-z to indicate EOF.

: The second problem is it seems that under NT perl doesn't support command
: line arguments. Regardless of the number of command line arguments #$ARGV
: always equals -1! I wrote a test script and seen it for my self, I wouldn't
: have thought it otherwise.

Try running the script by "perl name_of_script" rather than just 
"name_of_script."  NT's command processor has some rather peculiar ideas 
about what command-line info to pass to a program invoked through file 
associations.



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

Date: 09 Nov 1999 13:37:21 +1100
From: Cooper Stuart SC <wh9coos@nc.itntl.bhp.com.au>
Subject: Re: expect module
Message-Id: <kgsn1so5r1a.fsf@nc.itntl.bhp.com.au>

"Felix Maurer" <maurerf@post.ch> writes:

> Hi all,

> I'm trying to use the expect module for the first time, and have some
> problems with the following loop:

> #!/usr/local/bin/perl
> use Expect;
> @disk = "/dev/dsk/c0t8d0s0","/dev/dsk/c0t8d0s6","/dev/dsk/c0t8d0s7";

> # Start the newfs process.
> foreach $disk (@disk) {
>   ($newfs = Expect->spawn("newfs $disk")) || die "Couldn't spawn newfs, $!";
> 
>   unless ($newfs->expect(30,"(y/n)? ")) {
>     die "Never got the confirmation prompt, ".$newfs->exp_error()."\n";
>   }
>   print $newfs "y\r";
> 
>   $newfs->soft_close();
> }
> __END__

> First, it works only over one disk, and then i don't anderstand why I need
> the soft_close command?

can't help you here sorry.

> These are of course newbbie questions, but is there someone out there to
> give me some hints?

> Felix

Your @disk assignment is wrong. It should be:
@disk = ("/dev/dsk/c0t8d0s0","/dev/dsk/c0t8d0s6","/dev/dsk/c0t8d0s7");

If you add -w to your perl invocation,

#!/usr/local/bin/perl -w 

you'll get a warning like:

Useless use of a constant in void context at loop.pl line 3.
Useless use of a constant in void context at loop.pl line 3.

warning you that all is not as it seems in line 3.
In your original program you only get one element in your @disk array.

Get in the habit of
1) adding -w to your Perl scripts, particularly while they are 
   under development.
2) putting brackets around your lists.

Stuart Cooper.


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

Date: Tue, 09 Nov 1999 03:20:03 GMT
From: steven_ellis@my-deja.com
Subject: Re: FAQ 8.31: Can I use perl to run a telnet or ftp session?
Message-Id: <8083t0$34d$1@nnrp1.deja.com>

In article <381d02d8@cs.colorado.edu>,
  perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> (This excerpt from perlfaq8 - System Interaction
>     ($Revision: 1.39 $, $Date: 1999/05/23 18:37:57 $)
>
>     If all you want to do is pretend to be telnet but don't need the
>     initial telnet handshaking, then the standard dual-process
approach
>     will suffice:
>
>         use IO::Socket;             # new in 5.004
>         $handle = IO::Socket::INET->new('www.perl.com:80')
>                 || die "can't connect to port 80 on www.perl.com: $!";
>         $handle->autoflush(1);
>         if (fork()) {               # XXX: undef means failure
>             select($handle);
>             print while <STDIN>;    # everything from stdin to socket
>         } else {
>             print while <$handle>;  # everything from socket to stdout
>         }
>         close $handle;
>         exit;

One problem with this code is that the socket closes before all the
incoming data has been streamed through. For example if I cat a large
file to the socket the last characters will not appear at the server
end.

Does anyone know a solution for this problem as I need to capture all
input to a given port number without being caught by a closing socket
first.

Steve


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


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

Date: Mon, 08 Nov 1999 19:50:54 -0800
From: David Amann <dove@synopsys.com>
Subject: FAQs everywhere?
Message-Id: <38279A1E.304F0382@synopsys.com>

Hi all,

I've been off the newsgroup for awhile and when I come back what do I
see but FAQs everywhere!  This is pretty neat.

I have some questions.  Do the FAQs actually get posted automatically
depending on what people are asking, or is it just a random posting?
Does someone make sure which FAQs should be posted or is there some sort
of automatic matching going on?

Thanks for the help!

-=dav




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

Date: 8 Nov 1999 22:30:11 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Help with HTML forms and MYSQL insert
Message-Id: <slrn82f91e.6es.abigail@alexandra.delanet.com>

Shawn Smith (SPAMshawns@unt.edu) wrote on MMCCLX September MCMXCIII in
<URL:news:38281d29.906589@news.unt.edu>:
-- On 8 Nov 1999 01:03:18 -0600, abigail@delanet.com (Abigail) wrote:
--
-- >Shawn Smith (SPAMshawns@unt.edu) wrote on MMCCLX September MCMXCIII in
-- ><URL:news:38276c36.39566868@news.unt.edu>:
-- >%% 
-- >%% I got it where I can do selects but I can't seem to get the insert to
-- >%% work.  I dont' need help with the HTML forms; I need  help with the
-- >%% Perl MYSQL insert script.
-- >
-- >
-- >This is comp.lang.perl.misc, not comp.lang.sql.
--
-- It must have been the header that threw you.  
--
-- Let me clarify: I have no problem with sql, I have no problem with
-- HTML forms.  
--
-- My problem is with perl.  My problem is using perl to interface my
-- HTML form with my database.  My problem is with the syntax of perl.
-- All I wanted was an example of someone using perl to interface a form
-- to a db doing an insert.


In that case, since you are already doing the select, it's the same
interface.

HTH. HAND.


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 9 Nov 1999 11:57:28 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Help with IF statements
Message-Id: <kELV3.14$kK3.2506@vic.nntp.telstra.net>

jim and lois flaherty <kf4dmb@tds.net> wrote in message
news:t_KV3.182$4D5.116994@ratbert.tds.net...
> I have a form and the script e-mails the results to the proper person.
> Everything works fine execpt
> the IF statement I have .
>
>
> $adpso = $formdata{'adpso'};
> $code = $formdata{'dept'};
>
>
> if($code eq "03") {
>   $adpso = "schmidt"
> }
>   else
>  {
> }
>
> if($code eq "20") {
>   $adpso = "MR Lowe"
> }
>   else
>  {
> }
>
> if($code eq "40") {
>   $adpso = "Paipe"
> }
>   else
>  {
>    $adpso = "engelhardt"
> }
>
> No matter what the code on the form which is a drop Box . the script
always
> selects
> engelhardt
>
> Help !
>
> thanks in advance
> Jim

You may find it works better with elsif statements like so:

if($code eq "03") {
$adpso = "schmidt"
}
elsif($code eq "20") {
$adpso = "MR Lowe"
}
elsif($code eq "40") {
$adpso = "Paipe"
}
else
{
$adpso = "engelhardt"
}

I am assuming of course that your form is providing your '$code' as a string
not a number.  Also, if you are setting $adpso based on $code, why even get
$adpso from the form?  Or does this code only run if $adpso is not set by
the form?

Wyzelli




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

Date: Tue, 09 Nov 1999 02:18:49 GMT
From: sangiro <sangiro@dropzone.com>
Subject: Help: Pulling a File/Page from another server
Message-Id: <8080a6$js$1@nnrp1.deja.com>

Heya,

I am maintaining web pages on three different servers (don't as why -
that's the way it is unfortunately!)

I would like to share components between these three servers.  For
example:  there are some news.txt files on the one server with
headlines to news items posted on the page on that server.

I would like to pull those headlines through an SSI/CGi script onto the
pages on the other servers as well.  Assume that I know very little
about PERL.

I have found the script included below that actually grabs a page off
EXITE, chops it up, reformats it and prints the weather headlines to a
page.  Substituting my server information and getting rd of some of the
formatting lines, I can't get this to work for me.  I think there's got
to be an easier way.  Can anyone help?  Does anyone have a script that
does this?

Safe swoops
Sangiro

http://www.dropzone.com/


#!/usr/bin/perl

# getWeather.cgi
# by Joel Wheeler
#
# Gets the weather forecast at http://my.excite.com/?forecast=DAY
#

# Set necessary variables and call function to grab weather page
$server = "my.excite.com";
$document = "/?forecast=DAY";
$weather = &GetWebPage();

# Get rid of everything before the "Dayton, OH" line
$weather =~ s/.*Dayton, OH \(USA\)<\/B><\/FONT><BR>//s;

# Get rid of everything after that first </TD>
$weather =~ s/<\/TD>+.*//s;

# ignore <TD VALIGN=top> tag and everything before it
$weather =~ s/.*<TD VALIGN=top>//s;

# replace "/images" with full address
$weather =~ s/\/images/http:\/\/my.excite.com\/images/s;

print "content-type: text/html\n\n";
print $weather;
print "\n";

# end main



sub GetWebPage
{

# Copyright 1994 Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software
and its
# documentation for any purpose is hereby granted without fee, provided
that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising
or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  M.I.T. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
#

sub TCP { join("", getprotobyname('tcp')); }
sub SOCK_STREAM { 1; }
sub AF_INET { 2; }
sub PF_INET { &AF_INET; }

# sub main {
#  $server = "localhost";
  $port = 80;
#  $document = "/index.html";
  @Headers = ("User-Agent", "http-get/0.1");



  if ($server =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
    @addrs = pack('C4', split(/\./,$server));
  } else {
    ($dummy,$dummy,$dummy,$dummy, @addrs) = gethostbyname($server);
  }
  $remote = pack("S n a4 x8", &AF_INET, $port, $addrs[0]);
  socket(S, &PF_INET, &SOCK_STREAM, &TCP) || die "socket: $!";
  $cdb = localtime($^T);
  connect(S, $remote) || die "connect fail at $cdb: $!";
  select(S); $| = 1;
  select(STDOUT); $| = 1;

  $request = "GET $document HTTP/1.0\r\n";
  while ($#Headers > 0) {
    $request = $request . "$Headers[0]: $Headers[1]\r\n";
    shift(@Headers); shift(@Headers);
  }
  $request = $request . "\r\n";
  print(S $request);

  $big = 1024*1024;
  while ($len = sysread(S, $data, $big)) {
#    $out = syswrite(STDOUT, $data, $len);
     $xyz .= $data;
  }
  close(S) || die "close: $!";
# }


# &main;

# Local Variables:
# mode: c
# End:


$xyz;
}


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


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

Date: Tue, 09 Nov 1999 02:55:22 GMT
From: Ala Qumsieh <qumsieh@sympatico.ca>
Subject: Re: Help: Pulling a File/Page from another server
Message-Id: <38278D90.5D48E4D@sympatico.ca>

sangiro wrote:

> I would like to share components between these three servers.  For
> example:  there are some news.txt files on the one server with
> headlines to news items posted on the page on that server.
> 
> I would like to pull those headlines through an SSI/CGi script onto the
> pages on the other servers as well.  Assume that I know very little
> about PERL.

Luckily for you, there is a good module that does all of this and
more. Get the LMP::Simple module from www.cpan.org.

> I have found the script included below that actually grabs a page off
> EXITE, chops it up, reformats it and prints the weather headlines to a
> page.  Substituting my server information and getting rd of some of the
> formatting lines, I can't get this to work for me.  I think there's got
> to be an easier way.  Can anyone help?  Does anyone have a script that
> does this?

What a way to re-invent a very good wheel!
Check out the module above.

HTH,
--Ala


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

Date: 9 Nov 1999 02:17:07 GMT
From: chesta@brown.edu (Rob Manchester)
Subject: Re: How do U parse from the end of the line?
Message-Id: <slrn82f106.1u.chesta@lester.manchero.org>

In article <807jbn$n4b$1@nnrp1.deja.com>, mirranda@my-deja.com wrote:
:In article   chesta@brown.edu (Rob Manchester) wrote:
:> :<mirranda@my-deja.com> wrote in message
:> : How do U parse from the end of the line to get the file extension
:> : and the file name only?
:> :
:> : i.e.:
:> : /mypath/another_path/foo_diretory/myfile.ext1
:> :
:> : and you want to replace the extension and just get the file name
:> : i.e.
:> : myfile.abc
:> :
:> : I am a beginner....
:> : Thanks.
:> :

:Hi Rob,
:
:First thanks for your help.  This does print the name ok but I can't
:pass it to another vairable.  I.e. when I try to assign the file only
:(with the new extension) I have trouble.
:My problem is this:
:On NT, I get this config file which I get with the whole path
:then I need to modify the extension and copy it to another directory.
:help...
:thanks
:> how about...
:>
:> my $ext="abc";
:> my @name = split(/[\.\/]/,"/some/path.txt");
:> print STDOUT "$name[@name -2].$ext\n";

NT? NT has paths that start with /?  I am not sure what the problem
is, but some other people have suggested using File::Basename.
That might be easier for you.

all I have done is taken "/some/path.txt" and using the split command
put it into an array like
@name = ("some","path","txt");
where
print @name[0]  -> some
print @name[1]  -> path
print @name[2]  -> txt
if we just
print @name that is the value or the array, which is three,
print @name[@name-1] -> txt
print @name[@name]  -> error
we can 
my $basename = "@name[@name-2].@name[@name-1]";
which gives us "path.txt"

we can repace "/some/path.txt" with any scalar, here I use
the first argumnet.  after the command.

#!/usr/local/bin/perl

my @name = split(/[\.\/]/,@ARGV[0]);
my $newext="bar";
my $newname = "$name[@name -2].$newext";
print STDOUT "$newname\n";

note, there is no error checking. which makes this very dangerous.
if you only have the case you stated above, it is fine, but not
very extensible.

-rob


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

Date: Tue, 9 Nov 1999 12:20:04 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How do U parse from the end of the line?
Message-Id: <wZLV3.15$kK3.2727@vic.nntp.telstra.net>

<mirranda@my-deja.com> wrote in message news:807jbn$n4b$1@nnrp1.deja.com...
>
> Hi Rob,
>
> First thanks for your help.  This does print the name ok but I can't
> pass it to another vairable.  I.e. when I try to assign the file only
> (with the new extension) I have trouble.
> My problem is this:
> On NT, I get this config file which I get with the whole path
> then I need to modify the extension and copy it to another directory.
> help...
> thanks

If all you are doing is changing the extension, why not just use s/// ?

#!/usr/bin/perl -w
use strict;
my $oldext = 'ext1';
my $newext = 'abc';
my $oldfilename = '/mypath/another_path/foo_diretory/myfile.ext1';
my $newfilename = $oldfilename;
$newfilename =~ s/\.$oldext/\.$newext/;
print "$oldfilename\n";
print "$newfilename\n";

This actually does less than my previous post, though what you are
specifying now is a little simpler.

The \. is included within the s/// in an attempt to ensure that the only
place changed is the file extension.  But if you have a file called
/mypath/another_path/foo_diretory/myfile.ext1.ext1 it will be changed to
/mypath/another_path/foo_diretory/myfile.abc.ext1.  Hopefully that is not a
common occurance.  It it is likely to be a problem, change the regex to
s/\.$oldext$/\.$newext/ to force a match at the end of the line.

Wyzelli




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

Date: Tue, 09 Nov 1999 11:59:14 +0800
From: Adrian Chin <Achin@inprise.com>
Subject: How to use stat function ?
Message-Id: <38279C12.8FBB76DA@inprise.com>

Hi

I am confused on how stat () actually works.

I have :

    $mode = (stat $file) [2];

it prints out :

mode = 16893 for a directory which is drwxrwxr-x
mode = 33261 for a file which is -rwxr-xr-x

How come 9 and 8 existed in the mode result ?


Thanks
Adr



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

Date: Mon, 08 Nov 1999 20:14:22 -0800
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Re: Large hash: advice?
Message-Id: <38279F9E.A0F4C84B@midnightbeach.com>

Kragen Sitaker wrote:

> >I'd appreciate any comments on this strategy before I spend some time
> >coding it.
> 
> This sounds like it would definitely work.  Data::Dumper might help you
> creating the string representation.

In the "Yes, but" category, I get "errno 22" from sdbm when I add large
keys. A Google search indicates that this is, indeed, a value-too-large
error.

At this point, I suspect that - short of a real database - my best bet
may be to write the strings to a third file and use the DBM files to
store per key offsets and lengths within this third file. I'll sleep on
it, and see what comes to me in the shower, I guess.

-- 

http://www.midnightbeach.com    - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages


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

Date: Mon, 08 Nov 1999 19:57:33 -0800
From: David Amann <dove@synopsys.com>
Subject: Re: Loading modules
Message-Id: <38279BAD.CB48C98A@synopsys.com>

Hi Red,

26Red@depechemode.com wrote:

> I wrote a PERL script that requires the loading of modules.  In UNIX,
> the script is able execute perfectly but when I click on the file using
> Netscape browser, I get a server Error message.

My guess is that your modules are not installed in the standard perl space
and that you have an environmental variable in your shell configuration
file that sets the path to your special modules.

The way that I solve these problems is to use the 'lib' pragma as follows.

#!/usr/bin/perl -w

use lib "/path/to/my/module/director";

# insert perl code here

Hope this helps,
-=dav





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

Date: Mon, 08 Nov 1999 22:12:22 -0600
From: Matt Schuette <schuette@umr.edu>
Subject: Re: Need nifty code for displaying Web Graphics
Message-Id: <38279F26.BBB27080@umr.edu>

Martien Verbruggen wrote:

> > Hmmm...
> >
> > var fred = 'GIF89a\1\0\1\0\200[...]\1\0;'
> > ...
> > <IMG SRC="javascript:fred">
>
> That is not HTML.

I believe that is called masochism.

Matt



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

Date: 8 Nov 1999 22:45:29 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: perl as first language?
Message-Id: <slrn82f9u3.6es.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLX September
MCMXCIII in <URL:news:38274A95.7874C759@mail.cor.epa.gov>:
;; Abigail wrote:
;; > 
;; > todd (thirdwaver@inxpress.net) wrote on MMCCLVIII September MCMXCIII in
;; > <URL:news:s2929r91hpc35@news.supernews.com>:
;; [snip]
;; > '' that perl is not a great choice for a first language. If that is that case
;; > '' what is a good first language. (shell scripting, sed, awk, java, M$ Visual
;; > '' xxx)?
;; > 
;; > Python, Eiffel, Pascal, Java, LPC, Lisp, Algol, Scheme, ML, Haskel, Ada.
;; 
;; Granted, you are a computing deity while I'm just a code-butcher.
;; But I don't agree with your list.  Exposing someone to an entire
;; new paradigm PLUS a computing language seems to cause cerebral
;; implosions and other Bad Things (tm).

How can you not expose someone to a new paradigm and learn him/her
his/her first language? Whether the language will be procedurial,
object oriented, design by contract or functional, it will be new.

;; Python  - yes
;; Eiffel  - maybe
;; Pascal  - yes

And I forgot to mention the languages from the same school:
Modula and Oberon.

;; Java    - please, no

Any reason why not?

;; LPC     - don't know this one
;; Lisp    - maybe
;; Algol   - yes
;; Scheme  - well.. okay...
;; ML      - don't know this one either
;; Haskel  - a weak maybe
;; Ada     - maybe
;; 
;; By these standards, one could list APL and J [*not* JScript,
;; mind you] in here too.  And PL/1 and PL/C, and a dozen others.

Perhaps, but I don't know enough about those languages.

;; And Perl too.  Andrew Johnson's "Elements of Programming
;; with Perl" is a good intro computing text which uses
;; Perl as the language of choice - and does a good job of
;; both.

I disagree with Perl, for the same reason I don't recommend C. It's way
too messy and there's too much rope. That's great for someone who knows
what they are doing, but not good for someone who doesn't. First learn
to program, then you know how to exploit the mess and ropes of Perl and C.



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 08 Nov 1999 23:54:40 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl as first language?
Message-Id: <x77ljs1cz3.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> ;; And Perl too.  Andrew Johnson's "Elements of Programming
  A> ;; with Perl" is a good intro computing text which uses
  A> ;; Perl as the language of choice - and does a good job of
  A> ;; both.

  A> I disagree with Perl, for the same reason I don't recommend C. It's
  A> way too messy and there's too much rope. That's great for someone
  A> who knows what they are doing, but not good for someone who
  A> doesn't. First learn to program, then you know how to exploit the
  A> mess and ropes of Perl and C.

i started with PL/I which is much messier than c. luckily my class was
the one which taught structured programming so i never learned to rely
on gotos. c is high level assembler so it is not a good first language
IMO. 

as for perl, in some ways it makes for a good first language. i am
reading johnson's book now and it is very well written. the first
chapters are very general about programming concepts and coding safety
(strict, -w, formatting, etc). i haven't gotten to the real perl stuff
yet but i am looking forward to it. it is great to see a second
excellent perl book from manning. this bodes well for them.

uri


-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 09 Nov 1999 00:12:57 -0500
From: Balazs Rauznitz <jomagam@yahoo.com>
Subject: Re: Perl forgot 3 lines of the script
Message-Id: <3827AD59.2A72B36C@yahoo.com>

Utilisateur Red Hat Linux wrote:

> Hello,
> I need to write to a filehandle in a CGI script.
> So, i inserted, at the begining of the script:
>
> open(FILE,">file");
> print FILE "Hello !";
> close(FILE);

The problem _might_ be that you are looking in the wrong directory for the
file. The current working directory for a CGI script is server specific;
not neccessarily the location of the script...

But check the return value of open anyway....

Balazs




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

Date: Tue, 09 Nov 1999 03:00:20 GMT
From: Ala Qumsieh <qumsieh@sympatico.ca>
Subject: Re: Perl/Tk looping question.
Message-Id: <38278EBB.1E2ACA8E@sympatico.ca>

joneill wrote:
> In Perl/Tk how can I get access to objects(pressing Cancel buttons,
> redrawing progress bars, etc.) while my program is in a loop (reading a
> file, generating a table, etc.) without totally compromising my
> program's performance?

For reading files, checkout the fileevent() method, which is a wrapper
around the select statement.

You should also look at the DoOneEvent method.

HTH,
--Ala

PS. It is best to ask Perl/Tk related questions in the Perl/Tk
newsgroup: comp.lang.perl.tk


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

Date: Tue, 9 Nov 1999 04:30:16 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Problem with eval and lexical scoping
Message-Id: <FKwxuG.4x4@news.boeing.com>

In article <_eoV3.54803$23.2034233@typ11.nn.bcandid.com>,
Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <FIsBH1.1Ds@news.boeing.com>,
>Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>>In article <37eff311.0@news.victoria.tc.ca>,
>>Cody Jones <ua025@vtn1.victoria.tc.ca> wrote:
>>>  my $outer_eval = '{ my $x = 1; eval \'print $x\'; }';
>>>  eval $outer_eval;
>>
>>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" }';
>
>That is not a slight change.  That is a radical change.  $x gets
>interpolated now during the outer eval.

I intended "slight" in the sense of few keystrokes although
I see why you viewed the interpolation as radical.
  
Stil, without a workaround, I notice 5.004_04 will 
incorrectly pull $x from outside the local scope:

   my $x = 5;
   my $outer_eval = '{ my $x = 1; eval \'print $x\'; }';  # prints 5


Perhaps, the non-radical workaround should be:

my $outer_eval = '{ eval \'my $x = 1; print $x\'; }'   # prints 1

--
Charles DeRykus


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

Date: Tue, 09 Nov 1999 03:51:42 GMT
From: steven_ellis@my-deja.com
Subject: Problems with a perl socket listener
Message-Id: <8085oe$4dk$1@nnrp1.deja.com>



I have some perl code that connects to a socket on an abritrary port to
listen for data. It then prints the data to stdout.

If I use telnet or rtelnet to send a large file to the server the end
of the file is missing at the server end. It appears that the socket
has closed before all the data has been read.

Note that not all of my code is here but this example should almost
work.

use Socket;

    $proto = getprotobyname('tcp');
    socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "Socket: $!";
    setsockopt(SERVER,SOL_SOCKET,SO_REUSEADDR,1) or die "Setsockopt:
$!";
    bind(SERVER, sockaddr_in( 1234, INADDR_ANY )) || die "Bind: $!";
    listen( SERVER, SOMAXCONN ) || die "listen: $!";

    for( $waitedpid = 0;
	($peer = accept( CLIENT, SERVER )) || $waitedpid;
	$waitedpid = 0, close CLIENT )
	{
	next if ($waitedpid);
	autoflush CLIENT 1;
	(undef, $peeraddr) = sockaddr_in($peer);
	$peername = gethostbyaddr( $peeraddr, AF_INET );
	&log_message("Connection from $peername
		      (",inet_ntoa($peeraddr)," )");
	$linecount = 1;
	@CONFIG = '';
	print while(<CLIENT>);

	}
    exit;

Anyone got an idea how to fix this?

Thanks


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


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

Date: Tue, 09 Nov 1999 10:04:02 +0800
From: Balaji Krishnamurthy <bakrishn@cisco.com>
Subject: setting environment variables
Message-Id: <38278112.824EC06A@cisco.com>

hi,
   how do i set environment variables in perl. i need to write a script
which would set some environment variables for both unix and win-nt. 

   i presume the setenv does not reflect the settings to the parent
shell.

   thanx in advance.

balaji


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

Date: 9 Nov 1999 03:59:44 GMT
From: lee.lindley@bigfoot.com
Subject: symbolics was [Re: FAQ 5.5: How can I manipulate fixed-record-length files?]
Message-Id: <80867g$iep$1@rguxd.viasystems.com>

David Cassell <cassell@mail.cor.epa.gov> wrote:
:>[emailed to perlfaq-suggestions also]

:>Tom Christiansen wrote:
:>[snip]
:>>   How can I manipulate fixed-record-length files?
:>[snip]
:>>         open(PS, "ps|");
:>>         print scalar <PS>;
:>>         while (<PS>) {
:>>             ($pid, $tt, $stat, $time, $command) = unpack($PS_T, $_);
:>>             for $var (qw!pid tt stat time command!) {
:>>                 print "$var: <$$var>\n";
:>                                ^^^^^
:>ACK!!  ------------------------>


:>[snip] 
:>>     We've used `$$var' in a way that forbidden by `use strict 'refs''.
:>>     That is, we've promoted a string to a scalar variable reference
:>>     using symbolic references. This is ok in small programs, but
:>>     doesn't scale well. It also only works on global variables, not
:>>     lexicals.

:>Isn't this A Bad Thing (tm) when we tell people that symrefs
:>are 'okay' in a small program?  Aren't the people who will
:>do malignant things with symrefs writing *only* small programs
:>[relatively speaking, that is]?  Wouldn't it be better to
:>remove the symref or replace it with less evil code?

To play the devils advocate, if you want to use symbolic references,
that is your business.  They exist in the language.  There are better
ways to do things now, but the useage of symbolic references is not
yet "deprecated" (unless you count the treatment under the "use
strict" pragma that way, but that is self imposed).

This particular example could be re-written with a hash slice
assignment.  IMO, there could stand to be a few more examples of hash
slices in the documentation, so if you are volunteering to rewrite
this FAQ entry then give it a shot and submit it to Tom C instead of
just sending him a complaint about it, which BTW, is unlikely to move
him.  

It would provide a multiple level lesson if the hash slice method was
shown as an alternative to symbolic references in this FAQ item. OTOH
it would add some complexity to this FAQ item that could confuse the
reader more than it helped.  Damn, this documentation design thing
isn't so easy.

I know you already know how to write it yourself, but I throw in a
rough cut anyway since it is my current favorite thing about Perl.

@varnames = qw!pid tt stat time command!;
 ...
while (<PS>) {
    @psdata{@varnames} = unpack($PS_T, $_);
    for $var (@varnames) {
	print "$var: $psdata{$var}\n";
 ...

============================================================
Can anyone list a "good" time to use symbolic references in Perl 5
for some better definition of good than the above example?  I have a
feeling that there really is a time to use them, but I can't think of
any off of the top of my head.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 08 Nov 1999 23:33:58 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: symbolics was [Re: FAQ 5.5: How can I manipulate fixed-record-length files?]
Message-Id: <x7aeoo1dxl.fsf@home.sysarch.com>

>>>>> "ll" == lee lindley <lee.lindley@bigfoot.com> writes:

  ll> Can anyone list a "good" time to use symbolic references in Perl 5
  ll> for some better definition of good than the above example?  I have a
  ll> feeling that there really is a time to use them, but I can't think of
  ll> any off of the top of my head.

for general coding it is almost never needed. that is why we constantly
harp on it being evil. it is one of those things where you know how to
use it and where it needs to be used or you don't. unfortunately newbies
don't know that.

import/export uses them. Symbol::gensym does as do other core modules.
its main uses are for black magic munging of the symbol table where it
is the only way to get the desired results.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 9 Nov 1999 05:46:44 +0100
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: tutorial or help on HTML parser
Message-Id: <80896a$mbme$1@fu-berlin.de>

Philippe <philippe.d.oreyeNOphSPAM@iname.com.invalid> wrote in message
news:0a0133f8.8f2ee231@usw-ex0102-012.remarq.com...
>
> I want to generate the TOC(table of content) of HTML documents from
> the 'H' tags, viz <H1>, <H2>, <H3>, ...
>
> Of course, I could use regular exp to do this, but as there is the
> HTML::parser and XML::parser, it's better to learn how to use them.
>
IMHO the procedural interface provided by HTML::TokeParser is easier
to use and easier to understand.
Try something like:

#!wherever/perl -w
use strict;
use HTML::TokeParser;

# if you pass a html file name on the command line
# my $p = HTML::TokeParser->new(shift||"index.html");

# if you use it as a filter
# my $p = HTML::TokeParser->new(\*STDIN);

my $x='<H1 ALIGN="CENTER">this is a H1 title</H1>
 ...
<H2 ALIGN="CENTER">this is a H2 title</H2>
 ...
';

# if you pass it a html string
my $p = HTML::TokeParser->new(\$x);

unless (defined($p)) {
  die "can't parse HTML ($!)";
}

my @Headers = ();

while (my $token = $p->get_token()) {
  my ($type, $tag, @rest) = @$token;
  if ($type eq 'S' and
      $tag  =~ /(h[1-7])/i) {
    my $text = $p->get_trimmed_text("/$tag");
    push(@Headers, [$tag, $text]);
  }
}

foreach my $Header (@Headers) {
  print $Header->[0], ": ", $Header->[1], "\n";
}




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

Date: Mon, 8 Nov 1999 18:23:36 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: what is the difference between my() and local()?
Message-Id: <slrn82emro.n6b.tadmc@magna.metronet.com>

On Sun, 07 Nov 1999 19:35:43 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <slrn829c0a.je0.tadmc@magna.metronet.com>,
>Tad McClellan <tadmc@metronet.com> wrote:
>>   Any Perl programmer who has not at least skimmed all of
>>   the Frequently Asked Questions once or twice is indeed idiotic.
>
>Tad, shut the fuck up, eh?  


   I am unable to comply with your eloquently phrased request.

   Thank you for your input though.



   Post a FAQ, get flamed. That's just how it is on Usenet.

   (although my followup wasn't particularly harsh, I even put
    a couple of smileys in there...
   )


> It's one thing to be frustrated that people
>don't know about FAQs or don't read them.  It's something else entirely
>to go looking for excuses to call people idiots.


   It was Markus, not me, that characterized him as an idiot.

   Direct your curses at _him_.

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


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

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 1324
**************************************


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