[22233] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4454 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 23 11:12:11 2003

Date: Thu, 23 Jan 2003 08:10:11 -0800 (PST)
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, 23 Jan 2003     Volume: 10 Number: 4454

Today's topics:
        Perl package giving errors <ryan@dctnet.net>
    Re: Perl package giving errors <ryan@rhis.net>
    Re: Perl package giving errors <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Perl package giving errors <ryan@rhis.net>
    Re: Perl package giving errors <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Perl package giving errors <nobull@mail.com>
    Re: Please Help Me <nobull@mail.com>
    Re: Please Help Me <kttran@nortelnetworks.com>
    Re: Regex: optional word boundary (Sara)
    Re: Regex: optional word boundary (Anno Siegel)
    Re: Regex: optional word boundary (Sara)
    Re: Regex: optional word boundary <tassilo.parseval@post.rwth-aachen.de>
        Syntax oddity <ler@cfmu.eurocontrol.int>
    Re: Syntax oddity <bart.lateur@pandora.be>
    Re: To extract a specific portion of a text file (John Smith)
        unlink() <joeljkp@tabdemo.larc.nasa.gov>
    Re: unlink() <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: unlink() <GPatnude@adelphia.net>
    Re: unlink() <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Jan 2003 07:45:43 -0500
From: Ryan <ryan@dctnet.net>
Subject: Perl package giving errors
Message-Id: <b0oo4t$ro7bg$1@ID-129898.news.dfncis.de>

Hello,
        I have created a perl package that seems compile and run fine 
on my Redhat box using perl version 5.6.1 but when put on our webserver
using perl version 5.005_03 I get the following error when I type perl
Ispman.pm :
Array found where operator expected at Ispman.pm line 4, at end of line
        (Do you need to predeclare our?)
syntax error at Ispman.pm line 4, near "our @EXPORT"
BEGIN not safe after errors--compilation aborted at Ispman.pm line 82.
Here is the start of the package:

require Exporter;
@ISA    = qw(Exporter);
our @EXPORT= qw(error_msg
                get_db_config
                set_suspended
                get_today_date
                check_dup
                get_mf_dates
                check_date_format
                start_table
                fill_table
                get_pay_config
                checkadd_zip
                fill_ticket_table
                get_report_config);
our $VERSION=0.01;
Can anyone give me a hint what I'm doing wrong here?  I searched google for
about 2 hours and have been unable to find an answer.  Thank you

Ryan



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

Date: Thu, 23 Jan 2003 07:47:33 -0500
From: Ryan <ryan@rhis.net>
Subject: Re: Perl package giving errors
Message-Id: <b0oo8a$ro7bg$2@ID-129898.news.dfncis.de>

Sorry just a bit of a correction here:
package Ispman; <------ Didn't get in the cut and paste but is there.
> require Exporter;
> @ISA    = qw(Exporter);
> our @EXPORT= qw(error_msg
>                 get_db_config
>                 set_suspended
>                 get_today_date
>                 check_dup
>                 get_mf_dates
>                 check_date_format
>                 start_table
>                 fill_table
>                 get_pay_config
>                 checkadd_zip
>                 fill_ticket_table
>                 get_report_config);
> our $VERSION=0.01;




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

Date: Thu, 23 Jan 2003 13:53:09 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Perl package giving errors
Message-Id: <jcpv2v42g9cu5qte9pluhbm1shsm7jv5ia@4ax.com>

On Thu, 23 Jan 2003 07:45:43 -0500, Ryan <ryan@dctnet.net> wrote:

>Hello,
>        I have created a perl package that seems compile and run fine 
>on my Redhat box using perl version 5.6.1 but when put on our webserver
>using perl version 5.005_03 I get the following error when I type perl
>Ispman.pm :
>Array found where operator expected at Ispman.pm line 4, at end of line
>        (Do you need to predeclare our?)
>syntax error at Ispman.pm line 4, near "our @EXPORT"

[...]


