[16765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4177 Volume: 9

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

Date: Wed, 30 Aug 2000 11:05:18 -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: <967658718-v9-i4177@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
        Compiling SSLeay on Solaris 8 <rwiegand@tmltechnologies.com>
    Re: Could we export templates from module? nobull@mail.com
    Re: Extra ^M in text file (Villy Kruse)
    Re: Extra ^M in text file (Anthony Peacock)
        fancy perl regex problem <dan333@my-deja.com>
    Re: fancy perl regex problem <care227@attglobal.net>
    Re: fancy perl regex problem (Anno Siegel)
    Re: File handles with scalar value (Mark-Jason Dominus)
        file locking not working (Anno Siegel)
    Re: file locking not working <soybean_tofu@yahoo.com>
    Re: file locking not working nobull@mail.com
    Re: ftp function call in perl change the file size. <guenther.degenfelder@datev.de>
        Functions which modify thier parameters? <asince1@irix1.gl.umbc.edu>
    Re: Functions which modify thier parameters? (Andrew Johnson)
    Re: Functions which modify thier parameters? nobull@mail.com
    Re: Functions which modify thier parameters? (Mark-Jason Dominus)
        GD module <someone@microsoft.com>
        gilly asks: what is $isdst <trbovidd@mail.CAS.McMaster.CA>
    Re: gilly asks: what is $isdst <hillr@ugsolutions.com>
    Re: HELP! emergency - please help. <lr@hpl.hp.com>
    Re: hour difference between localtime and POSIX::mktime <lr@hpl.hp.com>
        How to use a template with perl --- novice question <agustinchernitsky@altavista.com>
    Re: I can't execute Perlscript on ServerSide <mischief@motion.net>
    Re: I can't execute Perlscript on ServerSide <Peter.Dintelmann@dresdner-bank.com>
    Re: interchanging variables <soybean_tofu@yahoo.com>
        IO::Socket for proxy <dsa@dassda.com>
    Re: IO::Socket for proxy <Peter.Dintelmann@dresdner-bank.com>
    Re: IO::Socket for proxy <bart.lateur@skynet.be>
    Re: Loading a array from a file. r_conner@my-deja.com
    Re: local *FILENAME within procedures....good practice? (Eric Bohlman)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 30 Aug 2000 16:51:46 GMT
From: Ralf Wiegand <rwiegand@tmltechnologies.com>
Subject: Compiling SSLeay on Solaris 8
Message-Id: <39AD3CBD.3C1200DA@tmltechnologies.com>

Hello Group -
I'm trying to compile SSLeay and I'm getting the following error
message:

cp SSLeay.pm blib/lib/Net/SSLeay.pm
AutoSplitting blib/lib/Net/SSLeay.pm (blib/lib/auto/Net/SSLeay)
blib/lib/Net/SSLeay.pm: some names are not unique when truncated to 8
characters
:
 directory blib/lib/auto/Net/SSLeay:
  ssl_read_all.al, ssl_read_until.al, ssl_read_CRLF.al truncate to
ssl_read
  ssl_write_all.al, ssl_write_CRLF.al truncate to ssl_writ
/usr/bin/perl -I/usr/perl5/5.00503/sun4-solaris -I/usr/perl5/5.00503
/usr/perl5/
5.00503/ExtUtils/xsubpp  -typemap /usr/perl5/5.00503/ExtUtils/typemap
-typemap t
ypemap SSLeay.xs >xstmp.c && mv xstmp.c SSLeay.c
cc -c -I/usr/local/ssl/include  -xO3 -xdepend     -DVERSION=\"1.05\"
-DXS_VERSI
ON=\"1.05\" -KPIC -I/usr/perl5/5.00503/sun4-solaris/CORE  SSLeay.c
cc: unrecognized option `-KPIC'
cc: language depend not recognized
cc: SSLeay.c: linker input file unused since linking not done
Running Mkbootstrap for Net::SSLeay ()
chmod 644 SSLeay.bs
LD_RUN_PATH="/usr/local/ssl/lib" cc -o
blib/arch/auto/Net/SSLeay/SSLeay.so -R/us
r/local/ssl/lib -G SSLeay.o    -L/usr/local/ssl -L/usr/local/ssl/lib
-lssl -lcry
pto
cc: SSLeay.o: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target
`blib/arch/auto/Net/SSLeay/SSLeay.s
o'

The system is a SS5/256MB RAM/2.8, OpenSSL installed OK, using GCC.2.8.1
etc...
(OpenSSL.0.9.4, SSLeay.1.0.5)
I would like to run webmin with SSL support, but the only thing what is
not working is the compiling of SSLeay.

Thank YOU
Ralf Wiegand
wiegandr@hourglass.com



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

Date: 30 Aug 2000 17:45:42 +0100
From: nobull@mail.com
Subject: Re: Could we export templates from module?
Message-Id: <u966oiy9xl.fsf@wcl-l.bham.ac.uk>

"Paul Dortman" <paul@pco.iis.nsk.su> writes:

> I ment format for writing to file by write function. I took mistake when
> call it 'template'. :(

Exporter.pm can export typeglobs.

If you export the typeglob *FOO then that exports the scalar $FOO, the
array @FOO, the hash %FOO, the function &FOO, the file handle FOO, the
directory handle FOO and the format FOO.

AFAIK[1] there's no such thing as a hard reference to a format so there's
no way to export a format without exporting the whole typeglob.

I tried *FOO{FORMAT} and found that it didn't work.

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


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

Date: 30 Aug 2000 15:08:49 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Extra ^M in text file
Message-Id: <slrn8qq8s1.euj.vek@pharmnl.ohout.pharmapartners.nl>

On Wed, 30 Aug 2000 12:42:01 GMT,
             nkhan75@hotmail.com <nkhan75@hotmail.com> wrote:



>Hello,
>
>I am working with Perl/NT. Every time I create a text file from my
>program, I find a ^M at the end of each line of the file.
>
>Does anyone know why this is happening?
>


You mean one ^M character in addition to the one that is supposed to
be there?



Villy


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

Date: 30 Aug 2000 16:39:50 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: Extra ^M in text file
Message-Id: <8ojdcm$krk$1@uns-a.ucl.ac.uk>

In article <8oj1nq$q7u$1@qnsgh006.europe.nortel.com>, 
lincolnmarr@nospam.europem01.nt.com says...
>
>
>> I am working with Perl/NT. Every time I create a text file from my
>> program, I find a ^M at the end of each line of the file.
>>
>> Does anyone know why this is happening?
>>
>
>See my other post about this... I still haven't solved it but the ^M is a
>control character (on my UNIX box it's ascii no. \015) which is code for 
a
>carriage return... to get rid of it I wrote a routine to substitute 
globally
>\015 with nothing. There may be another way out of this, I'm not sure yet 
as
>I'm still working on it but if I find out i'll let you know.
>
>Another point worth mentioning is that if you are ftp'ing/transferring 
files
>from a UNIX/Linux system to windows then the ^M won't appear if you 
transfer
>in ascii mode instead of binary... but maybe this is too off-topic and
>better discussed in another forum (maybe comp.unix.questions)

You are probably right that this is not directly perl related but it 
catches lots of people out.

The ^M is as you correctly ascertained the Carriage Return control 
character.  It appears because DOS (and therefore Windows) uses the CR/LF 
pair as line terminators.  Whereas Unix and its derivatives use only a LF 
as a line terminator.  So under a Unix system DOS text files have an extra 
character at the end of each line the CR.

Most ftp clients in ASCII mode silently handle the different sorts of line 
endings.  To be on the safe side always use ASCII mode to copy text files.

If this isn't possible (I get this when transfering Perl scripts by zip 
drive to my home development machine [dubious Perl reference]) you can use 
a utility called dos2unix that will sort the files out for you.



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

Date: Wed, 30 Aug 2000 15:34:11 GMT
From: Dan <dan333@my-deja.com>
Subject: fancy perl regex problem
Message-Id: <8oj9hh$in2$1@nnrp1.deja.com>

I would appreciate your help solving this regex puzzle:
I want to replace A with B except when it falls between X and Y.
Example
	A X A Y A  -->  B X A Y B

A and B happen to represent pairs of HTML tags in my case.
And there are many such pairs I wish to avoid substitution
inside.  So I think it might be easier to substitute a temp
string for the occurrences of A inside the tags, then replace
the occurrences of A everywhere, then undo the temp string
substitution, like this
	A X A Y A --> A X TMP Y A --> B X TMP Y B --> B X A Y B

Even this I am not sure how to do.  The problem is there might
be several occurrences of A inside the X and Y tags, as well as
other stuff, like
	X foo A bar A pdq Y --> X foo TMP bar TMP pdq Y

I can only see how to replace one A between each X and Y at a time.
The best I can think to do is use a loop and substitute until the
substitution fails to replace anything anymore, but this involves
scanning the whole string (which may be many KB long) many times,
so it is not very efficient.  Any help is appreciated.

Thanks,
Dan


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


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

Date: Wed, 30 Aug 2000 12:38:08 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: fancy perl regex problem
Message-Id: <39AD3870.6F3E25EB@attglobal.net>

Dan wrote:
> 
> I would appreciate your help solving this regex puzzle:
> I want to replace A with B except when it falls between X and Y.
> Example
>         A X A Y A  -->  B X A Y B
> 

Check out the lookahead and lookbehind features of Perl's 
regular expression package.  Should do the trick for you with
some trial and error.

http://www.perl.com/pub/doc/manual/html/pod/perlre.html


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

Date: 30 Aug 2000 17:10:04 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: fancy perl regex problem
Message-Id: <8ojf5c$j4j$1@lublin.zrz.tu-berlin.de>

Dan  <dan333@my-deja.com> wrote in comp.lang.perl.misc:
>I would appreciate your help solving this regex puzzle:
>I want to replace A with B except when it falls between X and Y.
>Example
>	A X A Y A  -->  B X A Y B

As posed, the problem is not hard.  Regexes allow you to specify
context for a match (see "lookahead" and "lookbehind" in perlre).
That should do it nicely.

>A and B happen to represent pairs of HTML tags in my case.

 ...and there lies the crux of the matter.  You can't parse HTML
with a handful of regexes.  I won't go into detail here, others
can do that far better and have often done here in the past.
It suffices to say that HTML nests, has comments, and can contain
quoted material.  Everyone who has tried to get only one of these
right with a regex will conclude that doing all three at once
is not going to work out.  You'll need all three (and more) to
determine the state of between-ness of each A.

Use one of the HTML:: modules on cpan.

Anno


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

Date: Wed, 30 Aug 2000 17:47:47 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: File handles with scalar value
Message-Id: <39ad48c3.1b2f$17e@news.op.net>
Keywords: Grenoble, eternity, kinglet, volatile

In article <8oippa$ii7$1@lublin.zrz.tu-berlin.de>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>they accept either a FILEHANDLE or a scalar containing the name of the 
>>FILEHANDLE
>>
>>so it's quite simple for a scalar to be both a string and a filehandle
>
>True, but that's not the case at hand.  In a text context, $file appears
>to contain the name of the opened file, not of the filehandle connected
>with it.  The real background is that $file is an object that overloads
>some operations, as another poster explained.

You are both right.  The basic trick look like this:

        sub trick_filehandle {
          my $file_name = my $filehandle_name = shift;
          open $filehandle_name, "< $file_name" or die ...;
          return $filehandle_name;
        }

        my $fh = trick_filehandle('/tmp/foo');
        print "The value as a scalar: $fh\n";
        print "But I can read data from it also: ", scalar(<$fh>), "\n";

and no overloading is necessary to make it work.

CGI.pm actually does overload the stringizing operation on the
filehandle, but it's only for a cosmetic reason.  The filehandles
CGI.pm uses have package names attached to them, and the stringize
operation removes the package name.

The overloading isn't necessary to make the trick work, however.



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

Date: 30 Aug 2000 17:38:42 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: file locking not working
Message-Id: <8ojgr2$j5s$1@lublin.zrz.tu-berlin.de>

Lincoln Marr <lincolnmarr@nospam.europem01.nt.com> wrote in comp.lang.perl.misc:
>
>>
>> I think you might bump into the same problem that many people bump into
>> when using flock. Locking a file with flock HANDLE, LOCK_EX only prevent
>> _cooperating_ programs from getting read or write access to it. In other
>> words, only programs that use flock will be stopped from opening the
>> file. If you have 50 programs that lock and unlock a file, and one that
>> doesn't, your data is not safe, and not guaranteed to be consistent.
>> This is called an advisory locking scheme.
>
>Does Perl have any command which makes it take notice of the file lock??  I

Why, yes.  It's called flock.

>don't want 2 or more people running my script to be able to write to the
>same file simultaneously, because of the risk of data corruption - meaning
>that junk is outputted to the browser.
>
>The only thing that will be accessing the files is the script - so it's the
>only thing that I want to take notice of the file lock... but I'm not sure
>how. Suggestions anyone?

That's the whole point about the flock mechanism.  flock( LOCK_EX) and
flock( LOCK_SH) will return[1] only when it is safe for a process to
access the file in the indicated manner.  It's all you need to make
your program take notice of locks.  The problem are processes that
don't use flock accessing the same file(s).

Anno

[1] Unless you are in non-blocking mode, that is.  If you are, it
    returns an error.


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

Date: Wed, 30 Aug 2000 11:41:08 -0400
From: soybean <soybean_tofu@yahoo.com>
Subject: Re: file locking not working
Message-Id: <5i9qqsg409s8tg10glorn8muaf0bgv79ot@4ax.com>

>Does Perl have any command which makes it take notice of the file lock??  I
>don't want 2 or more people running my script to be able to write to the
>same file simultaneously, because of the risk of data corruption - meaning
>that junk is outputted to the browser.
>
>The only thing that will be accessing the files is the script - so it's the
>only thing that I want to take notice of the file lock... but I'm not sure
>how. Suggestions anyone?

The only way to do this reliably is to use flock.
Perl binds flock to whatever locking mechanisim that it deams best,
but this may not be the best way to pull off locking on your OS.

Remember the important thing about flock is that flock-ing a file will
not stop other programs from opening, even erasing a flie. It only
stops other programs from flock-ing it.

Programs that flock need to check if the flock works, not the open. 

meta-code-example:

if (open file  and  flock file) {
	go to playland
} else {
	go home without supper
}


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

Date: 30 Aug 2000 17:54:24 +0100
From: nobull@mail.com
Subject: Re: file locking not working
Message-Id: <u94s42y9we.fsf@wcl-l.bham.ac.uk>

"Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com> writes:

> >                 Locking a file with flock HANDLE, LOCK_EX only prevent
> > _cooperating_ programs from getting read or write access to it. In other
> > words, only programs that use flock will be stopped from opening the
> > file.
> 
> Does Perl have any command which makes it take notice of the file
> lock??

This question is answered in the paragraph you quote above.

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


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

Date: Wed, 30 Aug 2000 17:10:07 +0200
From: "Guenther Degenfelder" <guenther.degenfelder@datev.de>
Subject: Re: ftp function call in perl change the file size.
Message-Id: <39ad246a$1@news.datev.de>

"calvin" <calvin@pixelmetrix.com> schrieb im Newsbeitrag
news:39AD074E.F62F6763@pixelmetrix.com...
> Hi all,
>
> When I used the "ftp.pl" in my source code to ftp and get some target
> file, I found the file size I got would be changed. What happened? And
> How to fix the problem?

Don't use the old 'ftp.pl' module!!! It is incomplete (i know that, i tried
complete it...) and it is only 'included for backward compatibility with
Perl 4' (can be read in the first lines of the code).

Your problem should be, that the file is transferred in the wrong mode
(ascii/binary).

Better use 'Net::FTP' !!!
But this runs only with Perl 5.
We decided to uprade from Perl 4 to Perl 5...

Regards

    Guenther




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

Date: 30 Aug 2000 15:53:32 GMT
From: Arcadio Sincero <asince1@irix1.gl.umbc.edu>
Subject: Functions which modify thier parameters?
Message-Id: <8ojals$shn$1@news.umbc.edu>

I'm trying to write functions in Perl which are able to modify its
parameters.  The way I'm doing that now is:

  sub foo($$)
  {
    my $p1 = \$_[0];
    my $p2 = \$_[1];

    $$p1 = 4;
    $$p2 = 11;
  }

What I'd really like to do, though, is something like this:

  sub foo($$)
  {
    my ($p1, $p2) = @_;

    $$p1 = 4;
    $$p2 = 11;
  }

But of course, this doesn't work because $p1 and $p2 in the second example
are no longer references to the elements of @_.  Does anybody know the
correct way to do what I'm trying to do in the second example?  Or is the
way I'm doing it in the first example the only way?

Thanks in advance for any help on this!

---
===============================================================================
Arcadio A. Sincero Jr.
Computer Science Major at the University of Maryland Baltimore County,
Linux systems administrator, wanna-be Windows and Linux software developer,
amateur competitive bodybuilder and all-around nice guy.

WWW: http://www.sincero.com/~asincero (COMING REAL SOON NOW(tm)!)
E-mail: mailto:asincero@sincero.com (THIS IS BROKE TOO! damn ...)

"There are three kinds of people in this world: those who can count, and those
 who can't."



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

Date: Wed, 30 Aug 2000 16:18:49 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Functions which modify thier parameters?
Message-Id: <Jtar5.9012$a5.84295@news1.rdc1.mb.home.com>

In article <8ojals$shn$1@news.umbc.edu>,
 Arcadio Sincero <asince1@irix1.gl.umbc.edu> wrote:
> I'm trying to write functions in Perl which are able to modify its
> parameters.  The way I'm doing that now is:
> 
>   sub foo($$)
>   {
>     my $p1 = \$_[0];
>     my $p2 = \$_[1];
> 
>     $$p1 = 4;
>     $$p2 = 11;
>   }
> 
> What I'd really like to do, though, is something like this:
> 
>   sub foo($$)
>   {
>     my ($p1, $p2) = @_;
> 
>     $$p1 = 4;
>     $$p2 = 11;
>   }

Change your prototype to (\$\$) -- the backwhacks mean that the
argument must begin with that type-character, and that they will
be automatically passed by reference to the subroutine:

    sub foo(\$\$){
        my($p1,$p2) = @_;
        $$p1 += $$p2;
        $$p2 = 42;
    }
    my ($x, $y) = (1,2);
    foo($x,$y);
    print "$x $y\n";      # 3 42

On the other hand, the @_ array holds aliases for the arguments
anyway, so this also works:

    sub foo($$){
        $_[0] += $_[1];
        $_[1] = 42;
    }
    my ($x, $y) = (1,2);
    foo($x,$y);
    print "$x $y\n";      # 3 42

They behave differently under exceptions -- ie; if you called it as

    foo(1,2);

the first example would give you a compile time exception, the second
would give a runtime exception for attempting to modify a read-only
value.

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/
      Doing linear scans over an associative array is like 
      trying to club someone to death with a loaded Uzi.
          -- Larry Wall


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

Date: 30 Aug 2000 17:54:04 +0100
From: nobull@mail.com
Subject: Re: Functions which modify thier parameters?
Message-Id: <u93djmy9jn.fsf@wcl-l.bham.ac.uk>

Arcadio Sincero <asince1@irix1.gl.umbc.edu> writes:

>   sub foo($$)
>   {
>     my $p1 = \$_[0];
>     my $p2 = \$_[1];

> What I'd really like to do, though, is something like this:
> 
>   sub foo($$)
>   {
>     my ($p1, $p2) = @_;

> But of course, this doesn't work because $p1 and $p2 in the second example
> are no longer references to the elements of @_.

Change:

   sub foo($$)

to:

   sub foo(\$\$)

_or_ change:

  my ($p1, $p2) = @_;

to:

  my ($p1, $p2) = \(@_);

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


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

Date: Wed, 30 Aug 2000 17:29:53 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Functions which modify thier parameters?
Message-Id: <39ad4490.1a66$7b@news.op.net>

[mailed and posted]

In article <8ojals$shn$1@news.umbc.edu>,
Arcadio Sincero  <asince1@irix1.gl.umbc.edu> wrote:
>I'm trying to write functions in Perl which are able to modify its
>parameters.  The way I'm doing that now is:
>
>  sub foo($$)
>  {
>    my $p1 = \$_[0];
>    my $p2 = \$_[1];
>
>    $$p1 = 4;
>    $$p2 = 11;
>  }

The easy way is:

        sub foo {       
          $_[0] = 4;
          $_[1] = 11;
        }


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

Date: Wed, 30 Aug 2000 16:10:55 +0100
From: "Zlanty" <someone@microsoft.com>
Subject: GD module
Message-Id: <8oj860$854$1@bignews.shef.ac.uk>

I built the GD module on a unix box to which I had telnet access and then
tried to copy the resultant lib to a unix www box for which I don't have
telnet access..

It didn't work.

How can I install this module without using telnet access???

Thanks

phil@moonhead.org.uk




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

Date: Wed, 30 Aug 2000 11:10:56 -0400
From: Daniel Trbovich <trbovidd@mail.CAS.McMaster.CA>
Subject: gilly asks: what is $isdst
Message-Id: <Pine.GSO.4.21.0008301108410.5825-100000@church.cas.McMaster.CA>

hello everyone,

I've been using the localtime function, and have tried to search the web
for this, but can't find what $isdst means in localtime().  I printed
the value and it returns 1.  can someone explain what this is?
thanks alot

gilly



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

Date: Wed, 30 Aug 2000 08:33:18 -0700
From: Ron Hill <hillr@ugsolutions.com>
Subject: Re: gilly asks: what is $isdst
Message-Id: <39AD293E.F12807D6@ugsolutions.com>

Daniel Trbovich wrote:

> hello everyone,
>
> I've been using the localtime function, and have tried to search the web
> for this, but can't find what $isdst means in localtime().  I printed
> the value and it returns 1.  can someone explain what this is?
> thanks alot
>
> gilly

This is the varable for daylight savings time. A value of 1 means that
daylight savings is in effect. A value of 0 means it is not

Ron



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

Date: Wed, 30 Aug 2000 10:04:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HELP! emergency - please help.
Message-Id: <MPG.1415f73db3f5416198acfd@nntp.hpl.hp.com>

In article <8ohij2$jrj$1@nnrp1.deja.com> on Tue, 29 Aug 2000 23:56:28 
GMT, skwilson@my-deja.com <skwilson@my-deja.com> says...
> In article <8ohi87$jfu$1@nnrp1.deja.com>,
>   Mark <mtaylorlrim@my-deja.com> wrote:
> >
> > > > +< and > are doing.
> > >
> > > > {
> > > > open(FILE, "+<$filename") || &error_exit;
> > > > }
> > > then open it for input...
> > Actually, the + makes it opened for both read and write.

 ...

> So, if the error is getting called and the file is in fact where it's
> supposed to be, what could be the problem?

Print the value of $! in your error handler.

perldoc perlvar

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 30 Aug 2000 10:23:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: hour difference between localtime and POSIX::mktime
Message-Id: <MPG.1416e2fd30ba59b298acff@nntp.hpl.hp.com>

In article <slrn8qpgop.d2n.vek@pharmnl.ohout.pharmapartners.nl> on 30 
Aug 2000 08:17:46 GMT, Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> 
says...

 ...

> That raises the question, what is the codifed POSIX behaviour of tm_isdst
> when used as input to mktime?  I tested on two systems; one ignores
> tm_isdst and the other don't when calling mktime.  

Then one of the implementations doesn't conform to the POSIX (C) 
Standard.

> The default of 0 for the isdst argument seems not to be the most useful
> choice; the value -1, I would think, would a better default.  Thus, if
> you don't make an explicit decission you will get the time zone flag
> which will normally be in effect for the time you try to convert.

Presumably the POSIX Standard for library functions is that of the C 
Standard, which says this in a footnote:

  Thus, a positive or zero value for tm_isdst causes the mktime function
  to presume initially that Daylight Saving Time, respectively, is or is
  not in effect for the specified time.  A negative value for tm_isdst
  causes the mktime function to attemp to determine whether Daylight
  Saving Time is in effect for the specified time.

> This relates to the recent discussion of standardizing Perl, where some
> people find inconsistencies between releases of perl.

A Perl standard would refer explicitly to other underlying standards 
where appropriate, unless the specifications differ.  The evolution of 
the documentation for the sprintf() function is a case in point -- 
originally referring to sprintf(3C), now independent.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 30 Aug 2000 12:19:26 -0300
From: "Agustin Chernitsky" <agustinchernitsky@altavista.com>
Subject: How to use a template with perl --- novice question
Message-Id: <8oj8od$b6ts4$1@ID-48235.news.cis.dfn.de>

Hi,

    I created a scripts (an orders script) that uses an HTML file as a main
template. This HTML has a text (ie TEXTHERE) that indicates the program to
insert other HTML code in that line. This program is made up of 3 parts:
main, an order summary and a contract info.

These 3 parts use the same template. Now as I'm not an expert but I have
read Larry Wall's Learning Perl and Programming Perl, I was able to make
this program work. What I need now is to optimize the code and for that I
need some experience. So, maybe someone here could help me.

The code opens the template on all the 3 parts (I have 3 open commands in
the program for the same file). I was thinking on placing all that on a sub
routine. What I don't is how to make the  program open the template and when
it detects the TEXTHERE, make it insert the new HTML code and after that,
finish the template (imagine that the TEXTHERE is in the middle of the
HTML).

Does anyone know how to handle this?

Thanks!!!

--
Agustín Chernitsky
InterEmpresa

E-mail:       agustinchernitsky@altavista.com
ICQ:          20020826




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

Date: Wed, 30 Aug 2000 10:00:59 -0500
From: "Chris Stith" <mischief@motion.net>
Subject: Re: I can't execute Perlscript on ServerSide
Message-Id: <sqq8bjpnc5d156@corp.supernews.com>


"Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com> wrote in message
news:8oiihb$d5b1@intranews.bank.dresdner.net...
>     to clarify things:
>
> >Gabo schrieb in Nachricht <8oigbp$a29$1@zamboni.dsnet.it>...
> >>HI,
> >>    I install Apache 1.3 and ActivePerl 5.6 with PerlScript support.
>
>     I should read more carefully. It's ASP...

Not everything on NT is ASP. You can write CGI
applications, since CGI is a standard and Apache on
any platform (or even IIS for that matter) will provide
the program with the enviroment variables and with
a standard input. The main portability problems for CGI
on NT are not that it doesn't work, but that paths are
weird DOS-type paths and that the other software on the
box is foreign to most programmers of Unix-variant
systems (such as no sendmail, and different ideas about
most other things too).

> >>My cgis writing in Perl run correctly, but I can't execute a Hello World
>
>     it is _not_ cgi.

sub parse_form_data() {
    ### left as an exercise
}

&parse_form_data (*form);

print "Content-type: text/html\n\n";
print "<html><body>Hello, $foo{firstname}";
print "</body></html>";
exit;

How is that not a CGI? The OP knows that his Perl
CGI programs are CGI programs, and that they are
working. All he needed to know was how to do the
PerlScript.

>     "hello world" is...
>
>         <%@ LANGUAGE = PerlScript %>
>
>         <HTML><HEAD><TITLE>First ASP in PerlScript</TITLE></HEAD>
>
>         <BODY bgcolor="#CCFFFF" text="#330099"><H1>
>
>         <SCRIPT LANGUAGE="PerlScript" RUNAT=Server>
>        $Response->write("Hello world!");
>      </SCRIPT>
>
>     </H1></BODY></HTML>
>
>         Peter
>
>
>




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

Date: Wed, 30 Aug 2000 17:56:17 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: I can't execute Perlscript on ServerSide
Message-Id: <8ojark$d552@intranews.bank.dresdner.net>

    Hi,

Chris Stith schrieb in Nachricht ...
>
>"Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com> wrote in
message
>news:8oiihb$d5b1@intranews.bank.dresdner.net...
>>     to clarify things:
>>
>>     I should read more carefully. It's ASP...
>
>Not everything on NT is ASP.

    I never made such a statement.

>You can write CGI
>applications, since CGI is a standard

    I know.

    The details published by me are from an email
    exchange with the original poster.

    Best regards,

        Peter Dintelmann





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

Date: Wed, 30 Aug 2000 12:10:13 -0400
From: soybean <soybean_tofu@yahoo.com>
Subject: Re: interchanging variables
Message-Id: <sacqqs49bplf5jhrf2r2sfkn41udve8om5@4ax.com>

On Wed, 30 Aug 2000 13:40:27 GMT, Ankur Banerjee
<ankban4@indiainfo.com> wrote:

>Any other ways to do it ??

Hi

This works for me :)

@vars=('a'..'c');  # or any set or variable names

for (@vars) { # or any other way that you set your variables
    $$_ = $x++;
}

for (@vars) {  # look at  the data before messing around
    print $$_,"\n";
}

print "<processing/>\n";

# here is the switch-a-roo

for (@vars) { push @values, $$_ }
@tmp_vars=@vars;
${pop @tmp_vars}=shift @values;
while (@tmp_vars) {
    ${pop @tmp_vars}=pop @values;
}

for (@vars) { # look at the data after messing around
    print $$_,"\n";
}


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

Date: Wed, 30 Aug 2000 23:46:50 +0800
From: DT <dsa@dassda.com>
Subject: IO::Socket for proxy
Message-Id: <MPG.1417ad44b10cea2d989681@news.cyberway.com.sg>

How can I use IO::Socket to access a http via proxy? Any form of help is 
apprceitated.


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

Date: Wed, 30 Aug 2000 17:50:13 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: IO::Socket for proxy
Message-Id: <8ojag8$d541@intranews.bank.dresdner.net>

    Hi,

DT schrieb in Nachricht ...
>How can I use IO::Socket to access a http via proxy? Any form of help is
>apprceitated.

    create an INET tcp socket connected to your
    proxy server (with its http proxy port) and send
    the desired http request
    (e.g. 'GET http://www.perl.com/')

    Best regards,

        Peter Dintelmann





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

Date: Wed, 30 Aug 2000 17:02:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: IO::Socket for proxy
Message-Id: <jafqqsg4kfc44si61e8a2h7hsdr12tqed3@4ax.com>

DT wrote:

>How can I use IO::Socket to access a http via proxy? 

Why?

LWP (even LWP::Simple) works nicely, but you need to set an environment
variable (I think it's HTTP_PROXY) to the URL of the proxy server. See
the docs for LWP::UserAgent, I think.

-- 
	Bart.


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

Date: Wed, 30 Aug 2000 15:18:40 GMT
From: r_conner@my-deja.com
Subject: Re: Loading a array from a file.
Message-Id: <8oj8jn$ha5$1@nnrp1.deja.com>

In article <n3coqs480cesgjn4e1dj24paaquav7lnfq@4ax.com>,
  Abe Timmerman <abe@ztreet.demon.nl> wrote:
> On Mon, 28 Aug 2000 23:42:56 GMT, r_conner@my-deja.com wrote:
>
> #!/usr/bin/perl -w
> use strict;
>
> my @data;
> while ( <DATA> ) {
> 	chomp;
> 	my @cols = split /,/;
> 	push @{ $data[$_] }, $cols[$_] for 0..$#cols;
> };
>
> print join(',', @$_), "\n" for @data;
>
> __DATA__
> 1,2,3,3
> 4,5,6,1
>
> --
> Good luck,
> Abe
>

Thanks Abe, That one worked as well, BTW I used commas for the example
because it was clearer in the post, tabs looked like shit.


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


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

Date: 30 Aug 2000 16:57:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: local *FILENAME within procedures....good practice?
Message-Id: <8ojed2$cp2$1@nntp9.atl.mindspring.net>

Brendon Caligari (bcaligari@my-deja.com) wrote:
: Is it a good practice to 'localise' a filename prior to use
: within 'sub' procedures?
: 
: To avoid name conflicts I am adopting the following policy,
: in case the 'calling function' has opened a file with the
: same name.
: 
: eg:
: 
: sub logEvent {
:   my $fname = shift();
:   local *LOGFILE;
:   unless ((-e $fname) && (open(LOGFILE, ">>$fname"))  {
:   .
:   .
: 
: 
: am I getting it all wrong or am i on the right track??

In general, your policy is a good one, assuming that what you need to
optimize for is maintainability (which is usually the case).  The less the
caller of a function needs to know about the internal implementation of
the function, the better, and choice of filehandle names is definitely an
internal implementation detail. 

: I am enjoying the 'easy goingness' of perl, but at times I'm being
: driven up the 'Wall' (pun not intended).

Perl does have a number of features (such as the ability to use variables 
without declaring them) that make writing small programs easier, but make 
writing large programs harder.  Fortunately, Perl also has features like 
the strict pragma that make it possible to override those problematic 
features.



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

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


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