[10845] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4446 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 17 11:37:19 1998

Date: Thu, 17 Dec 98 08:18:14 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Dec 1998     Volume: 8 Number: 4446

Today's topics:
    Re: ($e_mail !~ /\w+[-\w]*\@\w+[-\w]*\.\w+/) birgitt@my-dejanews.com
    Re: ADODB Problems, final adjustment <lss@shaw.wave.ca.spamtrap>
    Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free P pete@davesworld.net
        ANNOUNCE: smb2web - Samba to Web Gateway <rolf@insect.demon.co.uk>
    Re: array initialisation (Joergen W. Lang)
    Re: array initialisation (Joergen W. Lang)
    Re: CGI.pm and fileupload (Sam Curren)
        Character problem in GD? <bjornsvensson@geocities.com>
    Re: DBD::Oracle (SELECT *) question... evlap@usa.net
    Re: Encryption/Decryption of strings (Clay Irving)
    Re: hashes <aqumsieh@matrox.com>
    Re: Help: File size weirdness with db's (Alan Barclay)
        Help: missing module <ruedas@geophysik.uni-frankfurt.de>
        how can I create my html file elsewhere than in the cgi <ahamel@intrawest.com>
        how to find the line number of a matched string <bl@dcs.ed.ac.uk>
    Re: how to find the line number of a matched string <ebohlman@netcom.com>
    Re: how to find the line number of a matched string (Andrew M. Langmead)
        Parsing string from browser input nguyen.van@imvi.bls.com
    Re: Posting Code for Review <ebohlman@netcom.com>
        Printer Output - Capturing <hjcarr@nf.sympatico.ca>
        Problems with Forking!! (JT)
    Re: Searching through a 10MB file <ebohlman@netcom.com>
    Re: sort it ? (Micha3 Rutka)
        Split String <darrensweeney@eswap.co.uk>
    Re: Split String <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Split String <ebohlman@netcom.com>
        sql in perl ? <kamran@norsar.no>
    Re: sql in perl ? <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Dec 1998 13:39:45 GMT
From: birgitt@my-dejanews.com
Subject: Re: ($e_mail !~ /\w+[-\w]*\@\w+[-\w]*\.\w+/)
Message-Id: <75b1j2$jrp$1@nnrp1.dejanews.com>

In article <8cd85nqy4n.fsf@gadget.cscaper.com>,
  Randal Schwartz <merlyn@stonehenge.com> wrote:
>
> I encourage new users, but I also expect new users to QUICKLY
> understand that there are FAQs and Dejanews available for first-line
> research before posting worn-out questions word-for-word and wasting
> *all* our time with it.


Pardon me for abusing freely a saying by Larry Wall:

While someone obviously is expecting something to happen, it's not
obviously expected to happen.

Vent on and stay on ... :-)

birgitt

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


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

Date: Thu, 17 Dec 1998 11:32:10 GMT
From: "LSS" <lss@shaw.wave.ca.spamtrap>
Subject: Re: ADODB Problems, final adjustment
Message-Id: <_Y5e2.18$yp4.197@news.rdc1.on.wave.home.com>

>Hello,
>
>I tried the different versions of your example but it does not work;
>
>I get the error message
>Can't locate object method "createobject via package "ole".

This suggests that your Perl installation is missing required components for
the sample.  I use the Activestate distribution of Perl, version 507 does a
particularly good job of hooking itself in.

>
>I changed
>$Cn = CreateObject OLE 'ADODB.Connection';
>to
>$Cn = CreateObject Win32::OLE 'ADODB.Connection';
>
>then I get the message:
>unable to create ADO connection object.
>

This suggests that you may be using an older version of Perl.  Get the
latest from www.activestate.com and your issues should go away provided you
have ado services installed also.

>
>
>My problem might be caused here:
>
># DSN Connection
>$dbconnection = &quot;DSN=MyData;Uid=my;Pwd=password;&quot;;
># DSNless Connection
>#$dbconnection = 'DBQ=D:\SubDir\MyData.mdb;Driver={Microsoft Access Driver
>(*.mdb)};Uid=sa;Pwd=;';
>

Hopefully you did not use this literally.  The DSN form requires that you
use the ODBC control panel applet to install a Data Source Name that defines
how the database is reached.  The DBQ form allows you to spell out directly
how to reach your database and what database engine to use.

>
>I never worked with databases. What is the difference between DSN=MyData
and
>DBQ=D:\SubDir\MyData.mdb? Do I have to change the words Driver={Microsoft
>Access Driver (*.mdb)}
>
>I had similar problems with other examples. In each case I am not able to
open
>the database.
>
>I read the faq and everything I could find but I got no answers.
>
>please help me,
>
>thanks in advance
>
>

Unfortunately, all of this requires knowing a little bit about each
underlying component.  Taken individually, it is easy to digest.  But as a
whole, there is a lot to swallow.  Nibble away at the parts, and you'll
eventually consume the monster.





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

Date: Thu, 17 Dec 1998 13:44:39 GMT
From: pete@davesworld.net
Subject: Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free Perl IDE)
Message-Id: <75b1s8$k09$1@nnrp1.dejanews.com>