I don't think our() was around back in the 5.005_03 days. I may be
wrong, though.



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 23 Jan 2003 08:10:59 -0500
From: Ryan <ryan@rhis.net>
Subject: Re: Perl package giving errors
Message-Id: <b0opk8$qtplo$1@ID-129898.news.dfncis.de>

Bernard El-Hagin wrote:

> On Thu, 23 Jan 2003 07:45:43 -0500, Ryan <ryan@dctnet.net> wrote:
> 
>>Hello,
>>        I have created a perl package that seems compile and run fine
>>on my Redhat box using perl version 5.6.1 but when put on our webserver
>>using perl version 5.005_03 I get the following error when I type perl
>>Ispman.pm :
>>Array found where operator expected at Ispman.pm line 4, at end of line
>>        (Do you need to predeclare our?)
>>syntax error at Ispman.pm line 4, near "our @EXPORT"
> 
> [...]
> 
> 
> I don't think our() was around back in the 5.005_03 days. I may be
> wrong, though.
> 
> 
> 
> Cheers,
> Bernard
> --
> echo 42|perl -pe '$#="Just another Perl hacker,"'

I think that did the trick.  I guess from the error msg I could have
concluded that but I must need more coffee or something.... Thank you much.


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

Date: Thu, 23 Jan 2003 14:10:09 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Perl package giving errors
Message-Id: <7aqv2vgv8p3gmil2v8fevl5g17cj3tho6p@4ax.com>

On Thu, 23 Jan 2003 08:10:59 -0500, Ryan <ryan@rhis.net> wrote:


[...]


>I think that did the trick.  I guess from the error msg I could have
>concluded that but I must need more coffee or something.... Thank you much.


Tad, can we add "drink coffee before posting" to the "Must" section of
the Posting Guidelines?


;-)



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: 23 Jan 2003 13:13:04 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl package giving errors
Message-Id: <u9d6mo3t7j.fsf@wcl-l.bham.ac.uk>

Ryan <ryan@dctnet.net> writes:

> on my Redhat box using perl version 5.6.1 but when put on our webserver
> using perl version 5.005_03 I get the following error when I type perl
> Ispman.pm :
> Array found where operator expected at Ispman.pm line 4, at end of line
>         (Do you need to predeclare our?)

> Can anyone give me a hint what I'm doing wrong here?  I searched google for
> about 2 hours and have been unable to find an answer.

This is almost self-answering.

"our" was introduced in version 5.6

For a 5.5 compatible alternative to our:

  perldoc vars


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


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

Date: 23 Jan 2003 12:23:23 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Please Help Me
Message-Id: <u9lm1c3vic.fsf@wcl-l.bham.ac.uk>

"Khanh Tran" <kttran@nortelnetworks.com> writes:

> Subject: Please Help Me

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

If your subject truely refects your level of understanding of your
problem then you have not thought about your problem anywhere near
enough thought to dream of asking anyone else for help.

> I wrote a perl script 

Did you really?  This looks like it's evolved from an old Perl4
script.

Perl has moved on a long way since then.

If you are new to Perl you may want to avoid trying to learn Perl from
ancient resources.

> However, I need this script to work on pc and I never write any perl
> script cgi in pc platform.

Sould not make any difference unless you are playing with OS-specific
stuff.

> I downloaded and installed activeperl 5.8 on my pc.  Unfortunately!
> I don't know how to rewrite the script so it can work on my pc
> whitout any network connection.

Sould not be necessary.

> I guess I don't know the setup requirement in order to run the code (Ashame
> on me :-) ). 

To use CGI scripts you need a web server.

> I just want it runs locally.

In that case, you need a web server installed locally.

This, of course, has nothing to do with Perl.

> ------------------ Perl Script called FindTable---------------------
> #!/usr/bin/perl

You forgot to ask for help.

  use strict;
  use warnings;

> &ReadParse();

Don't use this ancient rubbish.  Use one of the modern CGI modules.

> my ($commands_in) = ($ENV{PATH_INFO}) ? $ENV{PATH_INFO} =~ s/^\/// :
> $ENV{QUERY_STRING}; my $IMG_DIR = "/mobility/personal/khanh";
>
> my @Result = ();

