[19408] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1603 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 24 09:05:38 2001

Date: Fri, 24 Aug 2001 06:05:11 -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: <998658311-v10-i1603@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 24 Aug 2001     Volume: 10 Number: 1603

Today's topics:
        avoid date like 31st of february (cecile)
    Re: avoid date like 31st of february (Rafael Garcia-Suarez)
        Date module <jonni@ifm.liu.nospam.se>
    Re: dynamic menu (efficiency) (Anno Siegel)
    Re: dynamic menu (efficiency) <ilya@martynov.org>
    Re: dynamic menu (efficiency) (Anno Siegel)
    Re: email this page script <s.warhurst@rl.ac.uk>
    Re: join (Anno Siegel)
        landscape printing from windows (Mike Solomon)
    Re: Microsoft Perl <bart.lateur@skynet.be>
    Re: modules and variables <goldbb2@earthlink.net>
        Newbie. Searching a text file and replacing text. <gortona@cs.man.ac.uk>
        Perl & SQL/ODBC <s.warhurst@rl.ac.uk>
    Re: Perl & SQL/ODBC <s.warhurst@rl.ac.uk>
    Re: Perl rookie question!  Setting up perl to work with <s.warhurst@rl.ac.uk>
        Persistent Perl Cookies using ASP? <ted_godwin@mindspring.com>
        pl or not pl, that is the question (Joachim Ziegler)
    Re: pl or not pl, that is the question <ilya@martynov.org>
    Re: pl or not pl, that is the question <wyzelli@yahoo.com>
    Re: printing from windows (gdi32) <goldbb2@earthlink.net>
        Regular Expression problem ??? <eric138@yahoo.com>
    Re: Regular Expression problem ??? (Bernard El-Hagin)
        searching an arrey <michealo@ozemail.com.au>
    Re: searching an arrey <ilya@martynov.org>
    Re: searching an arrey <michealo@ozemail.com.au>
    Re: State of Parrot <qvyht@removejippii.fi>
        SyncML and Perl? (Will)
    Re: SyncML and Perl? <ilya@martynov.org>
        using $/  for input, that's not coming from a file. (Klaus Foerster)
        Using newlines in Parse::RecDescent <weymer@mediawise.de>
    Re: Using newlines in Parse::RecDescent (Damian Conway)
        Using non-blocking sockets on Win2000 <Usenet@bNamed.be>
        win32 perlmagick dll <thoschne678@hotmail.com>
    Re: Win32: how much disk space free? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Aug 2001 04:16:46 -0700
From: cvieval@noos.fr (cecile)
Subject: avoid date like 31st of february
Message-Id: <edf9d1a7.0108240316.5ab25d90@posting.google.com>

Hello,

I am a novice in perl. I know how to do simple programs (print files
on a html page or forms and record information in a file) but I am
asking to do something more complicated.

I read lots of questions that was asked previously in
comp.lang.perl.misc about localtime and I don't really find what I
need. I don't have any book just a few lessons a teacher gave me +
activeperl documentation.

I would like to know if it is possible to use the function localtime
when I use list fields (in a html form written in perl).
Let me explain my problem:
I have several list fields for a date, one for the day, one for the
month, one for the year and a text field to write Time (I am not sure
if it is the best presentation for all of them). People can choose the
date and hour they like (for exemple for a delivery date) but of
course they shouldn't choose any date like 31st february.
So I would like to know how to avoid this kind of date when people
choose it (not in purpose I hope) and if localtime can do it. If, yes
can I find this information somewhere?

I thank you in advance for having time to answer my question.

Cécile


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

Date: 24 Aug 2001 12:28:01 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: avoid date like 31st of february
Message-Id: <slrn9ocicq.lkp.rgarciasuarez@rafael.kazibao.net>

cecile wrote in comp.lang.perl.misc:
: [...] People can choose the
: date and hour they like (for exemple for a delivery date) but of
: course they shouldn't choose any date like 31st february.
: So I would like to know how to avoid this kind of date when people
: choose it (not in purpose I hope) and if localtime can do it. If, yes
: can I find this information somewhere?

One of the methods is to convert the date to unixtime (nb of seconds
since 1970) and then to convert it back to a date. Then, check if the
result has not change.

Here is a test script : (it uses the Date::Parse module, which can
be found on CPAN) :

#!/usr/local/bin/perl
use strict;
use warnings;
use Date::Parse;
my ($year, $month, $day) = @ARGV;
my $unixtime = str2time(sprintf('%04d-%02d-%02d', $year, $month, $day));
if (!defined $unixtime) { die "Can't parse date\n"; }
my (undef,undef,undef,$day2,$month2,$year2) = localtime($unixtime);
$year2 += 1900;
$month2 += 1;
if (  $year  != $year2
   || $month != $month2
   || $day   != $day2)
{
    die "Bad date!\n";
}
print "Date OK\n";
__END__

Using Date::Parse has the advantage that you can feed it about any date
format.

