[16763] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4175 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 30 09:05:29 2000

Date: Wed, 30 Aug 2000 06:05:14 -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: <967640714-v9-i4175@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 30 Aug 2000     Volume: 9 Number: 4175

Today's topics:
    Re: `pos' after !//g <bart.lateur@skynet.be>
    Re: braincramp question on parameters being entered int (Helgi Briem)
    Re: calling CGI programs nobull@mail.com
    Re: Counting across multiple lines? (Anno Siegel)
    Re: error displaying with Perl compilator <graham.wood@iona.com>
        Extra ^M in text file nkhan75@hotmail.com
    Re: File handles with scalar value (Anno Siegel)
    Re: file locking not working (Martien Verbruggen)
    Re: file locking not working <lincolnmarr@nospam.europem01.nt.com>
        Finding a file in a huge filesystem nkhan75@hotmail.com
        ftp function call in perl change the file size. <calvin@pixelmetrix.com>
    Re: help in newfeeds (Martien Verbruggen)
        Help! ActivePerl 5.6 & Blat.exe <simon.ruzgar@nospam.btinternet.com>
        How can i change the device that system error messages  <kai@bcv01y01.vz.cit.alcatel.fr>
    Re: How can i change the device that system error messa <foo@bar.va>
    Re: How can i change the device that system error messa <hmerrill@my-deja.com>
    Re: Looking for help with list element numbering <krahnj@acm.org>
    Re: MySQL Table (Anthony Peacock)
    Re: MySQL Table <ales.romaniuk@zag.si>
    Re: MySQL Table (Anthony Peacock)
        Novice question: Interpolating embedded variables from  <trioinfoQUITAESTO@trioinfografia.com>
    Re: png/gif format <flavell@mail.cern.ch>
    Re: png/gif format (Martien Verbruggen)
    Re: png/gif format <bart.lateur@skynet.be>
    Re: Reg Exp Problem - What is wrong with this?? <bart.lateur@skynet.be>
    Re: Reg Exp Problem - What is wrong with this?? <flavell@mail.cern.ch>
    Re: replace some word in text file (Anno Siegel)
        script to retry logging on to net <geoff.cox@cableinet.co.uk>
    Re: square brackets in HERE documents (Eric Kuritzky)
    Re: square brackets in HERE documents <roman.stawski@fr.adp.com>
    Re: unpack format question (Fred R. Buck)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 30 Aug 2000 12:57:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: `pos' after !//g
Message-Id: <u51qqs02l7gk49osqaqmi5eg31kehna47d@4ax.com>

Hideaki Hase wrote:

>Is there any way to keep the return of `pos' function the value before
>the corresponding pattern matching with `g' option when the matching
>results failure?

There's the //c modifier.

-- 
	Bart.


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

Date: Wed, 30 Aug 2000 10:43:17 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: braincramp question on parameters being entered into a perl scrip
Message-Id: <39ace4fc.3883934@news.itn.is>

On Tue, 29 Aug 2000 10:57:04 +0900, Yongsik Kim
<yosikim@lgeds.lg.co.kr> wrote:

>
>
>Carrotshoes wrote:
>> 
>> Hey all, I have a perl script that I want to take in some parameters at
>> start up, I know that to get to the variables within the script its
>> 
>> $foo = $_[x] etc .  I just can seem to get the script to see the variables
>> from command line. Do I separate with commas, put it all in parenthesis or
>> what.
>separate with space or tab
>
>> I'm running ActivePerl on a win98 box. Some sample code is below to clarify
>> me.  Thanks for your help
>> 
>> #!/usr/bin/perl
>> #get the parameters here
>> $theDate  = $_[0];
>> $header  = $_[1];
>> $opening = $_[2];
>> $entry  = $_[3];
>> $closing = $_[4];
>$theDate  = $ARGV[0];
>$header  = $ARGV[1];
>$opening = $ARGV[2];
>$entry  = $ARGV[3];
>$closing = $ARGV[4];

Neater is:
my ($theDate,$header,$opening,$entry,$closing) = @ARGV;


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

Date: 30 Aug 2000 08:24:10 +0100
From: nobull@mail.com
Subject: Re: calling CGI programs
Message-Id: <u9snrnvxq8.fsf@wcl-l.bham.ac.uk>

Jonathan Palley <jpalley@jps.net> writes:

> I can probably broaden my question, if it helps to just how do you
> open a webpage in a browser from a perl cgi script?