This is better written as just:

  my @Result;

However, the use of file-scoped variables to communicate between
subroutines is sometimes a valid technique but is not a technique of
first choice.  This has nothing to do with Perl it's true in all
programming languages.

> &Header();

Why is that '&' in there?  If the answer is "I don't know" then remove
it and someday when you have time on your hands look up what it does.

> &DisplayResult() if ($#Result >= 0);

This is more simply and ideomatically written as:

 DisplayResult() if @Result;

> $commands_in = "";

[ At end of program ].

This is redunant.

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


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

Date: Thu, 23 Jan 2003 09:46:54 -0600
From: "Khanh Tran" <kttran@nortelnetworks.com>
Subject: Re: Please Help Me
Message-Id: <b0p2ok$hak$3@zcars0v6.ca.nortel.com>

Hi Brian,

Thank you very much for your quick response. Yes, I wrote the script except
the ReadParse function. I used that ReadParse function because I want
everything in one script (html and cgi). I guess this wasn't a good idea
then. I haven't found the solution yet. I think I am confusing of my thought
about pc platform. I thought there might be a way to do this without any
local server installation. Anyway, as far as the syntax and style, I don't
know what is the efficient one to write. I don't write perl script oftenly.
I learned perl script couple years ago but haven't actually coding much. I
read some of the examples in the activeperl 5.8 doc and quite a little
confusing of the codes. I need to update it and do some more reading. Well,
thank you very much for your quick response. I very appreciate that.

Thanks,

Khanh Tran

"Brian McCauley" <nobull@mail.com> wrote in message
news:u9lm1c3vic.fsf@wcl-l.bham.ac.uk...
> "Khanh Tran" <kttran@nortelnetworks.com> writes:
>
> > Subject: Please Help Me
>
> Please put the subject of your post in the Subject of your post.  If
> in doubt try this simple test.  Imagine you could have been bothered
> to have done a search before you posted.  Next imagine you found a
> thread with your subject line.  Would you have been able to recognise
> it as the same subject?
>
> If your subject truely refects your level of understanding of your
> problem then you have not thought about your problem anywhere near
> enough thought to dream of asking anyone else for help.
>
> > I wrote a perl script
>
> Did you really?  This looks like it's evolved from an old Perl4
> script.
>
> Perl has moved on a long way since then.
>
> If you are new to Perl you may want to avoid trying to learn Perl from
> ancient resources.
>
> > However, I need this script to work on pc and I never write any perl
> > script cgi in pc platform.
>
> Sould not make any difference unless you are playing with OS-specific
> stuff.
>
> > I downloaded and installed activeperl 5.8 on my pc.  Unfortunately!
> > I don't know how to rewrite the script so it can work on my pc
> > whitout any network connection.
>
> Sould not be necessary.
>
> > I guess I don't know the setup requirement in order to run the code
(Ashame
> > on me :-) ).
>
> To use CGI scripts you need a web server.
>
> > I just want it runs locally.
>
> In that case, you need a web server installed locally.
>
> This, of course, has nothing to do with Perl.
>
> > ------------------ Perl Script called FindTable---------------------
> > #!/usr/bin/perl
>
> You forgot to ask for help.
>
>   use strict;
>   use warnings;
>
> > &ReadParse();
>
> Don't use this ancient rubbish.  Use one of the modern CGI modules.
>
> > my ($commands_in) = ($ENV{PATH_INFO}) ? $ENV{PATH_INFO} =~ s/^\/// :
> > $ENV{QUERY_STRING}; my $IMG_DIR = "/mobility/personal/khanh";
> >
> > my @Result = ();
>
> This is better written as just:
>
>   my @Result;
>
> However, the use of file-scoped variables to communicate between
> subroutines is sometimes a valid technique but is not a technique of
> first choice.  This has nothing to do with Perl it's true in all
> programming languages.
>
> > &Header();
>
> Why is that '&' in there?  If the answer is "I don't know" then remove
> it and someday when you have time on your hands look up what it does.
>
> > &DisplayResult() if ($#Result >= 0);
>
> This is more simply and ideomatically written as:
>
>  DisplayResult() if @Result;
>
> > $commands_in = "";
>
> [ At end of program ].
>
> This is redunant.
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\




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

Date: 23 Jan 2003 05:12:14 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Regex: optional word boundary
Message-Id: <776e0325.0301230512.4f5e58df@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2u59r.8ha.tadmc@magna.augustmail.com>...
> Sara <genericax@hotmail.com> wrote:
> > "Amittai Aviram" <amittai@amittai.com> wrote in message news:<b0ksdj$r073c$1@ID-124651.news.dfncis.de>...
> 
> 
> >> This will not work:
> >> 
> >> \bfan(mail | base)?
> 
> 
> > You pretty much got it, but it looks like you added a ' ' in the
> > alternative clause. You can't "pretty it up" with spaces dude- they
> > are strictly interpreted inside the /'s.
> 
> 
> We can't really tell, because Amittai did not show us the operator,
> only the regex.
> 
>    /\bfan(mail | base)?/x
> 
> can indeed be prettied up with spaces.  :-)