-- 
Rafael Garcia-Suarez
$japh="Just another Perl hacker,\n";@j=split/(?= )/,$japh;for my $i
(0..3){*{(($x)=$j[3-$i]=~/\w+/g)[0]}=sub(@){print$j[$i]}}eval$japh;


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

Date: Fri, 24 Aug 2001 13:07:53 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Date module
Message-Id: <9m5c90$svg$1@newsy.ifm.liu.se>

I want to write a simple function like this.

print &AddDaysToDate('2001-05-24',5);
Will get you:
2001-05-29

print &AddDaysToDate('2001-05-24',-25);
Will get you:
2001-04-29

And so on. I could write it myself, but I don't want to reinvent the wheel.
So what module would you suggest. It should handle leap year, but it doen't
need to recognize any fancy dateformat.

What is the leap year convention anyway?
Are the leapyears:
year=(n*4 but not m*100);
and
year=(o*400);

for any integers n,m,o
--
/jN




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

Date: 24 Aug 2001 09:22:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dynamic menu (efficiency)
Message-Id: <9m56cr$mkg$1@mamenchi.zrz.TU-Berlin.DE>

According to  <four12and8up@unspam-me.yahoo.com>:
> I'm fooling around with keyboard input and wanted to create dynamic menu
> choices similar to what Internet Explorer does on the address line.
> 
> For example, if I have a list of the 50 US states, and I type 'M'
> on the input line, I would want to parse the list of states and find only
> those beginning with 'M'. If the next letter I type is 'i', the
> list should be narrowed down to the four states beginning with 'Mi'.

[etc]

Take a look at the module Text::Complete.  It may not do exactly what
IE does with the "address line" (whatever that is) but it deals with
the kind of situation you describe.

Anno


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

Date: 24 Aug 2001 13:37:35 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: dynamic menu (efficiency)
Message-Id: <87bsl5lrxc.fsf@abra.ru>

>>>>> On 24 Aug 2001 09:22:35 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) said:

AS> Take a look at the module Text::Complete.  It may not do exactly what
AS> IE does with the "address line" (whatever that is) but it deals with
AS> the kind of situation you describe.

Maybe Term::Complete? Text::Complete doesn't exist.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 24 Aug 2001 09:42:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dynamic menu (efficiency)
Message-Id: <9m57ii$t14$1@mamenchi.zrz.TU-Berlin.DE>

According to Ilya Martynov  <ilya@martynov.org>:
> >>>>> On 24 Aug 2001 09:22:35 GMT, anno4000@lublin.zrz.tu-berlin.de
> (Anno Siegel) said:
> 
> AS> Take a look at the module Text::Complete.  It may not do exactly what
> AS> IE does with the "address line" (whatever that is) but it deals with
> AS> the kind of situation you describe.
> 
> Maybe Term::Complete? Text::Complete doesn't exist.

Right, I mis-pasted.

Anno


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

Date: Thu, 23 Aug 2001 16:04:11 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: email this page script
Message-Id: <9m361c$15ic@newton.cc.rl.ac.uk>