In article <7e3a57.94l.ln@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
>
> [
>    There is nothing about modules in here. Followups trimmed.
>
>    ... uhh there is precious little about Perl in it either,
>    but I can't trim them all...
> ]
>
> Steven Morlock (newspost@morlock.net) wrote:
>
> : I think you should give David a break.
>
>    (but it doesn't really matter. spammers don't read the
>     newsgroups they spam, so he never saw Clay's followup...
>    )

Yes, I did. Until I read this, I didn't think it deserved a response. I
generally don't respond to flames. It just encourages them, and is damaging to
the public forum. However, since you considered it a bad thing (not
responding), I went back and answered, and repeated my apology for the emails.

>
> : I'm sure he has learned his lesson on the Job SPAM.
>
>    Which wasn't classical spam, just routine Internet abuse.

Given the nature of the email, I did not consider it spam (legally, it
isn't), or abuse of any kind. I expected a helpful community response, which
is exactly what I got, except for in here.

The question has been asked: what if _everybody_ did this. The answer, I would
not have done it. My email was sincere.

Internet abuse is also flaming, abusing, and continuing cluttering up an
otherwise helpful newsgroup with harmful, negative garbage. You are doing this
right now.

Randal: it is also an abuse of authority and unprofessional to deny a public
software announcement that is completely in tune with the purpose of a list
and beneficial to the community just because of personal feelings and
grudges.

>    Now this week he is going to learn his lesson about classical spam?
>
>    How much of other people's resources will he spend learning
>    _next_ week's lesson?
>
>    Internet abusers are evil.
>
>    David (or Pete) is an Internet abuser.
>
>    David (or Pete) is evil.
>
>    You build your reputation and then you live with what
>    you have built...
>
> : Clay Irving wrote in message <755sjl$f2c@panix.com>...
> : >In <754c55$kt$1@nnrp1.dejanews.com> pete@davesworld.net writes:
> : >
> : >>ANNOUNCE: CodeMagic Universal IDE for Win32
> : >>Win32 Based FREE IDE for Perl, TclTk, Java, C, Python
> : >>Beta Release 1 (15 Dec, 1998)
> : >
> : >>NEVER PAY FOR FREE SOFTWARE!
> : >>NEVER PAY FOR PERL SOFTWARE WHEN ALL YOU WANT IS FREE!
> : >>NEVER PAY FOR PROPRIETARY PERL SOFTWARE!
> : >
> : >WARNING!! WARNING!
> : >
> : >"pete@davesworld.net" is the same little snot who spammed posters in the
> : >Perl newsgroups with a sob story about his resume last week -- This week
> : >it's "FREE! FREE! SOFTWARE!" posted individually to each newsgroup
> : >instead of cross-posting...
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

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


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

Date: Thu, 17 Dec 1998 13:41:27 +0000
From: Rolf Howarth <rolf@insect.demon.co.uk>
Subject: ANNOUNCE: smb2web - Samba to Web Gateway
Message-Id: <36790A07.5C2C@insect.demon.co.uk>

Version 1.0 of smb2web is now available at

     http://www.insect.demon.co.uk/smb2web/

This is a Perl CGI script (plus related files) that provides access to a
Windows network file system through a web interface. It is similar to
smb2www (in fact, was based on it) but differs principally in that it
supports the use of filters to translate common Windows file formats
(such as MS Word documents) into HTML *on the server*. This makes it
ideal for mixed platform networks, allowing non-Windows clients to
access network files in a predominately Windows environment without
requiring any special browser plug-ins to be installed. It also supports
optional indexing and searching of files.

The filtering functionality depends on suitable third party translators
being installed (such as MsWordView or pstotext). Most of these programs
have limitations of one kind or another, but it is straightforward to
configure smb2web to use any additional or improved converters that you
might acquire. If you find any other programs that would make a good
smb2web filter please let me know so I can add them to the list of
supported filters.

-Rolf


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

Date: Thu, 17 Dec 1998 16:16:18 +0100
From: jwl@worldmusic.de (Joergen W. Lang)
Subject: Re: array initialisation
Message-Id: <1dk6nkq.1484ikg1x1r7d0N@host027-210.seicom.net>

Ala Qumsieh <aqumsieh@matrox.com> wrote:

> jwl@worldmusic.de (Joergen W. Lang) writes:
> 
> > Maybe someday we have modules like Crystal::Ball and Read::Mind which
> > suggest answers in an associative manner. 
> 
> I doubt if such modules would help. There is *NO WAY* you could guess
> what goes inside the minds of Perl programmers. ;-)

Rats ! That's like looking in a mirror. Is that really me thinking that
- or am I thought by Perl ? Time to get my medication, sorry ;-))


> I was checking the entries into the 3rd Confuscated Perl Contest
> .. and man .. some of those people have incredibly wicked minds!

Yep - but they do it on purpose. I still have an unfinished japh on my
machine that - when it's finished - is supposed to do an acoustic
version via Morse Code. I thought of using \a but I can't get it
changing the length of the sound to produce the .--..-'s 
Any ideas ;-)