Hi Tad:

Curious- I don't recall this syntax. I interpret that as matching:

    'fanmail ' or 'fan base' or 'fan'

In other words, 'fan' followed by 'mail ' or ' base' or nothing...

yet you're right, the ? causes the alternative clause to ignore
spaces- I tested it. That's a bit odd! I'm not a big "fan" of the ?,
but why would it cause the alternative to ignore whitespace?



-Gx


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

Date: 23 Jan 2003 13:34:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex: optional word boundary
Message-Id: <b0or0n$lca$2@mamenchi.zrz.TU-Berlin.DE>

Sara <genericax@hotmail.com> wrote in comp.lang.perl.misc:
> tadmc@augustmail.com (Tad McClellan) wrote in message

[...]

> > We can't really tell, because Amittai did not show us the operator,
> > only the regex.
> > 
> >    /\bfan(mail | base)?/x
> > 
> > can indeed be prettied up with spaces.  :-)
> 
> Hi Tad:
> 
> Curious- I don't recall this syntax. I interpret that as matching:
> 
>     'fanmail ' or 'fan base' or 'fan'
> 
> In other words, 'fan' followed by 'mail ' or ' base' or nothing...
> 
> yet you're right, the ? causes the alternative clause to ignore
> spaces- I tested it.

What exactly did you test?

>                      That's a bit odd! I'm not a big "fan" of the ?,

Being no fan of "?" makes about a much sense as being opposed to
multiplication.  If you want to make part of a pattern optional
it's the way to go.

> but why would it cause the alternative to ignore whitespace?

The "?" has nothing to do with it.  The /x modifier changes the
meaning of white space in a regex.  See perlre.

Anno


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

Date: 23 Jan 2003 06:07:50 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Regex: optional word boundary
Message-Id: <776e0325.0301230607.18bbf400@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2u59r.8ha.tadmc@magna.augustmail.com>...
> Sara <genericax@hotmail.com> wrote:
> > "Amittai Aviram" <amittai@amittai.com> wrote in message news:<b0ksdj$r073c$1@ID-124651.news.dfncis.de>...
> 
> 
> >> This will not work:
> >> 
> >> \bfan(mail | base)?
> 
> 
> > You pretty much got it, but it looks like you added a ' ' in the
> > alternative clause. You can't "pretty it up" with spaces dude- they
> > are strictly interpreted inside the /'s.
> 
> 
> We can't really tell, because Amittai did not show us the operator,
> only the regex.
> 
>    /\bfan(mail | base)?/x
> 
> can indeed be prettied up with spaces.  :-)

Actually I retract my previous response, Tad. I can't get this
solution to work. As I suspected it matches only 'fanmail ' and 'fan',
not 'fanbase'. Yes it can be prettied up this way, only problem is it
no longer works!


s/\b(fan(mail | base)?)\b/[$1]/g;

 ./x.pl
this is a paragraph with a bunch of fan words like fan fanbase
fanblade fanmail fantastic and that sort..

