[13683] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1093 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 16 10:05:40 1999

Date: Sat, 16 Oct 1999 07:05:10 -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: <940082710-v9-i1093@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 16 Oct 1999     Volume: 9 Number: 1093

Today's topics:
    Re: 200+ messages a day and still repetitive? (Tad McClellan)
        [iterative] pattern matching berkan@my-deja.com
    Re: and versus && <flavell@mail.cern.ch>
    Re: backup to change <gellyfish@gellyfish.com>
        Convert time-date string to epox seconds, <mark@compumix.com>
    Re: Convert time-date string to epox seconds, <marcel.grunauer@lovely.net>
    Re: getting variables embeded in string to be evaluated (Tad McClellan)
    Re: Help with extracting a portion of a string (Abigail)
    Re: Help! I'm writing simple translation script <marcel.grunauer@lovely.net>
    Re: Help! I'm writing simple translation script (Abigail)
        how to read an excel sheet (Patrick G.)
    Re: how to read an excel sheet <marcel.grunauer@lovely.net>
        Need help with seek/sysseek <greynite@mindspring.com>
    Re: Need help with seek/sysseek <marcel.grunauer@lovely.net>
    Re: Newbie question about time <Gizzzmo@pandora.be>
    Re: Newbie Question <martin@mert.globalnet.co.uk>
    Re: Perl and Excel <gellyfish@gellyfish.com>
        Placeholder problem with DBI::ODBC <andrew_dear@hotmail.com>
    Re: Please Help a newbie !!! <gellyfish@gellyfish.com>
        please help the telnet program (gator@apl.jhu.edu)
        qr operator the $_ <marcel.grunauer@lovely.net>
    Re: qr operator the $_ <marcel.grunauer@lovely.net>
    Re: reading binary data files <greynite@mindspring.com>
    Re: reading binary data files (Martien Verbruggen)
    Re: retrieve url from hypertext (Michel Dalle)
    Re: retrieve url from hypertext (Tad McClellan)
        Testing CGI scripts on win 98 <martin@mert.globalnet.co.uk>
    Re: Testing CGI scripts on win 98 <marcel.grunauer@lovely.net>
    Re: Testing CGI scripts on win 98 <wyzelli@yahoo.com>
        Unix Utilities: Perl Versions bayinnaung@my-deja.com
        Working on separate records in a file (Pfash1)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 16 Oct 1999 04:07:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 200+ messages a day and still repetitive?
Message-Id: <6nb9u7.hd6.ln@magna.metronet.com>

Brett W. McCoy (bmccoy@foiservices.com) wrote:
: Also Sprach Nolen Johnson <nolenj@worldnet.att.net>:

: >A closing note:
: >  Don't be afraid of crashing your computer a few times...In today's
: >technology most operating
: >systems wil probably recover.
: >  It is so cool when you finally figure something out on your own...if you
: >ever experience the
: >thrill, I guarantee you will think you are king of the world.

: I have found that I learn more by answering questions than asking them...


   I have found that I learn more by answering questions incorrectly
   than asking them  :-(

   Embarrassing myself in front of thousands of people when somebody
   jumps in to correct my answer is very powerful in helping to
   "internalize" the concept.   :-)


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


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

Date: Sat, 16 Oct 1999 12:47:40 GMT
From: berkan@my-deja.com
Subject: [iterative] pattern matching
Message-Id: <7u9s5a$8in$1@nnrp1.deja.com>

Hi,

Problem:

I have a string:  $string = "babbbab";

I want to find all possible ways of matching the pattern
b+ab+ on $string, put brackets around the match (ie create
a new string with s//g), and store all the new strings in
an array so that my array at the end looks like this:

@array = ("[babbb]ab", "[babb][bab]", "[bab][bbab]");

Knowing that the perl engine uses an NFA to do pattern
matching, is there a way to utilize it so that it returns
all possible matches (maybe iteratively) until it runs
out? (as opposed to running in one of the greedy or
minimalist modes and returning just one match).

The problem above is just an example. I would like to have
this functionality for any string and pattern. Any ideas?

Hopelessly yours,

Berkan


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


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

Date: Sat, 16 Oct 1999 14:50:09 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: and versus &&
Message-Id: <Pine.HPP.3.95a.991016144720.6256B-100000@hpplus01.cern.ch>

On Fri, 15 Oct 1999, R. McGillis blurted out:

> Thanks folks. You have all been very helpful with the exception of
> Abigail, 

Which only goes to show that you're not ready for Abigail's class of
advice yet.  That's nothing to whine about.  I don't suppose I'm ready
for it yet either, but I'm still glad it's there.


[another jeopardendectomy brings relief]



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

Date: 16 Oct 1999 10:37:23 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: backup to change
Message-Id: <7u9kh3$2s8$1@gellyfish.btinternet.com>

On Fri, 15 Oct 1999 15:08:21 GMT Paul D wrote:
> I'll take a stab at this.. I'm doing it with something I'm making now
> actually for the purposes of dealing with possible multiple accesses to
> text files. Here's an idea for you..HEAVILY commented for your pleasure
> :-)
> 
> $File variable holds your original file's filename 
> 
> # First we'll make a filename from your file but replace
> # those last 3 characters from its .ext with .lok
> $FileLock = $File; $FileLock =~ s/(.{3})$/lok!i;