That's "Perl CGI script".

Just why do you think the answre to this question will be different
today from it was last time it was asked in this newsgroup?  This
question is asked here just about every day.  You are expected to read
the newsgroups you post to.

Use the LWP modules.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 30 Aug 2000 12:10:29 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Counting across multiple lines?
Message-Id: <8oitjl$im8$1@lublin.zrz.tu-berlin.de>

Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:

[...]

>When tr() is used for counting, it doesn't do any replacing.

This statement may be a little misleading.  tr/// in scalar context
counts the replacements it makes, whether there are any actual
replacements (with a different character) happening or not.  The
particular variant tr///c, which can be used for character counting,
doesn't make visible replacements, but other variants ( tr///cd, for
instance) do and still count characters.

Anno


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

Date: Wed, 30 Aug 2000 12:21:00 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: error displaying with Perl compilator
Message-Id: <8oir43$qpe$1@bvweb.iona.com>

try perl my_program.txt > error.txt 2>&1

This works on NT.  The 2>&1 is telling the operating system to send the
STDERR to the same place as the STDOUT.

Graham Wood

<daniele7029@my-deja.com> wrote in message
news:8oih25$mas$1@nnrp1.deja.com...
> Hi,
>
> I m newly Perl programmer and I had downloaded ActivePerl.
> When I running compilator into Dos session (I have also window 98)
> lot of errors appears, as commun, but I can t cath the beginning
> of errors.
> I fact I d like to know how to send errors into a file like error.txt.
> I try use perl my_program.txt | more or perl my_program.txt > error.txt
> or use STDERR=error.txt but I doesn t work...
>
> I will very happy of your help.
>
> Thanks a lot.
>
> Daniele
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Wed, 30 Aug 2000 12:42:01 GMT
From: nkhan75@hotmail.com
Subject: Extra ^M in text file
Message-Id: <8oivem$5qe$1@nnrp1.deja.com>

Hello,

I am working with Perl/NT. Every time I create a text file from my
program, I find a ^M at the end of each line of the file.

Does anyone know why this is happening?

Thanks,
Nadeem


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


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

Date: 30 Aug 2000 11:05:14 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File handles with scalar value
Message-Id: <8oippa$ii7$1@lublin.zrz.tu-berlin.de>

jason  <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>QarnoS <qarnos@ozemail.com.au> wrote ..
>>I'm in the intermediate stages of learning Perl and have a question
>>which is annoying me enough to matter ;-)
>>
>>When working with the CGI module, if the submitted form contains a file
>>upload, the CGI::param method will return a scalar which doubles as a
>>filename and a file handle.
>>
>>Ie. I can do this:
>>$file = $cgi->param('uploadedfile');
>>print "Contents of $file:";
>>print <$file>;
>>
>>I was just wondering how the CGI module achieves this.
>
>this is a function of the <> operator (and the 'open', 'print' and 
>'close' functions .. and where it makes sense - all other Perl things 
>that deal with filehandles)
>
>they accept either a FILEHANDLE or a scalar containing the name of the 
>FILEHANDLE
>
>so it's quite simple for a scalar to be both a string and a filehandle

True, but that's not the case at hand.  In a text context, $file appears
to contain the name of the opened file, not of the filehandle connected
with it.  The real background is that $file is an object that overloads
some operations, as another poster explained.

Anno


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

Date: Wed, 30 Aug 2000 22:05:03 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: file locking not working
Message-Id: <slrn8qpqiu.ucf.mgjv@martien.heliotrope.home>

On Wed, 30 Aug 2000 11:14:57 +0200,
	Lincoln Marr <lincolnmarr@nospam.europem01.nt.com> wrote:
> I'm on HP-UX 10 and using Perl's flock function doesn't seem to be working
> for me. I have the O'Reilly CD bookshelf which comments that flock behaves
> like a traffic light - it's signals to stop don't have to be obeyed.

That's more or less right... Only things that pay attention to locks are
stopped by them. On *nix and *BSD*, that is.

> What I have is a CGI script, and I have the usual:
> 
> $EXCLUSIVE=2;
> $UNLOCK=8;

It's better, and easier to do

use Fcntl qw(:flock);

and use LOCK_EX and LOCK_UN. More standard, and more satisfying for
paranoid programmers who are afraind that those constants may actually
be different on different platforms. Who knows, they might even be
different on HP-UX, although I sincerely doubt it :)