this is a paragraph with a bunch of [fan] words like [fan] fanbase
fanblade [fanmail ]fantastic and that sort..


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

Date: 23 Jan 2003 14:35:48 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Regex: optional word boundary
Message-Id: <b0ouk4$2ua$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Sara:

> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2u59r.8ha.tadmc@magna.augustmail.com>...

>> We can't really tell, because Amittai did not show us the operator,
>> only the regex.
>> 
>>    /\bfan(mail | base)?/x
                           ^
                           ^
>> 
>> can indeed be prettied up with spaces.  :-)
> 
> Actually I retract my previous response, Tad. I can't get this
> solution to work. As I suspected it matches only 'fanmail ' and 'fan',
> not 'fanbase'. Yes it can be prettied up this way, only problem is it
> no longer works!
> 
> 
> s/\b(fan(mail | base)?)\b/[$1]/g;
                                 ^^
                                 ^^

Spot the difference? You left off the x-modifier which causes
whitespaces to be ignored. In your pattern whitespaces do matter.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Thu, 23 Jan 2003 11:43:07 GMT
From: Jean-Louis Leroy <ler@cfmu.eurocontrol.int>
Subject: Syntax oddity
Message-Id: <sdadhs5c60.fsf@grebe.sup.cfmu.eurocontrol.be>

According to the perlop manpage:

      Binary "=~" binds a scalar expression to a pattern match.  Certain
      operations search or modify the string $_ by default.  This operator
      makes that kind of operation work on some other string.  The right
      argument is a search pattern, substitution, or transliteration.


However, I just found out that perl 5.6.1 doesn't object to:

        'a' =~ 'b'

Digging it:

        print 'a' =~ '\w', "\n"; # returns: (1)
        print 'a' =~ '\d', "\n"; # ()
        my $pat = '\w';
        print 'a' =~ '$pat', "\n"; # ()

 ...it looks like m'' matches are performed, in spite of:

      If "/" is the delimiter then the initial "m" is optional.
-- 
Jean-Louis


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

Date: Thu, 23 Jan 2003 11:47:03 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Syntax oddity
Message-Id: <kalv2vgkvknghn7okc0kt3pb895iip142m@4ax.com>

Jean-Louis Leroy wrote:

>However, I just found out that perl 5.6.1 doesn't object to:
>
>        'a' =~ 'b'

>...it looks like m'' matches are performed, in spite of:
>
>      If "/" is the delimiter then the initial "m" is optional.

No, wrong conclusion. What you have on the right side is a *string*.
Observe:

	$re = '(\\w)';
	'a' =~ $re and print $1;
-->
	a

So Perl treats any string expression on the right side of "=~" as a
regex. It's the same as if you were to do

	'a' =~ /$re/


See also in perlop, a bit lower than the part you quoted:

	If the right argument is an expression rather than a search
	pattern, substitution, or transliteration, it is interpreted as
	a search pattern at run time. This can be less efficient than an
	explicit search, because the pattern must be compiled every time
	the expression is evaluated.

-- 
	Bart.


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

Date: 23 Jan 2003 06:56:04 -0800
From: clearguy02@yahoo.com (John Smith)
Subject: Re: To extract a specific portion of a text file
Message-Id: <500f84f3.0301230656.62b61601@posting.google.com>

Thanks Tad!

I tried your solution, but it was not exactly giving me the results  I
wanted.