When I need to do that I use Blat
(http://www.interlog.com/~tcharron/blat.html - version 1.8.9) and then
control it in Perl like this:

system ("$blatdir/blat.exe $blatdir/blat.txt -to $recipient -replyto
$from -from $from -sender $from -subject \"$subject\" -body
\"$content\" -q");

[defining or changing the variables as appropriate]

Note, when using Blat to send the contents of a variable as the message
body, you have to still specify a file to send.. in this case:
$blatdir/blat.txt. So, create a file and just type "dummy file" in it or
something.. Blat will not send the text it contains when you specify a
message body using the "-body" switch. You also need to specify a valid
server when you install blat.

There's probably an entirely more efficient way to do it than this, but I
don't get any problems from this method.

---------¦
  Bigus @ work
             ¦----------


"Class Spokesman" <galligat@tcd.ie> wrote in message
news:3B850966.7D1FC124@tcd.ie...
>     Hay
> I'm looking for a freeware perl script that can email a page
> Does anyone where i can find one thanks
>
>
> Tom
>




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

Date: 24 Aug 2001 07:10:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: join
Message-Id: <9m4ult$jn5$1@mamenchi.zrz.TU-Berlin.DE>

According to Michael Carman  <mjcarman@home.com>:

[...]

> #!/usr/bin/perl -w
> use strict;
> 
> while (my $line = <DATA>) {
>     while ($line !~ /;$/) {
>         $line =~ s/\n$/ /;

          last if eof DATA;

Without this it will loop endlessly if the last line is incomplete.

>         $line .= <DATA>;
>     }
>     my @array = split(/ /, $line);
>     print "$array[9]\n";
> }

Anno


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

Date: 24 Aug 2001 03:53:36 -0700
From: mike_solomon@lineone.net (Mike Solomon)
Subject: landscape printing from windows
Message-Id: <56568be5.0108240253.1228d222@posting.google.com>

I have written a script to print from windows - see below

The filename, printer, font and fontsize are passed to it and it
prints.

what I can't get it to do is change the printer orientation to
landscape.

I posted this problem a while back and got the following responce

You need to pass the address of a DEVMODE structure as the fourth 
parameter to CreateDC, and set its dmOrientation field to 
DMORIENT_LANDSCAPE.

I have no idea how to do this. I come from a Unix background and have
problems with Windows at the best of times !

Any help in incorporating this into my code would be gratefully
received

#winprint.pm
#print from windows

package winprint;
use Exporter ();
@ISA = qw(Exporter);

#export variables to use - don't need to declare in program
@EXPORT = qw(WIN_PRINT VALID_PRINTER PRINT_REPORT);

use strict;
use diagnostics;
use Win32::API;

##################################################################
# API declarations:
#set variables
my $CreateDCforPrinter = new Win32::API('gdi32',"CreateDC", [qw'N P N
N'], 'N');
my $DeleteDC = new Win32::API("gdi32","DeleteDC",['N'], 'N');
my $StartDoc = new Win32::API('gdi32',"StartDoc", [qw'N P'], 'N');
my $EndDoc = new Win32::API('gdi32',"EndDoc", ['N'], 'N');
my $StartPage = new Win32::API('gdi32',"StartPage", ['N'], 'N');
my $EndPage = new Win32::API('gdi32',"EndPage", ['N'], 'N');
my $GetDeviceCaps = new Win32::API('gdi32',"GetDeviceCaps", [qw'N N'],
'N');
my $CreateFont = new Win32::API('gdi32',"CreateFont", [('N') x 13,
'P'], 'N');
my $SelectObject = new Win32::API('gdi32',"SelectObject", [qw'N N'],
'N');
my $DeleteObject = new Win32::API('gdi32',"DeleteObject", ['N'], 'N');
my $TextOut = new Win32::API('gdi32',"TextOut", [qw'N N N P N'], 'N');
my $GetTextExtentPoint32 = new Win32::API('gdi32',
'GetTextExtentPoint32', [qw'N P N P'], 'N');

###################################################################
#print from windows
sub WIN_PRINT {
	my ($filename,$printername, $fontsize, $font_type) = @_;

	#test for valid file or die
	-e $filename or die "$filename does not exist";
	
	#set defaults
	$fontsize = 10 if ! $fontsize;
	$font_type = "Lucida Console" if ! $font_type;
	$printername ="Lexmark 3200 Series ColorFine" if ! $printername;  
#printer name

	#print section
	my $hdc = $CreateDCforPrinter->Call(0, $printername, 0, 0);
	my $jobname = "Printer Test";
	my $docinfo = pack 'VpV', 12, $jobname, 0;

	#if($StartDoc->Call($hdc, $docinfo) && $StartPage->Call($hdc)) {
	$StartDoc->Call($hdc, $docinfo);
		my($HORZRES, $VERTRES, $LOGPIXELSY) = (8, 10, 90);
		my $horzres = $GetDeviceCaps->Call($hdc, $HORZRES);
		my $vertres = $GetDeviceCaps->Call($hdc, $VERTRES);
		my $dpi = $GetDeviceCaps->Call($hdc, $LOGPIXELSY);

		# Font 
		my $newfont = $CreateFont->Call($fontsize*$dpi/72, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, $font_type);
		my $oldfont = $SelectObject->Call($hdc, $newfont);           

		open FILE, $filename or die "Can't open $filename";

		my $line = 0;
		my $height = $fontsize*$dpi/72*1.03;
		my $lines_per_page = int($vertres/$height) -1;

		while (<FILE>) {
			#call start page if line == 0
			$StartPage->Call($hdc) if $line == 0;

			chomp;					#strip newline

			my $text = $_;
		
			$text =~ s/\t/    /g;		#replace tabs with "    "

			#print
			$TextOut->Call($hdc, 100, ++$line * $height, $text, length($text));

			#page break
			if ($line == $lines_per_page) {
				$EndPage->Call($hdc);
				$line = 0;
			}

		} #end of file

		#I presume next line replaces new printer settings with original
settings
		$SelectObject->Call($hdc, $oldfont);
		#delete new settings
		$DeleteObject->Call($newfont);
		#end printing and eject paper
		$EndPage->Call($hdc) and $EndDoc->Call($hdc);
	#}
	#Delete DC - ???
	$DeleteDC->Call($hdc);

}

#return without error
1;

__END__


Regards


Mike Solomon


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

Date: Fri, 24 Aug 2001 09:20:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Microsoft Perl
Message-Id: <o57cot0o4p8193upsre9iu8jrqn10tlguj@4ax.com>

William Alexander Segraves wrote:

>BTW, IndigoStar claims in their release history to have upgraded to v
>5.0005. When I downloaded MicroWeb, v 5.001 was still in the distribution.
>They have not responded to questions.

Perhaps as included with Microweb.

But the most recent IndigoPerl is 5.6.1. Get that. It's free.

-- 
	Bart.


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

Date: Fri, 24 Aug 2001 07:32:56 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: modules and variables
Message-Id: <3B863B68.54175E56@earthlink.net>

Jeff Thies wrote:
> 
>   I have a few functions that I've moved into a module. I'm unsure how
> to initialize/reset global variables for these functions.
> 
>   Here's what I have:
> 
> use myModule($enviornment_var1,$enviornment_var2);
> 
> and "myModule"
> *********************
> my($env1,$env2)=@_;

This doesn't work.
When you do use myModule (list); it gets translated to
BEGIN { require myModule; myModule->import(list) }
The items in list are not available at toplevel in @_, as you seem to
think, but are available in sub import as @_, as perfectly normal
subroutine arguments.

-- 
I'm not a programmer but I play one on TV...


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

Date: Fri, 24 Aug 2001 13:27:54 +0100
From: Andrew Paul Gorton <gortona@cs.man.ac.uk>
Subject: Newbie. Searching a text file and replacing text.
Message-Id: <3B86484A.E8984AE4@cs.man.ac.uk>

Hi all,

I need to search a text file similar to this:

ChkDisk:	ERROR /dev/hda5 90% full
ChkCPU:		ERROR load average:1.00, 0.01, 2.00
 ...

I need to find say the ChkDisk and replace this line with the updated
line from another program.
How is this done.

Cheers for the help


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

Date: Fri, 24 Aug 2001 10:49:15 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Perl & SQL/ODBC
Message-Id: <9m57us$lfe@newton.cc.rl.ac.uk>

Hi

I'm using Win32 ODBC to create an MS Access database and have a little
problem:

What I do is loop through an array of listserv header keywords (array
contains eg: subscription, send, reply-to) check to see if a column exists
with the same name as the keyword, and if it doesn't - create it. The line I
use is as follows ($kw is the current keyword in the array):

if(defined $db->Sql("SELECT $kw FROM data"))
{
  $db->Sql("ALTER TABLE data ADD $kw text[255]");
}

Now, for the subscription and send keywords it works fine.. however when it
gets to reply-to it doesn't work. The reason appears to be because of the
hyphen in the keyword (it does this with other keywords with hyphens in
aswell). If I go to the database in MS Access itself, it has no problems
letting me create a column called reply-to, so it's not as if it's an
illegal character according to Access.

If I put quotes round $kw then it does create the reply-to column, however
it also leaves the quotes in the column name, which I don't want. Any ideas
how I can get round this?

Thanks


---------¦
  Bigus @ work
             ¦----------






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

Date: Fri, 24 Aug 2001 11:30:19 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Perl & SQL/ODBC
Message-Id: <9m5abs$ng0@newton.cc.rl.ac.uk>

Solved it! Enclosing $kw in square brackets does the trick.. an SQL issue
rather than a Perl one.

---------¦
  Bigus @ work
             ¦----------


"S Warhurst" <s.warhurst@rl.ac.uk> wrote in message
news:9m57us$lfe@newton.cc.rl.ac.uk...
> Hi
>
> I'm using Win32 ODBC to create an MS Access database and have a little
> problem:
>
> What I do is loop through an array of listserv header keywords (array
> contains eg: subscription, send, reply-to) check to see if a column exists
> with the same name as the keyword, and if it doesn't - create it. The line
I
> use is as follows ($kw is the current keyword in the array):
>
> if(defined $db->Sql("SELECT $kw FROM data"))
> {
>   $db->Sql("ALTER TABLE data ADD $kw text[255]");
> }
>
> Now, for the subscription and send keywords it works fine.. however when
it
> gets to reply-to it doesn't work. The reason appears to be because of the
> hyphen in the keyword (it does this with other keywords with hyphens in
> aswell). If I go to the database in MS Access itself, it has no problems
> letting me create a column called reply-to, so it's not as if it's an
> illegal character according to Access.
>
> If I put quotes round $kw then it does create the reply-to column, however
> it also leaves the quotes in the column name, which I don't want. Any
ideas
> how I can get round this?
>
> Thanks
>
>
> ---------¦
>   Bigus @ work
>              ¦----------
>
>
>
>




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

Date: Thu, 23 Aug 2001 10:14:02 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Perl rookie question!  Setting up perl to work with IIS or Personal Web Server
Message-Id: <9m2hgs$14cg@newton.cc.rl.ac.uk>

"Tintin" <somewhere@in.paradise.net> wrote in message
news:lNVg7.11$w01.56376@news.interact.net.au...
> > The line:  #!/usr/bin/perl is for unix.
> >
> > You need sth like:  #!c:/perl/bin/perl.exe
>
> Rubbish!  Don't answer questions that are off topic and don't give
incorrect
> answers.

1) "/usr/bin" is a unix style path.. and if I get the drive wrong in the
"c:/perl/bin/perl.exe" path when switching between different NT machines
with different perl locations my CGI throws up errors, so my answer was at
least partly correct.

2) His post is about Perl.. maybe the cause of his problem is the enviroment
Perl is running in, but he doesn't know that and he has to start somewhere
to find out. It always amuses me about some newsgroups.. on the one hand you
get some great selfless ppl who spend their valuable time helping solve
other people's problems, and on the other there are people like you who seem
to think it is their place to go round "policing" the newsgroup, and do so
in the most unhelpful way possible. If you think it's off-topic then why are
you reading it?

3) If you are going to accuse someone of being incorrect then at least have
the decency to say "why" you think they are. I don't mind being corrected
and welcome it as long as in doing so is decent about it. Similarly, if you
accuse someone with a genuine query of being off-topic, then say why.