> open(FILE,">>$file") || die "Can't open file, $!\n";

Checking for error and including $!, good.

> flock FILE, $EXCLUSIVE;

You should check for an error here.

> seek FILE, 0, 2;

Why do you do this seek? Do you have programs writing to the file while
you are doing this? If all programs duly lock the file, you should not
need it. It is (stylistically) slightly better, or at least more
readable, to use SEEK_END instead of a bare 2 (also available from the
Fcntl module, with the :seek tag).

> print FILE "$record\n";
> flock FILE, $UNLOCK;

You shouldn't ever need to explicitly unlock a file, and doing so might
actually get you in a race condition on some platforms and with certain
versions of perl. A close will unlock the file.

> close(FILE);
> 
> My thinking is that flock only works if another process tries to use the
> file outside of my script... so the problem is that if two or more people
> simultaneously press the submit button on my form (invoking the above code)
> then the file structure risks corruption.

I think you might bump into the same problem that many people bump into
when using flock. Locking a file with flock HANDLE, LOCK_EX only prevent
_cooperating_ programs from getting read or write access to it. In other
words, only programs that use flock will be stopped from opening the
file. If you have 50 programs that lock and unlock a file, and one that
doesn't, your data is not safe, and not guaranteed to be consistent.
This is called an advisory locking scheme.

> I know this may be more of a unix question but I'm stumped at the moment and
> was wondering if there's any other perl command to firmly lock a file?? If
> not does anybody know what's going on here?

There is no kernel or file system level locking on standard unices. I
personally never have had the need for it. Mabe, if you explain why you
feel you _do_ have a need for it, people on comp.unix.programmer can
give you general techniques to work around this, or point you in
directions of mandatory locking schemes for Unix and derivates. But I
suspect that you don't really need mandatory locking in the first place.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


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

Date: Wed, 30 Aug 2000 14:59:33 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: Re: file locking not working
Message-Id: <8oj0f8$pia$1@qnsgh006.europe.nortel.com>


>
> I think you might bump into the same problem that many people bump into
> when using flock. Locking a file with flock HANDLE, LOCK_EX only prevent
> _cooperating_ programs from getting read or write access to it. In other
> words, only programs that use flock will be stopped from opening the
> file. If you have 50 programs that lock and unlock a file, and one that
> doesn't, your data is not safe, and not guaranteed to be consistent.
> This is called an advisory locking scheme.

Does Perl have any command which makes it take notice of the file lock??  I
don't want 2 or more people running my script to be able to write to the
same file simultaneously, because of the risk of data corruption - meaning
that junk is outputted to the browser.

The only thing that will be accessing the files is the script - so it's the
only thing that I want to take notice of the file lock... but I'm not sure
how. Suggestions anyone?






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

Date: Wed, 30 Aug 2000 12:32:33 GMT
From: nkhan75@hotmail.com
Subject: Finding a file in a huge filesystem
Message-Id: <8oiut1$55d$1@nnrp1.deja.com>

Hello,

My problem is as follows:

I need to find a file, say foo.txt, in a file tree that contains
several thousand files. Just traversing through the tree takes over 2
hours on a strong machine. Hence I need to come up with Perl code
which, as soon as it finds the file, stops the search. Ofcourse, if the
file does not exist the code will step through all the files in the
tree looking for foo.txt.

Can anyone please guide me (a novice at Perl)?

Thanks,
Nadeem


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


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

Date: Wed, 30 Aug 2000 21:08:30 +0800
From: calvin <calvin@pixelmetrix.com>
Subject: ftp function call in perl change the file size.
Message-Id: <39AD074E.F62F6763@pixelmetrix.com>

Hi all,

When I used the "ftp.pl" in my source code to ftp and get some target
file, I found the file size I got would be changed. What happened? And
How to fix the problem?

Thank you.

Rgds,
Calvin




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

Date: Wed, 30 Aug 2000 22:20:05 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: help in newfeeds
Message-Id: <slrn8qprf5.ucf.mgjv@martien.heliotrope.home>

On Wed, 30 Aug 2000 16:13:29 +0800,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
	Mo Jiazhou <isc80031@nus.edu.sg> wrote:
> hi, people, how do i draw news feed from another content site by perl?
> any one is familiar with this? where can i find some sample code? or where
> can i know more about it?

\begin{lecture}

Euhmm.. You asked the same question yesterday. Part of one of your
followups in the thread there is:

> From: "Wowo" <mojiazho@hotmail.com>
> Newsgroups: comp.lang.perl.misc
> Message-ID: <22E71DAEC504D111B78100805FFE9DC73E8A8EF5@pfs21.ex.nus.edu.sg>
> Subject: Re: get newsfeeds from a content site with perl?
> Date: Wed, 30 Aug 2000 10:32:11 +0800
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> oh, i guess u don't even know what it is newsfeeds.
> 
> but never mind, i have work it out by myself.

Which according to the timestamps is slightly less than six hours
_before_ you reposted the exact same question. Part of that original
thread even went into the problem that you might not have been clear
enough in your question. reposting the question is not going to make it
more likely to get an answer.

If you choose to repost a question, which in itself is bad behaviour,
you could at least rephrase the question to include some of the
knowledge you have gained in the meantime. _Especially_ if someone has
already remarked upon the ambiguity in the original question.

\end{lecture}

Now, WHAT is it that you are trying to do? be an NNTP news client? There
are modules for that on CPAN, at http://www.cpan.org/. 

Get a real newsfeed? You will need a NNTP _server_ for that, and an
agreement with another server. Ask in another group, and get something
like inn (do a search on the web). If you really have a lot of time, you
could even write one yourself, probably, with some modules from CPAN. 

Are you really talking about Web pages that contain news items? Use the
LWP modules, available from CPAN. 