And what is wrong with flock ?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 12:59:14 +0200
From: Mark Bakker <mark@compumix.com>
Subject: Convert time-date string to epox seconds,
Message-Id: <38085A82.38BEBD34@compumix.com>

Does anyone know a simple way to convert a date-time string (YYYY-MM-SS
HH:MM:SS) to epox seconds?



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

Date: Sat, 16 Oct 1999 11:40:34 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Convert time-date string to epox seconds,
Message-Id: <6nEIOHWcK3SOh=xUg1VUFRasKPat@4ax.com>

On Sat, 16 Oct 1999 12:59:14 +0200, Mark Bakker <mark@compumix.com>
wrote:

> Does anyone know a simple way to convert a date-time string (YYYY-MM-SS
> HH:MM:SS) to epox seconds?

Time::Local has what you need:

#!/usr/bin/perl -w

use strict;
use Time::Local;

my $t = '1999-10-16 13:39:20';
my ($year, $month, $day, $hour, $min, $sec) =
	($t =~ /^(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/);
print timelocal($sec,$min,$hour,$day,$month,$year);


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Fri, 15 Oct 1999 15:44:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: getting variables embeded in string to be evaluated
Message-Id: <c708u7.076.ln@magna.metronet.com>

Bill (wlanahan@att.com) wrote:

: Subject: getting variables embeded in string to be evaluated


   Perl FAQ, part 4:

      "How can I expand variables in text strings?"


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


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

Date: 16 Oct 1999 05:15:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help with extracting a portion of a string
Message-Id: <slrn80gk1h.q8s.abigail@alexandra.delanet.com>

Brandon (pooka@cygnus.ucdavis.edu) wrote on MMCCXXXVII September MCMXCIII
in <URL:news:3807CE0E.6C0EC131@cygnus.ucdavis.edu>:
--
-- I don't need to convert an _arbitrary_ CFG into a DFA, just the one that
-- describes the language of HTML comments. That language seems to adhere
-- to the pumping lemma, so it is my belief that it is regular. I'll even
-- offer a quick proof:

Pointless proof, as the text you are parsing isn't comments - it's HTML.
And HTML cannot be described as a regular expression.


Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


  -----------== 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: Sat, 16 Oct 1999 10:03:23 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Help! I'm writing simple translation script
Message-Id: <TFgIOFYpNAMjwDpnJjlHersMjpA2@4ax.com>

On Sat, 16 Oct 1999 17:06:22 +0900, Choi Jin-Ho <choijinh@hitel.net>
wrote:

>  2) convert HTML text to word blocks, separated by
>     HTML tags or spaces.
> 
>     like this :
> 
>     <p>This is <a href="somesite.htm">heart failure</a>
> 
>     ==>
> 
>     $html = ('<p>', 'This', 'is', '<a href="somesite.htm">',
>              'heart', 'failure', '</a>);

Did you copy-and-paste this or just type it in? The last array element
is missing a quote, and you assign the whole list to a scalar, so
'</a>' is assigned to $html. Use @html instead.

>     (I use this script :
> 
> 	$html = get "$url";
> 
> 	@html = split (/[\r\n]|[\r]|[\n]/, $html);
> 
> 	print "Content-type: text/html\n\n";
> 
> 	foreach (@html) {
> 		$line= $_;
> 		push @line, $1 while $line =~ /([^\t
> <>]+|<(?:[^">]+|"[^"]+")*>)/g;

This regex fares better than other attempts at parsing HTML using a
simple regex, but it doesn't handle nested comments, for example.
Maybe you should use HTML::Parser or Parse::RecDescent?
Check deja.com for similar discussions in this group.

>  3) convert medical english words to medical korean words.
>     there are some compound words (consist of more than
>     two words), so I'll try max to 4 words.
> 
>     $html = ('<p>', 'This', 'is', '<a href="somesite.htm">',
>              'heart', 'failure', '</a>);
> 
>     ==>
> 
>     $korean_html = ('<p>', 'This', 'is', '<a
> href="somesite.htm">',
>              'SIM-BU-JEON', '</a>);

You could use a hash to translate words, like this:

my %trans =
	('heart failure' => 'SIM-BU-JEON',
	 'english word'  => 'korean word');

my @trans_html = map { exists $trans{$_} ? $trans{$_} : $_ } @html;

Of course, you should allow for different cases by either using lc()
or uc() at the beginning of the map block, or maybe using a
case-insensitive hash (cf. Tie:: modules).


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: 16 Oct 1999 07:04:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help! I'm writing simple translation script
Message-Id: <slrn80gqdn.q8s.abigail@alexandra.delanet.com>

Choi Jin-Ho (choijinh@hitel.net) wrote on MMCCXXXVII September MCMXCIII
in <URL:news:380831FE.723AB105@hitel.net>:
() To perl gurus ..

Well, your problem isn't a Perl problem, it's more a general programming
problem. Your question about a certain algorithm - not its implementation
in Perl. Followup questions about the algorithm should be posted to
comp.programmer. (But since I don't read that group by default, you
should Cc me as well - that is, if you want me to read the question.)

() 	$html = get "$url";

Why the quotes around $url?

() 	@html = split (/[\r\n]|[\r]|[\n]/, $html);

Eh? That's an extremely silly way to write /[\r\n]/. 
And why splitting on newlines? Newlines don't have any special meaning
in HTML - they are just like any other whitespace.

() 	foreach (@html) {
() 		$line= $_;
() 		push @line, $1 while $line =~ /([^\t
() <>]+|<(?:[^">]+|"[^"]+")*>)/g;

That would fail on tags containing a newline, or attribute values
surrounded by single quotes, or attribute values containing '>'.

Use HTML::Parser. HTML::Parser doesn't parse, but it tokenizes, (not
really HTML, but something that might be reasonable close to work for
you - just don't try using it on documents containing elements with
CDATA declared content), and you're tokenizing as well.

()  3) convert medical english words to medical korean words.
()     there are some compound words (consist of more than
()     two words), so I'll try max to 4 words.
() 
()     $html = ('<p>', 'This', 'is', '<a href="somesite.htm">',
()              'heart', 'failure', '</a>);
() 
()     ==>
() 
()     $korean_html = ('<p>', 'This', 'is', '<a
() href="somesite.htm">',
()              'SIM-BU-JEON', '</a>);
() 
()     (SIM-BU-JEON means 'heart failure' in korean)
() 
() 
() I succeed at step 1) and 2) with help of net friends,
() but step 3 is not easy to me.
() 
() I have english-korean medical glossary, so at first I thought
() this would not difficult. But soon I found most of medical term
() is consisted with more than two words, so I got trouble.
() 
() Can anyone provide me knowhow to process more than two
() words ?


Easy. Preprocess your dictionary. For the sake of the argument,
lets assume the format is:

     ENGLISH:KOREAN

with one translation on each line; English and Korean separated
by a colon. The English term can consist of several words.

Now, create a datastructure like this:

     my $dict  = {};
     my $token = "&&**&&**&&";  # As long as it isn't a possible word.
     while (<DICT>) {           # DICT is a filehandle to the dictionary.
         chomp;
         my ($english, $korean) = split /\s*:\s*/ => $_, 2;
         my @words = split ' '  => $english;
         my $d;
         for ($d = $dict; @words; $d = $d -> {shift @words} ||= {}) {}
         $d -> {$token} = $korean;
     }


This will create a data structure of the form:

$dict = {
    heart  =>  {failure  =>  {$token => 'SIM-BU-JEON'},
                $token   =>  'Whatever "heart" in Korean is'},
    lung   =>  {cancer   =>  {$token => 'Lung cancer in Korean'},
                $token   =>  'Lung in Korean'},
    index  =>  {finger   =>  {$token => 'Korean for "index finger"'},
    ...
}


Now, assume you have properly tokenized the English HTML, and we're
only translating chunks that have no tags; just words.

Let the array @english be an array consisting of English words. We
translate as follows:

    my @korean;
    while (@english) {
        my $korean = $english [0];
        my $length = 0;
        for (my ($i, $d) = (0, $dict);
             $i < @english and $d = $d -> {$english [$i]};
             $i ++) {
            if (exists $d -> {$token}) {
                $korean = $d -> {$token};
                $length = $i + 1;
            }
        }
        push   @korean  => $korean;
        splice @english => 0, $length || 1;
    }


You could in theory create a dictionary such that even after preprocessing,
the above algorithm takes quadratic time in the number of words, but in
practise, it will be linear.

Note that I didn't take punctuation into account, or letter cases.



Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


  -----------== 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: Sat, 16 Oct 1999 12:34:03 GMT
From: pgh@ga.nl (Patrick G.)
Subject: how to read an excel sheet
Message-Id: <3808707e.313887510@news.casema.net>

Hi,

Can some tell me how to read an excel sheet into a perl script ?

Please mail me some examples.

Thanks,

Patrick G.
(mailto: perl@ga.nl)



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

Date: Sat, 16 Oct 1999 12:47:18 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: how to read an excel sheet
Message-Id: <a4EIOITHhjXcmOpabhVgnJWAEe8A@4ax.com>

On Sat, 16 Oct 1999 12:34:03 GMT, pgh@ga.nl (Patrick G.) wrote:

> Can some tell me how to read an excel sheet into a perl script ?

You can use Win32::OLE to access the Excel file via COM, or you could
save the Excel sheet to a CSV file and use DBI or another module that
deals with CSV (check CPAN) to read it.


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Sat, 16 Oct 1999 13:03:41 GMT
From: Shawn Collenburg <greynite@mindspring.com>
Subject: Need help with seek/sysseek
Message-Id: <7u9t3a$90a$1@nnrp1.deja.com>

Could anyone tell me why the following program does not work? It fails
on just about every PERL it's been tested on save one.

Thanks,
Shawn
---------------- cut here ------------------
# Check to see if running as a web script
if ( exists $ENV{'LOCAL_ADDR'} ) {
  print "Content-type: text/html\n\n";
  print "<TITLE>Seektest.pl</TITLE><HEAD><H2>Seektest.pl</H2></HEAD>";
  print "<BODY><HR>";
  $cgi = "<P>";
}

print "PERL v. $]\n$cgi";
print "\$^X = $^X\n\n$cgi";

if ( open(FILE,"|which perl.exe") ) {
  while (<FILE>) {
    print "$_$cgi";
  }
}

unlink "seektest1.txt";
open FILE,"+>>seektest1.txt";

print "Seek 1 rc=".seek(FILE, 0, 0)."\n$cgi";
print FILE "12345\n\n";

print "Seek 2 rc=".seek(FILE, 2, 0)."\n$cgi";
print FILE "=12";

seek FILE, 0, 0;
$line = <FILE>;
chomp $line;

close FILE;

print "Seek(3) = $line;";
if ( $line == "12=12" ) {
  print " Success!\n\n$cgi";
} else {
  print " FAIL \n\n$cgi";
}
#############################################3
unlink "seektest2.txt";
open FILE,"+>>seektest2.txt";

print "Sysseek 1 rc=".sysseek(FILE, 0, 0)."\n$cgi";
syswrite FILE, "12345\n\n", 5+2*length($/), 0;

print "Sysseek 2 rc=".sysseek(FILE, 2, 0)."\n$cgi";
syswrite FILE, "=12", 3, 0;

sysseek FILE, 0, 0;
sysread FILE, $line, 6, 0;
chomp $line;

close FILE;

print "SysSeek(2) = $line;";
if ( $line == "12=12" ) {
  print " Success!\n\n$cgi";
} else {
  print " FAIL \n\n$cgi";
}


unlink "seektest3.txt";
open FILE,"+>>seektest3.txt";
print "Using binmode rc=".binmode(FILE)."\n$cgi";

print "Binmode Seek 1 rc=".seek(FILE, 0, 0)."\n$cgi";
print FILE "12345\n\n";

print "Seek 2 rc=".seek(FILE, 2, 0)."\n$cgi";
print FILE "=12";

seek FILE, 0, 0;
$line = <FILE>;
chomp $line;

close FILE;

print "Seek(3) = $line;";
if ( $line == "12=12" ) {
  print " Success!\n\n$cgi";
} else {
  print " FAIL \n\n$cgi";
}

unlink "seektest4.txt";
open FILE,"+>>seektest4.txt";
print "Using binmode rc=".binmode(FILE)."\n$cgi";

print "Sysseek 1 rc=".sysseek(FILE, 0, 0)."\n$cgi";
syswrite FILE, "12345\n\n", 5+2*length($/), 0;

print "Sysseek 2 rc=".sysseek(FILE, 2, 0)."\n$cgi";
syswrite FILE, "=12", 3, 0;

sysseek FILE, 0, 0;
sysread FILE, $line, 6, 0;
chomp $line;

close FILE;

print "SysSeek(2) = $line;";
if ( $line == "12=12" ) {
  print " Success!\n\n$cgi";
} else {
  print " FAIL \n\n$cgi";
}


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


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

Date: Sat, 16 Oct 1999 13:13:27 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Need help with seek/sysseek
Message-Id: <4YYIOAWVTNvNqCkXV3eXDpkbjKpO@4ax.com>

On Sat, 16 Oct 1999 13:03:41 GMT, Shawn Collenburg
<greynite@mindspring.com> wrote:

> Could anyone tell me why the following program does not work? It fails
> on just about every PERL it's been tested on save one.

[snip code]

It "doesn't work"? Because it's Saturday?

What does it do or not do? What was different on the one version of
Perl it did work on? What did you do and which error message did it
produce? Are we talking about a problem with your CGI query string
parsing, a server problem, or something about your file operations?

What is it supposed to do?

Hopefully you use CGI.pm for form parsing, not some homegrown code. In
that case you will also want to use CGI.pm's subs for outputting HTML,
like
	header,
	start_html,
	end_html,
	hr
	br


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Sat, 16 Oct 1999 13:42:33 +0200
From: "Gizzzmo" <Gizzzmo@pandora.be>
Subject: Re: Newbie question about time
Message-Id: <wvZN3.1336$pw5.3183@afrodite.telenet-ops.be>

You've been a great help Larry

Thanks

Christophe

Larry Rosler heeft geschreven in bericht ...
>In article <slrn80eeij.qim.mgjv@wobbie.heliotrope.home> on 15 Oct 1999
>14:28:50 GMT, Martien Verbruggen <mgjv@wobbie.heliotrope.home> says...
>> On Fri, 15 Oct 1999 16:14:19 +0200,
>> Gizzzmo <Gizzzmo@pandora.be> wrote:
>> > Can anyone tell me how to write a script that controls if a given date
for
>> > example 15/10/1999 (day/month/year)
>> > is older (for example 4 months) than the current time?
>>
>> You get the module Date::Manip or Date::Calc from CPAN:
>
>Unless you insist on an accurate specification of '4 months', this is
>significant overkill.  You can use a module that is part of the standard
>perl distribution, Time::Local.
>
>
>#!/usr/local/bin/perl -w
>use strict;
>use Time::Local;
>
>$_ = '15/10/1999';
>
>my ($day, $month, $year) = split m#/#;
>
>my $time = timelocal(0, 0, 0, $day, $month - 1, $year - 1900);
>
>$time -= 5 * 30 * 24 * 60 * 60;  # '5 months' ago (or so :-).
>
>print "Older\n" if time - $time > 4 * 30 * 24 * 60 * 60;
>
>--
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com




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

Date: Sat, 16 Oct 1999 13:05:39 +0100
From: "Martin Elliott" <martin@mert.globalnet.co.uk>
Subject: Re: Newbie Question
Message-Id: <7u9q8v$a4o$1@gxsn.com>

Thanks a lot for the help, I've installed Perl and so can write my scripts
ok, but the CGI scripts are going to be difficult to test.

Thanks for your time,

Martin




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

Date: 16 Oct 1999 09:01:24 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl and Excel
Message-Id: <7u9et4$2p6$1@gellyfish.btinternet.com>

On Fri, 15 Oct 1999 10:23:32 -0700 Gala Grant wrote:
> I need to use Perl to open an Excel Spreadsheet and pull out info, and then
> dynamically create a web page based on the pulled info.  Does anyone have
> any info on using Perl to manipulate Excel?  Is there a module or any text
> about it somewhere?
> 
> 

Whilst you could use the Win32::OLE module to work with Excel you might
considering trying the Excel ODBC driver and DBD::ODBC - this however
will only work if the data you are trying to extract is in a database
like format.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 14:23:53 +0200
From: Andrew Dear <andrew_dear@hotmail.com>
Subject: Placeholder problem with DBI::ODBC
Message-Id: <38086E59.821C6E30@hotmail.com>

I am having (the same) problem with a bound variable used in the where
clause of a delete statement. It is a number and works fine to start
with (say from 1..9), but as soon as the number gains a digit ie 10 (or
100) I get the following error..

########### Error Text #########
DBD::ODBC::st execute failed: [MERANT][ODBC Informix driver]Data type
for parame
ter 1 has changed since first SQLExecute call. (SQL-S1000)(DBD:
st_execute/SQLEx
ecute err=-1) at C:\SHS\paxrepl\testconnect.pl line 437.
########## End of Error Text ############

I have tried connecting to a variety of datasources, so I'm pretty
conviced it is to do with ODBC rather than the data source. Here's the
code............

$sth_pax = $dbh_pax->prepare(q{
   <some other columns>
   patid
   FROM
   mel_k_pat
   ORDER BY
   patid
   })

$sth_pax->bind_col(26,\$current_patid);

$sth_pax_del = $dbh_pax->prepare(q{
   DELETE mel_k_pat where patid = ?
   })
   || die("\nCould not prepare pax delete statement.\n");

while ($tmp = $sth_pax->fetchrow_arrayref)
{
 <Do some stuff>
 $sth_pax_del->execute($current_patid)
}

This works fine while $current_patid is 1 digit, but falls over as soon
as it becomes 2 digits (or ok if the first execute is 2 digits and then
it gets to 3 digits etc. etc.)

I have also tried various combinations of DBI::SQL_INTEGER (and varchar)
in the bind and prepare statements, to no effect.

Any clues, would be much appreciated, especially if I am attempting the
impossible (it did work with DBI::Sybase).

Thanks

Andrew









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

Date: 16 Oct 1999 10:34:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Please Help a newbie !!!
Message-Id: <7u9kbh$2s5$1@gellyfish.btinternet.com>

On Fri, 15 Oct 1999 04:07:13 -0500 Seth David Johnson wrote:
> On Fri, 15 Oct 1999, DHT wrote:
> 
>> Which codes at the end program (or a sub) so that program won't run when
>> people click on Go Back button of browsers ?
>> 
> I really hate to be harsh, but... ah, hell, I need to get some sleep.
> 

Harsh ? Harsh !

I think the actual answer was:

  Please refer to the CGI FAQ at:
 
    <http://www.webthing.com/tutorials/cgifaq.html>

  and if that does not have the answer ask in :

    comp.infosystems.www.authoring.cgi

 The answer would be the same whatever language the program was written in.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 16 Oct 1999 11:49:26 GMT
From: sp1d3rjd@yahoo.com (gator@apl.jhu.edu)
Subject: please help the telnet program
Message-Id: <38086634.1579923@news.erols.com>

I have been trying to use the telnet.pm module but with some problems,
here is the code ....


I ran the program  and it gave me no output except for the input and
dump logs.....then i logged in my self using the usual telnet method
and performed a last gator|more and it showed that it did log in but
did not perform the $command like it was supposed to....I am wondering
why I did not see the output for the ps command on my screen(when the
program was ran) and why it did not show up when i checked it using
the regular telnet 128.220.101.100 method.  Can any one tell me why i
did not see the ps command give its output....Does this have anything
to do with setting the cmd_remove_mode value.

Thanks for your help....

JD Durick
AT&T Information Security Center
Columbia, MD
=================================================================================================================

<ACTUAL PROGRAM:  telnet.pl>

#!/usr/bin/perl

use strict;
use Net::Telnet;

# Config Variables
my $host = '128.220.101.100';
my $command = '/usr/bin/who > who_log';
my $com1='/usr/bin/ps';
my $user = 'gator';
my $pass = 'thepassword';

my $telnet = Net::Telnet->new(-host => $host, -prompt => '/[aplcenmp
!>>] $/', Dump_log => "dump_log",Input_log => "input_log",
                              -timeout => 240);

die "Can't connect to $host: $!" unless $telnet;

# login
$telnet->login($user, $pass)
        or die "login failed: @{[$telnet->errmsg]}";

# execute the command
my @output = $telnet->cmd($command);

# dump the output
print @output;
$telnet->close;


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

Date: Sat, 16 Oct 1999 10:21:13 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: qr operator the $_
Message-Id: <3F0IOA0XUwnDMrlGzXVD1M0VeUnv@4ax.com>

Hi,

Is there any way to make a compiled regular expression act on the
default variable ($_), much like s///, m// and tr// do?

For example, using

	my $pat = '\d';
	my $re  = qr/$pat/;

you can do

	if ($myvar =~ re) ...

but it'd be nice if

	print "match" if $re;

would act on $_.

But maybe I'm misunderstanding qr() (I've checked perlop).

	print $re

prints "(?-xism:\d)", so qr() just seems to construct a regex, but
somehow I thought there'd be more magic behind the scenes. Is that all
there is to qr() or am I missing something?

Thanks

-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Sat, 16 Oct 1999 10:23:53 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: qr operator the $_
Message-Id: <6l8IOKPRP+99pfCWgDCS0ub7D3sI@4ax.com>

On Sat, 16 Oct 1999 10:21:13 GMT, Marcel Grunauer
<marcel.grunauer@lovely.net> wrote:

> Subject: qr operator the $_

Sorry, this should have been "the qr operator and $_".

Not that is makes a great difference, but I hate to use nonsensical
subjects.

-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Sat, 16 Oct 1999 13:14:32 GMT
From: Shawn Collenburg <greynite@mindspring.com>
Subject: Re: reading binary data files
Message-Id: <7u9tnk$9bg$1@nnrp1.deja.com>

In article <37fd3b58_2@news1.prserv.net>,
  fheitka@attglobal.net wrote:
>
> I'm trying to read a binary file using Perl.
> I've check through a lot of the online docs
> and a few books and I can't seem to get it to
> work.  Here is an example:
> Suppose I have a C program that writes out a
> binary file using fwrite.  In the files is
> date from the structure.
>
> struct mystruct {
>   int num;
>   double date[100];
>   char *dname="9/04/99 data"
> };
>
> How would I read the data?  I've tried using
> the seek, read, and unpack commands and all I
> seem to read is garbage.  Should Perl be able
> to do this?  I've seen lots of examples where
> Perl is evidently used to read text files.

Well, you're first problem is that your data structure won't work
they way you expect it to in C. What you really want is:

struct {
  int num;
  double date[100];
  char buf[80];
} mystruct;

strcpy ("99/09/14 data",mystruct.buf);

as putting a char* in a struct and then writing out the struct
to a data file will only send the *address* of the string, not
the string itself.

Cheers,
Shawn

P.S. "mystruct.buf" really evaluates to "*mystruct.buf[0]"


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


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

Date: 16 Oct 1999 14:00:51 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: reading binary data files
Message-Id: <slrn80h196.rsj.mgjv@wobbie.heliotrope.home>

On Sat, 16 Oct 1999 13:14:32 GMT,
	Shawn Collenburg <greynite@mindspring.com> wrote:
> In article <37fd3b58_2@news1.prserv.net>,
>   fheitka@attglobal.net wrote:

> > struct mystruct {
> >   int num;
> >   double date[100];
> >   char *dname="9/04/99 data"
> > };

> Well, you're first problem is that your data structure won't work
> they way you expect it to in C. What you really want is:
> 
> struct {
>   int num;
>   double date[100];
>   char buf[80];
> } mystruct;

Says who? I write a lot of C code where the structs contain a pointer
to a char. I just never try to write that directly to disk. You mimic
the pointer by using a file offset.

What happens when you suddenly decide that you actually needed 82
characters? That member being a pointer to char instead of an array of
char probably has a good reason.

And why change the definition of the struct?

> strcpy ("99/09/14 data",mystruct.buf);
> 
> as putting a char* in a struct and then writing out the struct
> to a data file will only send the *address* of the string, not
> the string itself.

Not exactly. Close, but semantically a bit off. But yes, if you have a
struct with a pointer, and you want to write the contents of the
memory that pointer points to, you willhave to provide for that.
generally, however, it is not a good idea to adapt your data type
design to your write and read routines. Normally that happens the
other way around. You design you data, and then you write the
read/write routines accordingly.

And how does your post say anything about the actual question: How do
I read this thing in Perl?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | The gene pool could use a little chlorine.
NSW, Australia                  | 


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

Date: Sat, 16 Oct 1999 11:53:41 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: retrieve url from hypertext
Message-Id: <7u9ovb$k6$1@xenon.inbe.net>

In article <7u9cg3$vmm$1@nnrp1.deja.com>, Howard Sun <hxshxs@my-deja.com> wrote:
>just started learning Perl. not sure how to do the following,
>
>extract all URLs within the hypertext.
>
>if I use
>if(/<a href="?.*"?>/) {
>       $link = $&;
>}
>
>it can only display <a href="http://......"> part, not the real url.
>real URL maynot start with http or end with html.
>
>also it stops at the first occurance.

Well, it's a nice start, but as you noticed, extracting links from an HTML
page can quickly get quite complex. So go to CPAN and grab HTML::Parser.
It includes HTML::Extor, a link extractor for HTML pages that should do
what you want...

Have fun,

Michel.


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

Date: Sat, 16 Oct 1999 05:00:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: retrieve url from hypertext
Message-Id: <cre9u7.lp6.ln@magna.metronet.com>

Howard Sun (hxshxs@my-deja.com) wrote:

: just started learning Perl. not sure how to do the following,
: extract all URLs within the hypertext.


   That wheel has already been invented

      HTML::LinkExtor - Extract links from an HTML document



   Perl modules are available at CPAN.


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


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

Date: Sat, 16 Oct 1999 13:11:01 +0100
From: "Martin Elliott" <martin@mert.globalnet.co.uk>
Subject: Testing CGI scripts on win 98
Message-Id: <7u9qj0$mh8$1@gxsn.com>

Is there another way to test CGI scripts without installing server
software??

If installing the software is my only hope, what is best and where do I get
it from??

Thanks,

Martin




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

Date: Sat, 16 Oct 1999 12:38:15 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Testing CGI scripts on win 98
Message-Id: <AX8IOMucuaSpQWBwCxu22FPESx2d@4ax.com>

On Sat, 16 Oct 1999 13:11:01 +0100, "Martin Elliott"
<martin@mert.globalnet.co.uk> wrote:

> Is there another way to test CGI scripts without installing server
> software??
> 
> If installing the software is my only hope, what is best and where do I get
> it from??

Sure, you can run scripts using CGI.pm from the command line. This
gives you the chance to simulate passing the query string by simply
entering it manually.

But you could just download Apache from http://www.apache.org.


-- 
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;


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

Date: Sat, 16 Oct 1999 22:33:34 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Testing CGI scripts on win 98
Message-Id: <DI_N3.7$6K1.577@vic.nntp.telstra.net>

Martin Elliott <martin@mert.globalnet.co.uk> wrote in message
news:7u9qj0$mh8$1@gxsn.com...
> Is there another way to test CGI scripts without installing server
> software??
>
> If installing the software is my only hope, what is best and where do I
get
> it from??
>
> Thanks,
>
> Martin
>
You could also try Perl Builder from www.solutionsoft.com but it involves
money.

There is an eval available. It is a nice IDE with built in CGI testing
facility.

Wyzelli




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

Date: Sat, 16 Oct 1999 11:14:47 GMT
From: bayinnaung@my-deja.com
Subject: Unix Utilities: Perl Versions
Message-Id: <7u9mn5$5hg$1@nnrp1.deja.com>

I came across a page full of Unix utilities that
had been rewritten in Perl about a week ago.
I believe the author was Tom Christiansen...
and I cannot find it again...you'd think that there
would be a lot of links to it...

Does anyone know where it is?

Thanks,

Jon Fernquest
bayinnaung@hotmail.com


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


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

Date: 16 Oct 1999 13:43:40 GMT
From: pfash1@aol.com (Pfash1)
Subject: Working on separate records in a file
Message-Id: <19991016094340.13381.00000035@ng-ch1.aol.com>

I would greatly appreciate any help:
I have files that contain an undetermined number of separate records each of
undetermined length. (These are separated on the file by dashed lines.) These
records are email messages, each with the same format (ie; second word on the
first line is the name of the recipient
and the message always begins after the third word on the third line ...but the
length of the message varies for each record.) 

I want to isolate and work with the name of the recipient, the sender and the
message for each of the records.

I am thinking the way to do this is to first use 
$/ = "-----------------------"; to put each record into its own field in an
array.  (see code below) 

Now, when I want to take each of those fields and split the contents on the
blank spaces (so that I can count the words and find each component I want to
work on), I am running into trouble.
How should I do this? Is there a way to split each email record on the blank
spaces when I put it into its own field in an array..and would this be an array
of arrays? How would that look?
 
#!perl -w
my @eachrecord;
open (FH, 'file_of_emails.db')      || die "$0: open file_of_emails.db: $!";
while (<FH>) 
{
$/ = "-----------------------";
chomp;
s/\n[ \t]+/ /g;
push @array_of_emails, $_; 
}
close (FH);
print $array_of_emails[1];
##########################
Here is the file of emails:

To: steve


Sender's Name: petesender

Hello, Steve: here is my message.
-----------------------
To: frank

Sender's Name: frankssender

Hello, frank:: here is my message
-----------------------
to: pete

Sender's Name: petessender

Hello, pete::here is my message blah, blah, blah,
blah, blah, blah,
-----------------------



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

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


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