4) Don't tell me what to do.. you are nobody to me, so fuck you.




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

Date: Fri, 24 Aug 2001 08:51:20 -0400
From: "TedWeb" <ted_godwin@mindspring.com>
Subject: Persistent Perl Cookies using ASP?
Message-Id: <9m5inn$8ep$1@slb0.atl.mindspring.net>

Hello everyone,

I'm trying implement persistent perl cookies using ASP to automate a website
login. After some investigation, this is what I have come up with:

   $Response->Cookies('someCookie')->{Test} = 'OK';
   $Response->Cookies('someCookie')->{Expires} = '01-Jan-2003-01:00:00 GMT';
   $Response->Cookies('someCookie')->{Secure} = 0;

This enables session cookies, but not persistent cookies. Oddly, the hash
value for Test can be read, but not for Expires and Secure. I'm sure this is
a security assest. Can anyone tell me how to create persistent cookies that
are saved as a file? Many thanks,

-Ted




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

Date: 24 Aug 2001 03:01:10 -0700
From: ziegler@algorilla.de (Joachim Ziegler)
Subject: pl or not pl, that is the question
Message-Id: <93aad7d0.0108240201.240f78b2@posting.google.com>

hi perlers,

is it ok to call an ordinary perl-script 'helloworld.pl',
or should it rather be call just 'helloworld'?