If you're lazy, like me, and don't want to spend days reinventing the
wheel, and what you really want is a local news spool, but not a full
server with feeds, you get something like leafnode, and set that up (do
a search on the web, not a perl subject.

Now, I think I'll just put you in my killfile before you really start to
annoy me.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


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

Date: Wed, 30 Aug 2000 11:13:57 GMT
From: "Simon" <simon.ruzgar@nospam.btinternet.com>
Subject: Help! ActivePerl 5.6 & Blat.exe
Message-Id: <V%5r5.10446$NR3.1303373@news1.cableinet.net>

Hey everyone I'm having trouble getting thhe following script to work on an
NT Server running ActivePerl 5.6 with blat.exe  teh url of teh test form is
http://uspr.co.uk/form.html it looks to run ok but the e-mail message never
arrives :`)  The script was originaly written to run on Unix using sendmail.

Would greatly appreciate your help

Thanks
Simon

#!/usr/bin/perl -- -*-perl-*

# Define fairly-constants

# mail program on your system (server your site is beeing hosted on).
$mailprog = 'blat.exe';

# recipient of all processed mail.
$recipient = 'simon.ruzgar@btinternet.com';

# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";

# Print initial html (e.g. title ) to be returned to client
print <<startReturnHTML;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>contact</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#663399" VLINK="#C0C0C0"
ALINK="#FF8000">

startReturnHTML


# Process the input arriving from your HTML <FORM>
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);

    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    $value =~ s/~!/ ~!/g;

    # Uncomment for debugging purposes
    # print "Setting $name to $value<P>";

    $form{$name} = $value;
}

#Get time
$time_now = localtime;

#Send mail
#open(MAIL, "|$mailprog -t $form{'to'}") || die "Can't open $mailprog!\n";
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "From: $form{'name'},\n";
print MAIL "Subject: Contact Information.\n";
print MAIL "X-Mailer: mailcgi 1.0\n";
#Terminate mail headers.
print MAIL "\n";
print MAIL "Hi Simon,\n";
print MAIL "\n";
print MAIL "$form{'Name'} came by the website and filled out the contact
form.\n";
print MAIL "\n";
print MAIL "Detail's:\n";
print MAIL "Name:  $form{'name'}\n";
print MAIL "Phone: $form{'phone'}\n";
print MAIL "Email:  $form{'email'}\n";
print MAIL "\n";
print MAIL "\n";
close(MAIL);

# Print remining html to be returned to client
print <<endReturnHTML;

Thank you! $form{'name'}

</BODY>
</HTML>

endReturnHTML






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

Date: Wed, 30 Aug 2000 13:21:20 +0200
From: Fu Kai <kai@bcv01y01.vz.cit.alcatel.fr>
Subject: How can i change the device that system error messages print to?
Message-Id: <39ACEE30.C8B45F88@bcv01y01.vz.cit.alcatel.fr>

HI,

I am new player of Perl,and i want to know if it is possible to let
system print the error messages to
a special file like error.log,not the default STDERR,cauz i dont want
the error messages display on
the screen when the program running.

Any help is appreciated.


--
Kai





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

Date: Wed, 30 Aug 2000 13:49:52 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: How can i change the device that system error messages print to?
Message-Id: <39ACF4E0.67FF7939@bar.va>

Fu,

Fu Kai wrote:
> I am new player of Perl,and i want to know if it is possible to 
> let system print the error messages to a special file 
> like error.log,not the default STDERR,cauz i dont want the 
> error messages display on the screen when the program running.

  RTFM.  From the open manual page (perldoc -f open):

<cite>
	Here is a script that saves, redirects, and restores STDOUT 
	and STDERR:

	    #!/usr/bin/perl
	    open(OLDOUT, ">&STDOUT");
	    open(OLDERR, ">&STDERR");

	    open(STDOUT, ">foo.out") || die "Can't redirect stdout";
	    open(STDERR, ">&STDOUT") || die "Can't dup stdout";

	    select(STDERR); $| = 1;     # make unbuffered
	    select(STDOUT); $| = 1;     # make unbuffered

	    print STDOUT "stdout 1\n";  # this works for
	    print STDERR "stderr 1\n";  # subprocesses too

	    close(STDOUT);
	    close(STDERR);

	    open(STDOUT, ">&OLDOUT");
	    open(STDERR, ">&OLDERR");

	    print STDOUT "stdout 2\n";
	    print STDERR "stderr 2\n";
</cite>


	Best regards,
		Marco


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

Date: Wed, 30 Aug 2000 12:40:14 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: Re: How can i change the device that system error messages print to?
Message-Id: <8oivbc$5ie$1@nnrp1.deja.com>

In article <39ACEE30.C8B45F88@bcv01y01.vz.cit.alcatel.fr>,
  Fu Kai <kai@bcv01y01.vz.cit.alcatel.fr> wrote:
> HI,
>
> I am new player of Perl,and i want to know if it is possible to let
> system print the error messages to
> a special file like error.log,not the default STDERR,cauz i dont want
> the error messages display on
> the screen when the program running.

Here is a portion of the info that I got by doing
"perldoc -q STDERR":

=head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq8.pod

=head2 How can I capture STDERR from an external command?

There are three basic ways of running external commands:

    system $cmd;                # using system()
    $output = `$cmd`;           # using backticks (``)
    open (PIPE, "cmd |");       # using open()

With system(), both STDOUT and STDERR will go the same place as the
script's versions of these, unless the command redirects them.
Backticks and open() read B<only> the STDOUT of your command.

With any of these, you can change file descriptors before the call:

    open(STDOUT, ">logfile");
    system("ls");

---------- end of section taken -----------------
So, you should be able to do
    open(STDERR, ">your_own_logfile");

and have the STDERR messages be written to that log file.

HTH.

--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

>
> Any help is appreciated.
>
> --
> Kai
>
>


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


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

Date: Wed, 30 Aug 2000 05:44:20 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Looking for help with list element numbering
Message-Id: <39AD01A4.584F34CB@acm.org>

Jody Fedor wrote:
> 
> The following program produces a list of filenames from a transfer.log file.
> I find the unique file names but would like to count the number of times
> these files are found in the log.  I don't know a good way to do this.  Any
> help?
> 
> (Would like an output similar to:
> index.htm 6
> toner.htm 12
> inkjet.htm 8  etc. etc. etc. )
> 
> Thank you.
> 
> #!c:\perl -w
> 

open INFILE, 'c:/perl/logs/transfer.log' or die "Can't read
transfer.log: $!\n";


> print "reading transfer1.log\n";
> 

while ( <INFILE> ) {
	chomp;
	if ( m#.*] "GET /cgi-bin/serve.pl/\d+/(.*\.htm) .*# ) {
		$seen{ $1 }++ if length $1 < 30;
	}
}

close INFILE;

foreach $uniq ( sort keys %seen ) {
	print "$uniq  $seen{$uniq}\n";
}


HTH

John


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

Date: 30 Aug 2000 10:05:55 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: MySQL Table
Message-Id: <8oima3$l26$1@uns-a.ucl.ac.uk>

In article <MPG.1416cae8686f972d989682@news.siol.net>, ales.romaniuk@zag.si 
says...
>
>Hi !
>
>Can anyone tell me, how to obtain information about table into Perl.
>I would like to know field name, field type, size, is it key etc..

RTFM:

http://www.mysql.com/documentation/mysql/mysql/commented/manual.php?section=SHO
W

Issue this command using the usual DBI/DBD interface.



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

Date: Wed, 30 Aug 2000 12:53:33 +0200
From: Marvin <ales.romaniuk@zag.si>
Subject: Re: MySQL Table
Message-Id: <MPG.1417061932fad6f7989683@news.siol.net>

In article <8oima3$l26$1@uns-a.ucl.ac.uk>, a.peacock@chime.ucl.ac.uk 
says...
> In article <MPG.1416cae8686f972d989682@news.siol.net>, ales.romaniuk@zag.si 
> says...
> >
> >Hi !
> >
> >Can anyone tell me, how to obtain information about table into Perl.
> >I would like to know field name, field type, size, is it key etc..
> 
> RTFM:
> 
> http://www.mysql.com/documentation/mysql/mysql/commented/manual.php?section=SHO
> W
> 
> Issue this command using the usual DBI/DBD interface.
> 
> 
I am using DBI/DBD interface all the time, I just haven't had any need 
for obtaining field specifications till now. And in Perl DBI book I 
didnt find anything usable.

Regards


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

Date: 30 Aug 2000 12:34:50 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: MySQL Table
Message-Id: <8oiv1a$nke$1@uns-a.ucl.ac.uk>

In article <MPG.1417061932fad6f7989683@news.siol.net>, ales.romaniuk@zag.si 
says...
>
>In article <8oima3$l26$1@uns-a.ucl.ac.uk>, a.peacock@chime.ucl.ac.uk 
>says...
>> In article <MPG.1416cae8686f972d989682@news.siol.net>, ales.romaniuk@zag.si 
>> says...
>> >
>> >Hi !
>> >
>> >Can anyone tell me, how to obtain information about table into Perl.
>> >I would like to know field name, field type, size, is it key etc..
>> 
>> RTFM:
>> 
>> 
http://www.mysql.com/documentation/mysql/mysql/commented/manual.php?section=SH
>O
>> W
>> 
>> Issue this command using the usual DBI/DBD interface.
>> 
>> 
>I am using DBI/DBD interface all the time, I just haven't had any need 
>for obtaining field specifications till now. And in Perl DBI book I 
>didnt find anything usable.

That is because the command you need is a mySQL one!

Follow the URL I posted above and it will give you the description and syntax 
of the SHOW command.  You can use this to view various pieces of meta data 
about the database.

(PS Please note that the URL has been wrapped.)



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

Date: Wed, 30 Aug 2000 14:42:16 +0200
From: "Toni" <trioinfoQUITAESTO@trioinfografia.com>
Subject: Novice question: Interpolating embedded variables from a template file
Message-Id: <8oivgo$5a0g54@SGI3651ef0.iddeo.es>

Hello!

I've a template html file where I've embedded scalar vars in this way:

 ...
<TD> Today is $date </TD>
 ...

I want to generate files with this embedded vars interpolated to the value
calculated in the script, using something like this :

foreach $_ (<TEMPLATE>){
  print OUTPUT_FILE $_;
}

I hope I've been explained OK, my english is not enough good
Can anybody help me?

THANKS


(Sorry for the cross-posting to comp.lang.perl)




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

Date: Wed, 30 Aug 2000 11:54:03 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: png/gif format
Message-Id: <Pine.GHP.4.21.0008301139580.12815-100000@hpplus03.cern.ch>

On Wed, 30 Aug 2000, Ivan Murray wrote:

> I'm playing with Multi Router Traffic Grapher (www.mrtg.org) and it seems
> perl is producing PNG and GIF files incorrectly.

MRTG has always worked fine for me, so I'd say you're doing something
wrong.

Whether it's a Perl problem is entirely unclear from your totally
inadequate description.

MRTG has a mailing list, and there's some kind of archive access too.

> It outputs an html file with graphs. When you view the html in a
> browser, the graphs dont load and the progress bar does not move.
> When you get the properties of the graph placeholder within the
> browser, it reports the size as -1.

And you haven't even bothered to look in the work subdirectory, where
the HTML pages and the images are created, to find what's there?

> Any ideas?

I'm afraid so.  On the basis of what you have posted, you don't seem
to have much of a clue how to go about diagnosing problems.

For all that we know, you might be creating .png files while having
the program write HTML that's trying to call out .gif files instead.

There isn't the slightest evidence in your posting that you have a
Perl programming problem.   When you have, then you would be on-topic
here, but until then, you're just going to cause frustration to
yourself and everyone else.

good luck




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

Date: Wed, 30 Aug 2000 22:25:39 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: png/gif format
Message-Id: <slrn8qprpj.ucf.mgjv@martien.heliotrope.home>

On Wed, 30 Aug 2000 14:20:07 +1200,
	Ivan Murray <imurray@wel.co.nz> wrote:
> I'm playing with Multi Router Traffic Grapher (www.mrtg.org) and it seems
> perl is producing PNG and GIF files incorrectly. It outputs an html file
> with graphs. When you view the html in a browser, the graphs dont load and
> the progress bar does not move. When you get the properties of the graph
> placeholder within the browser, it reports the size as -1.

I get some emails from people using mrtg now and again, because for some
reason they seem to think I have something to do with it (while I never
even have looked at it, or installed it). Maybe it uses GD::Graph, and
the author left a copyright notice in the program, which I appreciate.

Anyway, most of the time people have troubles like this, it's because
they have a wrong version of GD or the wrong libgd, or they compiled GD
wrong or something like that.

The only person who can find out is you. Go to the place where mrtg puts
its output. Look at the files. Read the code, and see what its doing. If
it isn't clear, write to the author of the program. 

mrtg might be written in Perl, but that doesn't make 
- any bugs in the program, or 
- insufficient diagnostics, or 
- you not doing what the installation instructions told you, or 
- incorrect versions of modules or libraries, 
a perl issue. Just like bugs in Microsoft's products never are a C or
C++ issues, even though those are the languages that they most
frequently use.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: Wed, 30 Aug 2000 12:57:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: png/gif format
Message-Id: <b31qqs4g293s0cs2bv6nk408ffa0cgjgbt@4ax.com>

Ivan Murray wrote:

>I'm playing with Multi Router Traffic Grapher (www.mrtg.org) and it seems
>perl is producing PNG and GIF files incorrectly.

You're trying this on a PC? Check if they used binmode() in papropriate
places. It's a noop on Unix, but on a PC, it's absolutely VITAL in order
to correctly create binary files.

   HTH,
   Bart.


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

Date: Wed, 30 Aug 2000 12:08:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Reg Exp Problem - What is wrong with this??
Message-Id: <k5tpqsk62sr9vus73jb6ok3i35h88ginfp@4ax.com>

Scott wrote:

>> Ah. If that's what you are doing, be very careful about what HTML
>> you let people submit. There are very devious ways of sticking
>> malicious javascript into HTML.
>
>What kind of bad things might someone do?  Certainly nothing that could
>trash the server or someone's machine other than locking up the browser,
>right?

I once did a HTML preparser, using HTML::TokeParser (part of the
HTML::Parser package) which simply eliminated tags I didn't need; and
comments as well. Pure text ("T") is passed as is, on "S" and "E" tags,
the tag ($token->[1]) is checked against a hash of allowable tags, and
if it is allowable, pass the original text ($token->[-1]). It works
pretty nicely, and the code is short, too. I've just rewritten it from
scratch:

	use HTML::TokeParser;
	my %allowed = map { lc $_ => 1 } qw(P BR HR A IMG I B U);
	# don't forget to set $file to the filename
	my $p = new HTML::TokeParser($file);
	# $p->get_tag('body');	# skip header
				# if it's a complete HTML file
	while(my $token = $p->get_token) {
	    if($token->[0] eq 'T') {
		# pure text
	        print $token->[-1];
	    } elsif($token->[0] eq 'S' or $token->[0] eq 'E') {
		#opening or closing tag	
	        print $token->[-1] if $allowed{$token->[1]};  
	    }
	}

Pass a reference to the scalar holding the html text to new(), if you
don't want to read it from a file.

And you could end up with a html file containing a lot of empty lines.
Filter them out at will.

-- 
	Bart.


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

Date: Wed, 30 Aug 2000 14:21:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Reg Exp Problem - What is wrong with this??
Message-Id: <Pine.GHP.4.21.0008301418330.12815-100000@hpplus03.cern.ch>

On Wed, 30 Aug 2000, Scott wrote:

> > Ah. If that's what you are doing, be very careful about what HTML
> > you let people submit. There are very devious ways of sticking
> > malicious javascript into HTML.
> 
> What kind of bad things might someone do? 

You haven't been keeping up with your CERT alerts.

http://www.cert.org/advisories/CA-2000-02.html

You could make yourself jointly liable, for facilitating an attack by
third parties.  IANAL, please get advice from a practitioner licensed
to operate in your jurisdiction.



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

Date: 30 Aug 2000 12:27:40 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: replace some word in text file
Message-Id: <8oiujs$inh$1@lublin.zrz.tu-berlin.de>

Keith Calvert Ivey <kcivey@cpcug.org> wrote in comp.lang.perl.misc:

[...]

>But the normal Perl idiom for slurping a whole file would be
>
>    { local $/; $File = <FILE>; }

 ...or even

     read FILE, $File, -s FILE;

Anno


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

Date: Wed, 30 Aug 2000 10:25:26 GMT
From: Geoff Cox <geoff.cox@cableinet.co.uk>
Subject: script to retry logging on to net
Message-Id: <lrnpqs079e962hm6qa9o8je5nsjlnhcf4c@4ax.com>

Hello,

I have a cron script to connect to the Internet

/usr/sbin/pppd
/bin/sleep 40
u -l -c /usr/bin/fetchmail majordom
/bin/sleep 40
/etc/ppp/stop

but......... am getting quite a few engaged calls for the ISP - any
idea how I carry out say 5 redials before waiting for the next cron
connect ? 

Cheers

Geoff


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

Date: 30 Aug 2000 10:14:40 GMT
From: kuritzky@math.berkeley.edu (Eric Kuritzky)
Subject: Re: square brackets in HERE documents
Message-Id: <8oimqg$dr6$1@agate.berkeley.edu>

In article <slrn8qpkjm.dqh.marcel@gandalf.local>,
Marcel Grunauer <marcel@codewerk.com> wrote:
>On Wed, 30 Aug 2000 09:12:10 GMT, Ronny <ronald_f@my-deja.com> wrote:
>
>>Say I have a scalar $x, which contains "abc", and I want to build the
>>string "abc[]". Since "$x[]" does not work - it would interpret x as an
>>array - I would write this as
>>	$x."[]"
>>
>>But how can I do this, if I'm inside a HERE document? I.e.:
>>
>>$r=<<!END
>>...
>>$x[]  <--- does not work of course
>>...
>>!END
>>;
>
>
>    $x\[]
>

${x}[] also works.


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

Date: Wed, 30 Aug 2000 12:42:24 +0200
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: square brackets in HERE documents
Message-Id: <39ACE510.3000701@fr.adp.com>

Marcel Grunauer wrote:

> On Wed, 30 Aug 2000 09:12:10 GMT, Ronny <ronald_f@my-deja.com> wrote:
> 
> >Say I have a scalar $x, which contains "abc", and I want to build the
> >string "abc[]". Since "$x[]" does not work - it would interpret x as an
> >array - I would write this as
> >	$x."[]"
> >
> >But how can I do this, if I'm inside a HERE document? I.e.:
> >
> >$r=<<!END
> >...
> >$x[]  <--- does not work of course
> >...
> >!END
> >;
> 
> 
>     $x\[]

TMTOWTDI

${x}[]

-- 




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

Date: Wed, 30 Aug 2000 12:20:13 GMT
From: frbuck@bell-labs.com (Fred R. Buck)
Subject: Re: unpack format question
Message-Id: <39acfbcb.141774771@nntpa.cb.lucent.com>

kcivey@cpcug.org (Keith Calvert Ivey) wrote:

>frbuck@bell-labs.com (Fred R. Buck) wrote:
>
>>	($id, $idx, $count, $length, @binblock, $progn, $pcount) =
>>unpack('IISIC128II', $header);
>>
>>given the script fragment above my problem is the number of bytes
>>extracted into @binblock.  When I run the script $#binblock yields 129
>>and empty values for $progn and $pcount. $id, $idx, $count and $length
>>all contain appropriate values after the unpack.
>
>Larry Rosler has already explained the problem.  One possible
>solution would be to use an array slice instead of an array.
>Replace @binblock with @binblock[0 .. 127].  But are you sure
>you want the data to be an array rather than just a string?  
>It doesn't seem very Perlish.
>
>-- 
>Keith C. Ivey <kcivey@cpcug.org>
>Washington, DC
 
You are right, using a string makes everything flow much smoother.
thanks.


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

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


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