Joergen
-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: Thu, 17 Dec 1998 16:16:21 +0100
From: jwl@worldmusic.de (Joergen W. Lang)
Subject: Re: array initialisation
Message-Id: <1dk6o4q.19lsam818gfj7kN@host027-210.seicom.net>

Craig Berry <cberry@cinenet.net> wrote:

> Joergen W. Lang (jwl@worldmusic.de) wrote:
> : That's almost always the biggest problem in answering those questions.
> : There's always a good part of guessing involved. 
> : Maybe someday we have modules like Crystal::Ball and Read::Mind which
> : suggest answers in an associative manner. 
> 
> Those names are poorly chosen.  You want Ball::Crystal (in parallel with
> other sorts of balls -- Ball::Onyx, Ball::Plastic), and Mind::Read (in
> parallel with Mind::Control, Mind::Lose, and so forth).

Depends on what you want to do with it. Your way won't allow things
like: Crystal::Structure or Crystal::Clear nor would you be able to have
things like Read::Newspaper, Read::WritingOf::Wall or Read::TFM which
IMHO would be a big loss.

Joergen
-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: Thu, 17 Dec 1998 07:51:52 -0800
From: samc@empirewest.com (Sam Curren)
Subject: Re: CGI.pm and fileupload
Message-Id: <MPG.10e2c874577b3e2b9896bf@news.sonic.net>

Look here for anything you need on CGI.pm, and remember that the web has 
resources too.

http://stein.cshl.org/WWW/software/CGI/

HTH -Sam

In article <3678D0B7.4B7B491D@netjob.dk>, e.christensen@netjob.dk says...
> Hi
> I am trying to make a fileupload script with the CGI module.
> But this module creates temporary files in a directory called tmp.
> How can I change this to anothher by my choice, I have looked in the
> docs, and Dejanews -> now(answers)
> 
> Quote from the docs:
> 
> CGI.pm creates temporary files in either the /usr/tmp or the /tmp
> directory.
> These temporary files have names like CGItemp125421, and should be
> deleted automatically.
> 
> 
> Ernst
> 
> 


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

Date: Thu, 17 Dec 1998 16:27:31 +0100
From: Bjorn Svensson <bjornsvensson@geocities.com>
Subject: Character problem in GD?
Message-Id: <367922E3.70BC14D0@SPAMSOMEONEELSE_geocities.com>

Hi,

I have a problem writing 2 (e and E) out the six swedish 
non-english characters with GD's string.

Seems like many/most (but not all) of the ASCII characters 
161-255 are having problem, for exampel the copyright symbol, 
the Yen symbol, and the spanish upsidedown questionmark.

I'm using ActiveStates 5.005_02 and have tried the following script on
both NT4 (swedish) and win95(english).

Am I doing something wrong?  Is this a bug?  How can I write the
copyright symbol etc using GD?

    ####################################################
    use locale; # Makes no difference to this result
    use Strict;
    use GD;

    $gifout = "GD_temp.gif" ;
    $texten = "Some problematic ASCII characters for GD.pm : )&eE!%";
    $text1 = "ASCII codes 161-255: !"#$%&'()*+,-./0123456789:;<=>?-";
    $text2 = "@ABCDEFGHIJKLMOPQRSTUVWXYZ[\]^_";
    $text3 = "`abcdefghiklmnopqrstuvwxyz{|}~";
    $im = new GD::Image(450,100);

    $white = $im->colorAllocate(255,255,255);
    $black = $im->colorAllocate(0,0,0);
    $red = $im->colorAllocate(255,0,0);
    $im->rectangle(0,0,449,99,$black);
    $im->string(gdLargeFont,10,10,"$texten",$red);
    # The font makes no difference
    $im->string(gdMediumBoldFont,10,30,"$text1",$black);
    $im->string(gdMediumBoldFont,10,50,"$text2",$red);
    $im->string(gdMediumBoldFont,10,70,"$text3",$black);

    open (MYGIF,">$gifout") || die  ("Problem open file $gifout");
    binmode MYGIF;
    print MYGIF $im->gif;
    close MYGIF;
exit 0;


##############
    Bjorn
##############


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

Date: Thu, 17 Dec 1998 13:57:18 GMT
From: evlap@usa.net
Subject: Re: DBD::Oracle (SELECT *) question...
Message-Id: <75b2jt$kkp$1@nnrp1.dejanews.com>

Hi All! I have a trouble with my query result. I wonder why the queries below
give different result with DBD::Oracle.  1) SELECT * FROM A_C where Code=2 
2) SELECT Code, Reference, Title,... FROM A_C where Code=2 Although
everything works properly with sqlplus! Actually, after fetching in
variables, $Code - undefined but other fields/vars seem to be OK. I tried 2
ways: 1) @row = $cursor->fetchrow_array;  $Code=$row[0];  .... 2) my($Code, 
 ...);  $cursor->execute;  $cursor->bind_columns(undef, \($Code,  ... )); 