i remember having read that the 'pl' stands for 'perl library', but i
can't find anything about this subject neither in the camel book, nor
in the FAQ.

greetings from germany,
joachim


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

Date: 24 Aug 2001 14:14:53 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: pl or not pl, that is the question
Message-Id: <87pu9lkbmq.fsf@abra.ru>

>>>>> On 24 Aug 2001 03:01:10 -0700, ziegler@algorilla.de (Joachim Ziegler) said:

JZ> hi perlers,
JZ> is it ok to call an ordinary perl-script 'helloworld.pl',
JZ> or should it rather be call just 'helloworld'?

JZ> i remember having read that the 'pl' stands for 'perl library', but i
JZ> can't find anything about this subject neither in the camel book, nor
JZ> in the FAQ.

 .pl as 'perl library' was valid in Perl 4 days. Nowdays people
(including me) often use .pl for scripts. I think it is ok.

JZ> greetings from germany,

greeting from russia :)

JZ> joachim

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 24 Aug 2001 21:39:23 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: pl or not pl, that is the question
Message-Id: <Xarh7.1$MU2.13857@wa.nnrp.telstra.net>

"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87pu9lkbmq.fsf@abra.ru...
> >>>>> On 24 Aug 2001 03:01:10 -0700, ziegler@algorilla.de (Joachim
Ziegler) said:
>
> JZ> hi perlers,
> JZ> is it ok to call an ordinary perl-script 'helloworld.pl',
> JZ> or should it rather be call just 'helloworld'?
>
> JZ> i remember having read that the 'pl' stands for 'perl library', but i
> JZ> can't find anything about this subject neither in the camel book, nor
> JZ> in the FAQ.
>
> .pl as 'perl library' was valid in Perl 4 days. Nowdays people
> (including me) often use .pl for scripts. I think it is ok.
>
> JZ> greetings from germany,
>
> greeting from russia :)

 .pl is the default in a win32 environment.

nothing or .pl is common in a *nix environment.

 .pl or .cgi is common in a CGI environment depending only on the
configuration of the web server and personal preference.

heh, greetings from Australia  :)

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Fri, 24 Aug 2001 07:26:58 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: printing from windows (gdi32)
Message-Id: <3B863A02.29661601@earthlink.net>

Mike Solomon wrote:
[snip]
> any suggestion will be gratefully received.

I don't know about your particular problem [printing orientation], I do
have some suggestions for your code.