> > I giving my file one more time (extract.txt)
> > ----------------------------------------------------------
> > Component    : Main TestPiece
> >     Language        : C++
> >    Creation Date   : 20-03-2002
> >       Test Key :                       test_hello_there
> >                                        test_log_long_one
> >                                        test_short_my_song
> >       Code key :		       test_bob_smith             
> >                                        test_dave_smith
> >                                        test_harry_smith
> 
> 
> > Now when I run your (David's) code, I am getting the below output:
> > ---------------------
> > Test Key :                             test_hello_there
> >                                        test_log_long_one
> >                                        test_short_my_song
> >                                        test_dave_smith
> >                                        test_harry_smith
> > -------------------------------------------------------

In the above file, the following line after the last value of the
first "Test Key" field can be any line (a blank line, a valid text
line or a comment line). In this case, it happens to start with "Code
key" field and its values.

Again the output has to be exactly the first "Test Key" field and its
values only and it should ignore any other subsequent lines that have
"test_" in it.

EX:
-------------------------------------------
Test Key :                             test_hello_there
                                       test_log_long_one
                                       test_short_my_song
--------------------------------------------



> 
> Add this statement somewhere in David's code 
> (correct location left as an exercise for the reader):
> 
>        last if /^\s*Code key/;

As I said above, this line will not work - the next line after the
last value of the first key doesn't have to be starting with "Code
key".

Do you know how I can just get the first "Test Key" field and only its
values?

Thanks,
John.


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

Date: Thu, 23 Jan 2003 09:30:22 -0500
From: Joel Konkle-Parker <joeljkp@tabdemo.larc.nasa.gov>
Subject: unlink()
Message-Id: <3E2FFC7E.1060906@tabdemo.larc.nasa.gov>

I have the following lines at the end of my script:

unlink ("./temp_trail.txt") || die $!;
unlink ("./prt0001__out.log.1") || die $!;

But when my script ends each time, the files are still there. The 'die' 
doesn't produce any output. This is Perl 5.004. What's wrong here?

- Joel



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

Date: Thu, 23 Jan 2003 15:33:40 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: unlink()
Message-Id: <q4vv2vor1l4j1l6bjrmnnov9p72kd6cphg@4ax.com>

On Thu, 23 Jan 2003 09:30:22 -0500, Joel Konkle-Parker
<joeljkp@tabdemo.larc.nasa.gov> wrote:

>I have the following lines at the end of my script:
>
>unlink ("./temp_trail.txt") || die $!;
>unlink ("./prt0001__out.log.1") || die $!;
>
>But when my script ends each time, the files are still there. The 'die' 
>doesn't produce any output. This is Perl 5.004. What's wrong here?


Doesn't look like there's anything wrong. Works for me, in any case.
I think the problem lies somewhere else.


BTW, you can combine those two commands into one:


   unlink ('./temp_trail.txt', 'prt0001__out.log.1') || die $!;



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 23 Jan 2003 14:55:36 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: unlink()
Message-Id: <InTX9.602$ni5.353194@news1.news.adelphia.net>

"Joel Konkle-Parker" <joeljkp@tabdemo.larc.nasa.gov> wrote in message
news:3E2FFC7E.1060906@tabdemo.larc.nasa.gov...
> I have the following lines at the end of my script:
>
> unlink ("./temp_trail.txt") || die $!;
> unlink ("./prt0001__out.log.1") || die $!;
>
> But when my script ends each time, the files are still there. The 'die'
> doesn't produce any output. This is Perl 5.004. What's wrong here?
>
> - Joel
>

Personally: I think it may be the single dot-slash.... current directory is
simply: "temp_trail.txt" --

On Unix systems -- Peril's unlink will NOT remove files if there is a
symbolic link to it...
Are you positive that the file handles are closed at this point in your
scripts ? (Perl normally closes any open file handles when the script
terminates or exits normally...)
I also suggest that you check the return value of "unlink".... like this....

$STATUS = unlink ('./temp_trail.txt', 'prt0001__out.log.1') || die $!;
print "RESULT: $STATUS\n\n

FWIW...


GP





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

Date: Thu, 23 Jan 2003 15:46:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: unlink()
Message-Id: <D7UX9.771$3J.304@nwrddc01.gnilink.net>

codeWarrior wrote:
> On Unix systems -- Peril's unlink will NOT remove files if there is a
> symbolic link to it...

I can't check this right now because I don't have a Unix machine up and
running, but I highly doubt that. Symbolic links are _not_ included in the
link count of a file, at least on those file systems I know.

Having said that "unlink" will never remove a file. It will only remove the
directory entry for a file.
And only if this happens to be the last link to a file then the OS will
remove the file, too.

jue




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

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


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