$cursor->fetch; -------------- The same result, $Code - undefined (as perl
debugger says). However the query "SELECT Code, ..." brings correct result.
If this a glitch of DBD::Oracle? Oracle works on other computer and was
called via sql*net v1 (SCO Oracle 7.0.13). A_C is a view like "SELECT Code,
 .... FROM...".

Regards, Eugene.

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


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

Date: 17 Dec 1998 08:24:15 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Encryption/Decryption of strings
Message-Id: <75b0lv$dpr@panix.com>

In <36781b4a.22314516@news.cchat.com> rand@mindless.com (Steven Edwards) writes:

>I was wondering if there were any good routines available to decrypt
>an encrypted string. I can encrypt the string using the crypt
>function, but I'm tryng to find a way to decrypt a string based on a
>password.

>Suggestions? :)

Sure. Try this link:

    http://reference.perl.com/query.cgi?security

Something like Crypt::DES module perhaps?

    use Crypt::DES;
    
    my $key = pack("H16", "0123456789ABCDEF");
    my $cipher = new DES $key;
    my $ciphertext = $cipher->encrypt("plaintex");	# NB - 8 bytes
    print unpack("H16", $ciphertext), "\n";

-- 
Clay Irving
clay@panix.com


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

Date: Thu, 17 Dec 1998 01:18:55 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: hashes
Message-Id: <x3yaf0n8f5c.fsf@tigre.matrox.com>


tabo <cswfrank@rica.net> writes:

> 
> is there a way to get the number of items in a hash table?

$num = scalar keys %hash;



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

Date: 17 Dec 1998 04:42:53 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Help: File size weirdness with db's
Message-Id: <913869768.563514@elaine.drink.com>

In article <7573vf$ojl$1@nntp.Stanford.EDU>,
Perry Friedman <friedman@Xenon.Stanford.EDU> wrote:
>
>total 16392
>-rw-------   1 pickem   staff       4096 Dec 15 17:45 NEW.dir
>-rw-------   1 pickem   staff    33230848 Dec 15 17:45 NEW.pag
>
>Here is a du -k on the directory:
> 8197
>
>Now, the file looks to be about four times as big as is reported by du or
>even the directory total.
>
>The amount of K added jives with the individual file size, as does the number
>of blocks added.  But the total is still off.
>This is really weird.
>
>Anyone know why this would be?  Is this a bug in Perl?  In Solaris?  In ls?


No, it's not a bug. It's really a feature!

First, the basics. There are two sizes stored for every file.

$size=(stat($file))[7] -    The length of the file in bytes. In NEW.pag above
                            this is 33230848.
$blocks=(stat($file))[12] - The actual number of blocks allocated for this
                            file.

Now for most files, these figures are closely related. To store 32Mb of
data, you need 64k blocks of 512 bytes each, however, in your file above
they're not! One clever thing that the majority of Unix filesystem are
capable of doing is having files with holes in them, eg, the file created by
this program:

#!/usr/local/bin/perl

open(BIGFILE,">bigfile") or die "opening $!\n";
seek(BIGFILE,1e6,0) or die "seeking $!\n";
print BIGFILE "\n";

creates a file, then seeks to the millionth byte before writing any data.
Obviously the bytes before the millionth cannot contain any data, and thus
the system won't even allocate any blocks for this portion of the file. When
it gets to a portion which has data, ie the million+1th byte, it will have
a block allocated for that portion. If a program attempts to read from
a portion of the file which doesn't have a block allocated (usually called
a hole), then the OS will simply return a block of NULL's.

However, most files are written sequentially, without using seek
at all. It's theoretically possible for the OS to scan each block before
writing it to disk, and if it's all NULL's, skip allocating the block,
but this isn't done on any system I'm aware of, probably because the disk
space saved isn't worth the extra cost of scanning files. Therefore if
you were to replace the seek above with a write of million NULL bytes,
then the OS would happily allocate enough blocks to store all this data.

cp isn't smart enough to do seeks when it's copying a file, so when you
copied the original file (with holes), you got a copy without holes, and
thus the copy uses up more disk space even though it's the same length
long.



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

Date: Thu, 17 Dec 1998 13:29:41 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: Help: missing module
Message-Id: <3678F935.219F@geophysik.uni-frankfurt.de>

Hello,
as my first posting apparently hasn't reached the NG, I try it again:
I have got a Perl 5 script here which uses a module Getopt::Std . This
module is missing on my machine, and I didn't find it on CPAN; I did
find several Getopt modules, but with other name endings. Can anybody
tell me if I can use one them instead or, even better, where I can find
Getopt::Std?
Any help will be highly appreciated.

Thomas Ruedas
PS: Please reply by e-mail as well.
-- 
--------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, 
J.W. Goethe University Frankfurt/Main
Feldbergstrasse 47			D-60323 Frankfurt/Main, Germany
Phone:+49-(0)69-798-24949		Fax:+49-(0)69-798-23280
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
--------------------------------------------


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