[snip]
> # API declarations:
> my $CreateDCforPrinter = new Win32::API('gdi32',"CreateDC", [qw'N P N
> N'], 'N');
> my $DeleteDC = new Win32::API("gdi32","DeleteDC",['N'], 'N');
> my $StartDoc = new Win32::API('gdi32',"StartDoc", [qw'N P'], 'N');
> my $EndDoc = new Win32::API('gdi32',"EndDoc", ['N'], 'N');
> my $StartPage = new Win32::API('gdi32',"StartPage", ['N'], 'N');
> my $EndPage = new Win32::API('gdi32',"EndPage", ['N'], 'N');
> my $GetDeviceCaps = new Win32::API('gdi32',"GetDeviceCaps", [qw'N N'],
> 'N');
> my $CreateFont = new Win32::API('gdi32',"CreateFont", [('N') x 13,
> 'P'], 'N');
> my $SelectObject = new Win32::API('gdi32',"SelectObject", [qw'N N'],
> 'N');
> my $DeleteObject = new Win32::API('gdi32',"DeleteObject", ['N'], 'N');
> my $TextOut = new Win32::API('gdi32',"TextOut", [qw'N N N P N'], 'N');
> my $GetTextExtentPoint32 = new Win32::API('gdi32',
> 'GetTextExtentPoint32', [qw'N P N P'], 'N');

All these declarations are pretty ugly, and when calling them, you have
to do stuff like $CreateFont->Call( ... ), instead of a more sensible
CreateFont( ... ).

This could be fixed by doing something like:
my %api_calls = (
	CreateDC => 'NPNNN', DeleteDC => 'NN', StartDoc => 'NPN',
	EndDoc => 'NN', StartPage => 'NN', EndPage => 'NN',
	GetDeviceCaps => 'NNN', CreateFont => 'N' x 13 . 'PN',
	SelectObject => 'NNN', DeleteObject => 'NN',
	TextOut => 'NNNPNN', GetTextExtentPoint32 => 'NPNPN',
);
while( my( $name, $params ) = each %api_calls ) {
	my @invals = $params =~ /./g;
	my $outval = pop @invals;
	my $apicall = Win32::API( 'gdi32', $name, \@invals, $outval );
	no strict 'refs';
	*{$name} = sub { $apicall->Call(@_) };
}


if(my $hdc = CreateDC(0, $printername, 0, 0)) {
        my $jobname = "Printer Test";
        my $docinfo = pack 'VpV', 12, $jobname, 0;

        if( StartDoc($hdc, $docinfo) && StartPage($hdc) ) {
 ....

Doesn't this look much prettier?

-- 
I'm not a programmer but I play one on TV...


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

Date: Fri, 24 Aug 2001 20:54:08 +0800
From: "Eric Chow" <eric138@yahoo.com>
Subject: Regular Expression problem ???
Message-Id: <9m5iss$hj09@ctmsun0.macau.ctm.net>

Hello,

Would you please to teach me how to define an expression if I want to get
the following result ?

Source =
"<ALWAYS_BE_HERE><ANY_OF_OTHERS><ANOTHER_ALWAYS_BE_HERE>#DATA_THAT_I_WANT#<E
ND_DELIMETER>"


If I want to get the contents of  "#DATA_THAT_I_WANT#" from the above
source, how to define an expression ?

where "<ALWAYS_BE_HERE>", "<ANOTHER_ALWAYS_BE_HERE>" and "<END_DELIMETER>"
are fixed contents, but the "<ANY_OF_OTHERS>" are variant contents.




Best regards,
Eric





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

Date: Fri, 24 Aug 2001 13:02:23 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Regular Expression problem ???
Message-Id: <slrn9ocjlv.g4l.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 24 Aug 2001 20:54:08 +0800, Eric Chow <eric138@yahoo.com> wrote:
>Hello,
>
>Would you please to teach me how to define an expression if I want to get
>the following result ?
>
>Source =
>"<ALWAYS_BE_HERE><ANY_OF_OTHERS><ANOTHER_ALWAYS_BE_HERE>#DATA_THAT_I_WANT#<E
>ND_DELIMETER>"
>
>
>If I want to get the contents of  "#DATA_THAT_I_WANT#" from the above
>source, how to define an expression ?
>
>where "<ALWAYS_BE_HERE>", "<ANOTHER_ALWAYS_BE_HERE>" and "<END_DELIMETER>"
>are fixed contents, but the "<ANY_OF_OTHERS>" are variant contents.


Assuming input in $_ you can do this:


my ($data_that_i_want) = />([^<]+)</;

print $data_that_i_want;


Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: Fri, 24 Aug 2001 20:01:21 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: searching an arrey
Message-Id: <9Bph7.2065$vI2.118063@ozemail.com.au>

how can i search an arrey for a word, and show the whole line that it's on .
the word can be any where on the line




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

Date: 24 Aug 2001 14:17:18 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: searching an arrey
Message-Id: <87lmk9kbip.fsf@abra.ru>

>>>>> On Fri, 24 Aug 2001 20:01:21 +1000, "nathan" <michealo@ozemail.com.au> said:

n> how can i search an arrey for a word, and show the whole line that it's on .
n> the word can be any where on the line

Array? Lines? Do you have an array which has as its elements some
lines of some text?

If so you can use following:

    my (@lines) = grep SEARCH_CRITERIA, @array.

See 'perldoc -tf grep' for more info.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 24 Aug 2001 20:38:08 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: searching an arrey
Message-Id: <A7qh7.2090$vI2.120641@ozemail.com.au>

yes, there is text.
id&&name&&post
each is split after the search find's a match




Ilya Martynov <ilya@martynov.org> wrote in message
news:87lmk9kbip.fsf@abra.ru...
> >>>>> On Fri, 24 Aug 2001 20:01:21 +1000, "nathan"
<michealo@ozemail.com.au> said:
>
> n> how can i search an arrey for a word, and show the whole line that it's
on .
> n> the word can be any where on the line
>
> Array? Lines? Do you have an array which has as its elements some
> lines of some text?
>
> If so you can use following:
>
>     my (@lines) = grep SEARCH_CRITERIA, @array.
>
> See 'perldoc -tf grep' for more info.
>
> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




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

Date: Fri, 24 Aug 2001 11:15:25 GMT
From: Hessu <qvyht@removejippii.fi>
Subject: Re: State of Parrot
Message-Id: <3B863591.B1A3DD54@removejippii.fi>



Dan Sugalski wrote:
> 
> Hessu <qvyht@removejippii.fi> wrote:
> > Polly still alive and nacking?
> 
> Yup, doing just fine. Working (albeit early stage) source soon.
> 
> Announcements to be made to use.perl.org, I expect.
> 
>                                 Dan

Great, thanx!
I'll keep cookies ready!


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

Date: 24 Aug 2001 02:16:28 -0700
From: nailism@hotmail.com (Will)
Subject: SyncML and Perl?
Message-Id: <7c9a4f04.0108240116.23a84d6c@posting.google.com>

I have been working on a project to sync data across platforms using
xml, Recently we have found that there is an x-fer protocal called
SyncML.
I was really hoping to write the serverside using perl (because I am
more confortable with perl than any other language) however I have
been unable to find any resource for SyncML using Perl. the supported
development envirnments are Visuall C++, Palm (C\C++) and somthing
called mingw 32.

Is anyone working with SyncML and perl?


Thanks

Will


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

Date: 24 Aug 2001 13:23:05 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: SyncML and Perl?
Message-Id: <87g0ahlsli.fsf@abra.ru>

>>>>> On 24 Aug 2001 02:16:28 -0700, nailism@hotmail.com (Will) said:

W> I have been working on a project to sync data across platforms using
W> xml, Recently we have found that there is an x-fer protocal called
W> SyncML.
W> I was really hoping to write the serverside using perl (because I am
W> more confortable with perl than any other language) however I have
W> been unable to find any resource for SyncML using Perl. the supported
W> development envirnments are Visuall C++, Palm (C\C++) and somthing
W> called mingw 32.

W> Is anyone working with SyncML and perl?

I've not worked with it but it looks like yet another XML
application. Perl has a lot of modules for XML so I don't see a
problem.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 24 Aug 2001 05:31:44 -0700
From: klaus.foerster@motorola.com (Klaus Foerster)
Subject: using $/  for input, that's not coming from a file.
Message-Id: <7d413c2e.0108240431.1904c62a@posting.google.com>

Hi everybody,

I have a perl program, that reads data from a file and changes
dynamically
(depending on the read in data) the input_record_separators ($/)

Now I want to use the same program to parse a file, that I read in
already
and is saved in an array.

the only idea to reuse the existing program is:

fork the process
1.) one process writes the array to it's stdout (connected to the 2nd
forked
    process) and exits afterwards.

2.) the other process reads the first processes output via stdin and
can now change $/ as required.

Does anyone have a more elegant solution, that avoids spaning
processes or
rewriting the code containing the changes to $/ massively.

thanks in advance and bye


Klaus


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

Date: Fri, 24 Aug 2001 14:34:29 +0200
From: Andreas Weymer <weymer@mediawise.de>
Subject: Using newlines in Parse::RecDescent
Message-Id: <3B8649D5.FD702706@mediawise.de>

Hello,

I'm trying to parse a text line by line using Parse::RecDescent. Each
line is terminated by a "\n".

Although the task setting up a grammar for this case is straightforward
the following program doesn't
produce any results.


     use Parse::RecDescent;

     $grammar =
     q{
         line:       word(s) newline { print "Found a line\n"; }
         word:       /\w+/
         newline : /\n/
     };

     $parse = new Parse::RecDescent ($grammar);


     $data =
     qq(This is line one\nAnd this is line two\n);

     $parse->line($data);


RecDescent doesn't recognize the newlines. Does anybody know what I'm
getting wrong?

Thanks in advance,
Andreas Weymer



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

Date: 24 Aug 2001 12:35:05 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Using newlines in Parse::RecDescent
Message-Id: <9m5hlp$2ua$1@towncrier.cc.monash.edu.au>

Andreas Weymer <weymer@mediawise.de> writes:


>RecDescent doesn't recognize the newlines. Does anybody know what I'm
>getting wrong?

By default, P::RD skips all whitespace (*including* newlines) before
tokens. 

Try this instead:

         line:    <skip: qr/[ \t]*/> word(s) newline 
				{ print "Found a line\n"; }
         word:    /\w+/
         newline: /\n/


Damian


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

Date: Fri, 24 Aug 2001 11:26:07 GMT
From: Bart Mortelmans <Usenet@bNamed.be>
Subject: Using non-blocking sockets on Win2000
Message-Id: <3B8639A5.2040100@bNamed.be>

Greetings,

I have been working with NET::DNS and have seen how it can speed up 
things if you can do multiple look-ups at a time. Now I would like to do 
the same with (some sort of) Whois-system, but I can't get it to work on 
Win2000.

On comp.lang.perl.modules I got some good-looking code for doing 
background lookups for Whois. This code however uses

 > use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);

And I get the error:
 > PerlScript Error error '80004005'
 >
 > (in cleanup) Your vendor has not defined Fcntl macro F_GETFL, used
 >
 > /test/NonblockWhois.asp, line 7

When I try to use this. It seems this is a known problem with ActivePerl 
for Windows.

Can anyone point me in the right direction so I can still do multiple 
(background) socket-connections without using F_GETFL?

I thought I would look into NET::DNS to see how it is done in there, but 
I'm rather a novice user and don't really know where to start...

Thanks,
Bart Mortelmans



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

Date: Fri, 24 Aug 2001 11:35:22 +0200
From: Thomas Schneider <thoschne678@hotmail.com>
Subject: win32 perlmagick dll
Message-Id: <3B861FDA.49293DA0@hotmail.com>

Hi!
I've got a problem running a perl-dll created with active state's
perlctrl. I'm using Perlmagick in my script and the generated dll runs
perfectly on my computer, but on computers with no
perl/imagemagick/perlmagick installed I get the message "unknown error"
when accessing the dll. Does anybody know which dlls I have to bind or
what else I have to do to get the dll running on other computers?
This is the output of perlctrl:
C:\TEMP\ctrl>perlctrl -f pix.pl
Creating PerlCtrl pix.dll ...
Adding Module: D:/Programme/Perl/lib/Exporter.pm
Adding Module: D:/Programme/Perl/lib/Carp.pm
Adding Module: D:/Programme/Perl/site/lib/Win32/OLE.pm
Adding Module: D:/Programme/Perl/lib/DynaLoader.pm
Adding Module: D:/Programme/Perl/lib/auto/DynaLoader/dl_expandspec.al
Adding Module: D:/Programme/Perl/lib/auto/DynaLoader/dl_findfile.al
Adding Module:
D:/Programme/Perl/lib/auto/DynaLoader/dl_find_symbol_anywhere.al
Adding Module: D:/Programme/Perl/lib/auto/DynaLoader/autosplit.ix
Adding Module: D:/Programme/Perl/site/lib/Image/Magick.pm
Adding Module: D:/Programme/Perl/site/lib/auto/Image/Magick/autosplit.ix