Date: Thu, 17 Dec 1998 09:23:56 -0500
From: "Alexandre Hamel" <ahamel@intrawest.com>
Subject: how can I create my html file elsewhere than in the cgi-bin folder??
Message-Id: <8s8e2.2$oA1.105486@news.bctel.net>

I've tryied many ways but without success... :( here's my code )

#!/usr/perl
push(@INC, "/cgi-bin");
require ("cgi-lib.pl");

# Script Perl
# Updates des conditions de neige
# Auteur : Alexandre Hamel, lundi, 14 dic. 1998

print "Content-type: text/html\n\n";

print "<HTML><HEAD><TITLE>test updates</TITLE></HEAD>\n";
print "<BODY bgcolor=#FFFFFF>\n";
print "<CENTER>\n";


@my_query_string = split(/&/,$ENV{'QUERY_STRING'});
my %conditions;

foreach $index (0..$#my_query_string)
{
 ($key, $val) = split(/=/, $my_query_string[$index],2);
 $conditions{$key} = $val;
}


print "</BODY></HTML>\n";

#
# Criation du fichier newcondf.htm francais
#

open (CONDF, ">newcondf.htm")
 or die "Problhme lors de la criation du fichier!";
printf CONDF "<HTML><HEAD><TITLE>Conditions de neige</TITLE></HEAD>";
printf CONDF "<BODY bgcolor=#FFFFFF>";
printf CONDF "<CENTER>";
printf CONDF "<FONT SIZE=6 COLOR=#99003><B>Conditions de
neige</B></FONT><BR>";
printf CONDF "$conditions{'jour'}, le $conditions{'date'}
$conditions{'mois'} $conditions{'annee'} a
$conditions{'hour'}:$conditions{'minute'}$conditions{'ampm'}";
printf CONDF "</center>";
printf CONDF "<table border=1 width=400 align=center CELLPADDING=3
CELLSPACING=0>";
printf CONDF "<tr><td bgcolor='#0066cc'>";
printf CONDF "<b><center>Accumulation de neige</center></b>";
printf CONDF "</td></tr>";
printf CONDF "<tr><td bgcolor='#0099cc'>";
printf CONDF "<ul>";
printf CONDF "<li>Dernier 24 heures  : $conditions{'24hrs'} cm.<br>";
printf CONDF "<li>Dernihre semaine   : $conditions{'lastweek'} cm.<br>";
printf CONDF "<li>Dibut de la saison : $conditions{'season'} cm.<br>";
printf CONDF "</ul>";
printf CONDF "</td></tr>";
printf CONDF "<br>";
printf CONDF "<tr><td bgcolor='#0066cc'>";
printf CONDF "<b><center>Tempiratures</center></b>";
printf CONDF "</td></tr>";
printf CONDF "<tr><td bgcolor='#0099cc'>";
printf CONDF "<ul>";
printf CONDF "<li>Tempirature au sommet  : $conditions{'wsummit'}
celcius.<br>";
printf CONDF "<li>Vitesse des vents      : $conditions{'wind'} km/h.<br>";
printf CONDF "</ul>";
printf CONDF "</td></tr>";
printf CONDF "<tr><td bgcolor='#0066cc'>";
printf CONDF "<b><center>Information sur la station</center></b>";
printf CONDF "</td></tr>";
printf CONDF "<tr><td bgcolor='#0099cc'>";
printf CONDF "<ul>";
printf CONDF "<li>Longueur des pistes : $conditions{'pistes'} km.<br>";
printf CONDF "<li>Heure d'ouverture   : $conditions{'open'}h AM.<br>";
printf CONDF "<li>Nombre de remonties : $conditions{'remontees'}<br>";
printf CONDF "</ul>";
printf CONDF "</td></tr>";
printf CONDF "</table>";
printf CONDF "</BODY></HTML>";
close ( CONDF );

#
# Criation du fichier newconde.htm anglais
#

open (CONDE, ">newconde.htm")
 or die "Problhme lors de la criation du fichier!";
printf CONDE "<HTML><HEAD><TITLE>Snow conditions</TITLE></HEAD>";
printf CONDE "<BODY bgcolor=#FFFFFF>";
printf CONDE "<CENTER>";
printf CONDE "<FONT SIZE=6 COLOR=#99003><B>Snow conditions</B></FONT><BR>";
printf CONDE "$conditions{'day'}, $conditions{'month'}
$conditions{'date'}<sup>th</sup> $conditions{'annee'},
$conditions{'hour'}:$conditions{'minute'}$conditions{'ampm'}";
printf CONDE "</center>";
printf CONDE "<table border=1 width=400 align=center CELLPADDING=3
CELLSPACING=0>";
printf CONDE "<tr><td bgcolor='#0066cc'>";
printf CONDE "<b><center>Snow Accumulation</center></b>";
printf CONDE "</td></tr>";
printf CONDE "<tr><td bgcolor='#0099cc'>";
printf CONDE "<ul>";
printf CONDE "<li>Last 24 hours  : $conditions{'24hrs'} cm.<br>";
printf CONDE "<li>In the last week   : $conditions{'lastweek'} cm.<br>";
printf CONDE "<li>Since season's beginning : $conditions{'season'} cm.<br>";
printf CONDE "</ul>";
printf CONDE "</td></tr>";
printf CONDE "<br>";
printf CONDE "<tr><td bgcolor='#0066cc'>";
printf CONDE "<b><center>Temperatures</center></b>";
printf CONDE "</td></tr>";
printf CONDE "<tr><td bgcolor='#0099cc'>";
printf CONDE "<ul>";
printf CONDE "<li>Temperature at the summit : $conditions{'wsummit'}
celcius.<br>";
printf CONDE "<li>Wind speed      : $conditions{'wind'} km/h.<br>";
printf CONDE "</ul>";
printf CONDE "</td></tr>";
printf CONDE "<tr><td bgcolor='#0066cc'>";
printf CONDE "<b><center>Resort information</center></b>";
printf CONDE "</td></tr>";
printf CONDE "<tr><td bgcolor='#0099cc'>";
printf CONDE "<ul>";
printf CONDE "<li>Longest run : $conditions{'pistes'} km.<br>";
printf CONDE "<li>Opening time   : $conditions{'open'}h AM.<br>";
printf CONDE "<li>Number of lifts : $conditions{'remontees'}<br>";
printf CONDE "</ul>";
printf CONDE "</td></tr>";
printf CONDE "</table>";
printf CONDE "</BODY></HTML>";
close ( CONDE );






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

Date: Thu, 17 Dec 1998 11:18:32 GMT
From: Budi Ling <bl@dcs.ed.ac.uk>
Subject: how to find the line number of a matched string
Message-Id: <199812171118.LAA27986@keisgaig.dcs.ed.ac.uk>



Could any Perl expert help me with this?

I want to match a string and get the line number that
points to it; for example:

if ($myLinesFlat =~ m/^Name:\w+\nPhone:\w+/m) {
 ...get the line number of Name: ...
}


How to get the line number? Thanks,

Bud


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

Date: Thu, 17 Dec 1998 12:12:04 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: how to find the line number of a matched string
Message-Id: <ebohlmanF43z84.69M@netcom.com>

Budi Ling <bl@dcs.ed.ac.uk> wrote:
: I want to match a string and get the line number that
: points to it; for example:

: if ($myLinesFlat =~ m/^Name:\w+\nPhone:\w+/m) {
:  ...get the line number of Name: ...
: }
: How to get the line number? Thanks,

I'm assuming that $myLinesFlat is just a long multiline string and you 
want to know the logical line number that 'Name' is on (i.e. one more 
than the number of \n's that occur before 'Name'.

One option is to add a seemingly useless 'g' modifier to your pattern
match, which will have the effect of making the location of the first
character after your match available with the pos() function.  Using 
that, we can extract the part of the string before your match and count 
how many newlines it has:

 if ($myLinesFlat =~ m/^Name:\w+\nPhone:\w+/mg) {
   #get the part of the string up to and including the match
   my $t=substr($myLinesFlat,0,pos($myLinesFlat)-1);

   #force any subsequent matches to start from the beginning again,
   #because the 'g' modifier changed the semantics of matching
   pos($myLinesFlat)=0;

   #count the number of newlines before and inside the match.  Since the
   #match includes a newline, this is the same as one more than the number
   #of newlines before the match, which is what we want (assuming we want
   #1-based rather than 0-based line numbers)
   $MatchLine=($t=~tr/\n//);
 }

Another option would be to use the built-in special variable $` which is 
automatically set to the substring preceding the match:

 if ($myLinesFlat =~ m/^Name:\w+\nPhone:\w+/m) {
   $MatchLine=($`=~tr/\n//)+1;
 }

Less code, but if you use $` *anywhere* in a program, it slows down 
*every* regular-expression match anywhere in the program.  That may or 
may not matter in your case: you're invited to use the Benchmark module 
to find out which option is faster in your program.



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

Date: Thu, 17 Dec 1998 14:41:59 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: how to find the line number of a matched string
Message-Id: <F4465z.Fv5@world.std.com>

Budi Ling <bl@dcs.ed.ac.uk> writes:

>I want to match a string and get the line number that
>points to it; for example:

>if ($myLinesFlat =~ m/^Name:\w+\nPhone:\w+/m) {
> ...get the line number of Name: ...
>}

You could use the pos() and tr/// solution that Eric posted, but may I
suggest another tactic? Do you really need to keep the entire file in
memory at once? Sure perl can do it, but why ask it to do so unless
you really need it.

while(defined($line=<FILE>)) {
  # see if we have a "Name:" line"
  if ($line =~ /^Name:\w+/) {
      $name = $line;

      # now grab the next line and see if it is a "Phone:" line, if not
      # go back to searching for another "Name:"
      $line = <FILE>;
      redo unless $line =~ /^Phone:\w+/;
      $phone = $line;

      # we want to report the line number for the "Name:" line, but
      # we've already gone past it to "Phone:", so subtract one.
      $line_number = $. - 1; 

  }
}
-- 
Andrew Langmead


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

Date: Thu, 17 Dec 1998 11:56:42 GMT
From: nguyen.van@imvi.bls.com
Subject: Parsing string from browser input
Message-Id: <75arhq$f2c$1@nnrp1.dejanews.com>

Hi Perl gurus,

I have some problem with my perl CGI. I create a script to take the input
from browser, which then using Date::Manip module to convert string to date.
After converting to date, it look for a file name with date attached at the
end of the file (ie filename.12171998) and open the file and show output to
browser. I have tried to write it but somehow not work for me

____________________________________________________________________

use CGI;
use Date::Manip qw(ParseDate UnixDate);
$query = new CGI;
$| = 1;
print "Content-type:text/html\n\n";

read ( STDIN, $request_string, $ENV{'CONTENT_LENGTH'});
( $key, $value ) = split ( /=/, $request_string );
$value =~ s/\+/ /g;
$key =~ s/\+/ /g;
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
$key =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
$view_all = $query->param('see'); where "see" is a Name variable in HTML

_____________________________________________________________________-

I'm using POST method. I think that the code just stopped right here.
Do you have any idea?

Thanks
Van

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


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

Date: Thu, 17 Dec 1998 11:00:48 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Posting Code for Review
Message-Id: <ebohlmanF43vxC.29D@netcom.com>

Jim Seymour <jseymour@jimsun.LinxNet.com> wrote:
: Is it okay to post code for review here in comp.lang.perl.misc?
: (Providing it's not *too* large.)  I looked at the FAQs but did
: not see this issue addressed.  Maybe I missed it.

: I'd simply like a review of one of my latest efforts to see if
: I'm "on track", as it were.

It's done, and is OK unless done so often that it starts to overwhelm the 
group.  What's *not* OK is to post a long piece of code, claim that it 
isn't working properly but you don't understand what it means, and ask 
other people to fix it for you.  But you're not going to do that.  Perl 
is what it is today because so much Perl code has been peer-reviewed.




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

Date: Thu, 17 Dec 1998 11:35:25 GMT
From: "Howard Carr" <hjcarr@nf.sympatico.ca>
Subject: Printer Output - Capturing
Message-Id: <3678ec4d.0@209.128.1.3>

How would I go about getting a copy of everything that went to a printer
that is on a tty. I need to put the data printed into a database for problem
solving.

Thanks
--
Howard Carr, Computer Sytems Specialist
Corner Brook Pulp & Paper Ltd
Tel: (709) 637-3561




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

Date: Thu, 17 Dec 1998 15:57:10 GMT
From: jett1not@homedot.com (JT)
Subject: Problems with Forking!!
Message-Id: <367d2520.52770450@news>

I posted a few days ago regarding a mailing list script that was
crashing on my server. Let me assure that this is not being used for
SPAM, it is a sponsored and subscriber only list.

I'm running this on perl, version 5.004_04 built for i386-bsdos

I have been trying to set process management to keep the mailing
routine from consuming all of my resources. I've been able to prevent
the script from using up all of the processes on the server but now
I', getting duplicate output.

as a test I'm sending to a list of 100 of my own email address, I'm
receiving around 108-115. I don't know how to prevent the duplicates.

 I've set $| = 1; in my script to try and prevent this, but it's had
no effect.

In the following code, the process "send_mail", is already known to
function correctly, I just left it in for the sake of clarity in what
I'm looking at..

This is what I've got, what am I doing wrong? 

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

$SIG{CHLD} = sub {wait}; # Get rid of zombie processes.
 
   FORK:
   { if ($pid = fork) # Parent process
     { ### beginning of send_mail
  		if ($form_data{'database'} eq "text.list")
  		{ &real_send_mail($fromuser, $fromsmtp, $touser,
$tosmtp, $subject, $messagebody);}    
  		else
  		{ &real_send_mail_html($fromuser, $fromsmtp, $touser,
$tosmtp, $subject, $messagebody);
  		}
	 }
	 ### End of send_mail
     elsif (defined $pid) # Child process
     { ### beginning of send_mail
	   	if ($form_data{'database'} eq "text.list")
	   	{ &real_send_mail($fromuser, $fromsmtp, $touser,
$tosmtp, $subject, $messagebody);}    
	   	else
	   	{ &real_send_mail_html($fromuser, $fromsmtp, $touser,
$tosmtp, $subject, $messagebody);
	   	redo FORK;
	 }
	 }
	 ### End of send_mail
     elsif ($!=~/No more processes/) # Fork failed
     { sleep 5;
       redo FORK;
     } else {
     die "Can't fork: $!\n";
   }
   } 
-----------------------------------------------------------------------------------
Any guidance would be greatly appreciated. I know there are better
methods to manage such a mailing routine, but I'm currently eating the
time on this job and as the subscriber base expands, my client will
likely upgrade to a full-blown list server package.

a quick and dirty workaround is all I seek.
-JT

Remove the "not" and delete the "dot" to reply
jett1not@homedot.com


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

Date: Thu, 17 Dec 1998 11:34:16 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Searching through a 10MB file
Message-Id: <ebohlmanF43xH4.433@netcom.com>

Uri Guttman <uri@sysarch.com> wrote:
: are you searching for multiple entries per pass? if so then you can read
: all the search id's into a hash and see if record matches any hash
: entry. this will be a major win and speedup. but it only works if you
: are looking for many items during one exec of the program. i will assume
: so in my comments below. in any case, searching for one will not be slow
: and is just a simpler case.

If he's doing lots of passes looking for small (possibly single) numbers 
of items, his best bet is to build an auxilliary index file containing 
the key and offset of each "start" line.

:   CMA>    while (<DDTS_DATA>) {
:   CMA>       chop($_);

: use chomp. it is safer.

Unfortunately, CMA's post specified Perl4 as a requirement :(


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

Date: 17 Dec 1998 16:18:34 +0100
From: rutka@lucent.com (Micha3 Rutka)
To: jimbo@cgocable.net
Subject: Re: sort it ?
Message-Id: <wsmaf0mpzjp.fsf@hzsac328.nl.lucent.com>

rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
> Jim Fitzsimmons <jimbo@cgocable.net> wrote:
> 
> > text file looks like this, in the format of vendor, price 1, price2, price
> > 3, price4....etc. :
> > 
> > vendor1 99.00 98.00 299.00 300.00 
> > vendor2 89.00 94.00 299.00 300.00 
> > vendor3 99.00 14.00 299.00 300.00 
< Nice explain of ST removed >
> And you can put all three steps together:
> 
> @vendors = map { $_->[1] }
>            sort { $a->[0] <=> $b->[0] }
>            map { [ (split " ", $_)[$field], $_ ] } @vendors;
> 

Alternativly, you can speed up a little bit by using a construction,
which I invented during problem of sorting IP addresses (look in
Dejanews for articles from October of this year). Here is the code:

@vendors = map{ substr($_,9) } 
           sort 
           map{ sprintf("%9.2f",(split " ",$_)[$field]).$_ } @vendors;

Note: I assume that your vendors spend less than 999999.99 ;-).

-- 
Dr. Ir. Michal Rutka       Lucent Technologies - Huizen, The Netherlands
Senior System Engineer     mailto:rutka@lucent.com


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

Date: Thu, 17 Dec 1998 05:37:22 -0800
From: "E-swap" <darrensweeney@eswap.co.uk>
Subject: Split String
Message-Id: <75b1ff$235@sjx-ixn3.ix.netcom.com>

Hi

I have searched for this but cannot find the answer.

I have a string which could be "hshsh123456789" or "hdgsfsre123456789"

What I need to do is split off the last 9 digits ... how do I do that?

Thanks all for your help

Darren




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

Date: 17 Dec 1998 14:47:13 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Split String
Message-Id: <83r9tyev8e.fsf@vcpc.univie.ac.at>

Re: Split String, E-swap <darrensweeney@eswap.co.uk>
said:

E-swap> Hi I have searched for this but cannot find
E-swap> the answer.

perldoc perlre
perldoc -f substr

E-swap> I have a string which could be
E-swap> "hshsh123456789" or "hdgsfsre123456789"

E-swap> What I need to do is split off the last 9
E-swap> digits ... how do I do that?

Either with a regexp, \d{9} matches 9 digits,

or, substr() with a -ve position argument works from
the end of the string.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Thu, 17 Dec 1998 13:50:30 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Split String
Message-Id: <ebohlmanF443s7.AwG@netcom.com>

E-swap <darrensweeney@eswap.co.uk> wrote:
: I have searched for this but cannot find the answer.

It would help if you told us where you searched, so that we could correct 
any deficiencies in Perl's documentation.

: I have a string which could be "hshsh123456789" or "hdgsfsre123456789"

: What I need to do is split off the last 9 digits ... how do I do that?

($last_9)=($string=~/(\d{9})$/);


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

Date: Thu, 17 Dec 1998 12:53:12 +0100
From: Kamran Iranpour <kamran@norsar.no>
Subject: sql in perl ?
Message-Id: <3678F0A8.10AC@norsar.no>

Hi
  
  I am a newbie in perl so have patience with me.
  I am writing a CGI-script in perl which recieve s
  a field from a html page and then is supposed to handle that
  as a key for data in a Oracle database, fetch the data
  and send them back to the page. Is there a package in perl
  for doing sql calls to Oracle ? Or maybe you will be kind 
  to forward me to a faq dealing with this issue.

  Thanks in advance
  
  Kamran


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

Date: 17 Dec 1998 12:55:38 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: sql in perl ?
Message-Id: <83soefdltx.fsf@vcpc.univie.ac.at>

Re: sql in perl ?, Kamran <kamran@norsar.no> said:

Kamran> and send them back to the page. Is there a
Kamran> package in perl for doing sql calls to
Kamran> Oracle ?

Hi,

look in CPAN for the DBD and DBI modules.  These
will do what you want.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

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


Administrivia:

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

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

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


------------------------------
End of Perl-Users Digest V8 Issue 4446
**************************************

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