Adding Module: D:/Programme/Perl/lib/strict.pm
Adding Module: D:/Programme/Perl/lib/vars.pm
Adding Module: D:/Programme/Perl/site/lib/PerlCOM.pm
Adding Module: D:/Programme/Perl/lib/Config.pm
Adding Module: D:/Programme/Perl/lib/Carp/Heavy.pm
Adding Module: D:/Programme/Perl/site/lib/Win32/OLE/Lite.pm
Adding Module: D:/Programme/Perl/lib/Exporter/Heavy.pm
Adding Module: ./CPixval.pm
Adding Module: D:/Programme/Perl/lib/warnings/register.pm
Adding Module: D:/Programme/Perl/lib/warnings.pm
Adding Module: D:/Programme/Perl/lib/AutoLoader.pm
Adding Binary: D:/Programme/Perl/site/lib/auto/Image/Magick/Magick.dll
Adding Binary: D:/Programme/Perl/site/lib/auto/Win32/OLE/OLE.dll
Done creating pix.dll

Thanks for any help



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

Date: Fri, 24 Aug 2001 11:01:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Win32: how much disk space free?
Message-Id: <r1dcot0rk46d9ocjb3k5dbdma4i7de9n7b@4ax.com>

Benjamin Goldberg wrote:

>Florian Haftmann wrote:
>> 
>> Hi!
>> 
>> I want to examine (Win32) how much disk space (drive A: or B:) is
>> available?
>> How to do?
>
>Look through www.cpan.org or search via search.cpan.org for modules
>starting with Win32:: and if you're lucky, you can get access to some
>win32api function which will do it.

Win32::DriveInfo looks like it will work.

	<http://search.cpan.org/search?dist=Win32-DriveInfo> 

-- 
	Bart.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 1603
***************************************


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