[23639] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5846 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 22 18:05:41 2003

Date: Sat, 22 Nov 2003 15:05:08 -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           Sat, 22 Nov 2003     Volume: 10 Number: 5846

Today's topics:
    Re: Avoiding running a process twice (Anno Siegel)
    Re: bit sequence match <eddhig22@yahoo.com>
        code structure <eddhig22@yahoo.com>
    Re: code structure <pinyaj@rpi.edu>
    Re: code structure <eddhig22@yahoo.com>
    Re: dumb newbie question (or newbie dumb question) <jerry_c48@cordollisonline.com>
    Re: dumb newbie question (or newbie dumb question) <noreply@gunnar.cc>
    Re: dumb newbie question (or newbie dumb question) <raisin@delete-this-trash.mts.net>
    Re: dumb newbie question (or newbie dumb question) <uri@stemsystems.com>
        newbie regular expression questions <bxtrap01@comcast.net>
        Printing to one x-y co-ord Default@IO_Error_1011101.xyz
    Re: Printing to one x-y co-ord <noreply@gunnar.cc>
    Re: Printing to one x-y co-ord Default@IO_Error_1011101.xyz
    Re: Printing to one x-y co-ord <jurgenex@hotmail.com>
    Re: Printing to one x-y co-ord (William Herrera)
    Re: Printing to one x-y co-ord Default@IO_Error_1011101.xyz
    Re: Printing to one x-y co-ord Default@IO_Error_1011101.xyz
        reading and writing to text file via form newbie <me@privacy.net>
    Re: reading and writing to text file via form newbie <noreply@gunnar.cc>
        Top level blocks and indentation (Anno Siegel)
    Re: Top level blocks and indentation <jwillmore@remove.adelphia.net>
    Re: Top level blocks and indentation <tassilo.parseval@rwth-aachen.de>
    Re: what does "/usr/bin/perl: relocation error:" mean? (Sara)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Nov 2003 18:53:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Avoiding running a process twice
Message-Id: <bpobaq$qqa$1@mamenchi.zrz.TU-Berlin.DE>

Ed W <dodgynewsgroups@ewildgoose.demon.co.uk> wrote in comp.lang.perl.misc:
> This is almost certainly an FAQ quality question and I appologise in
> advance, but could anyone point me to some references on how to avoid
> allowing the user to run multiple instances of my app.  I'm looking for
> something cross platform, Win32 and linux.
> 
> The idea is that the app is a socket app and users will confuse themselves
> if they can fire up multiple instances simultaneously.  I would like to
> detect that there already a running instance and if so, then bail out.
> 
> The root seems to be to find a nice generic way of checking the process
> table?  What are the best modules for this under Win32?

I don't think you want to check the process table.  That isn't even portable
among unix systems, and it may introduce race conditions.

One common way is to sync through the filesystem.  Use existence of a file
as a signal that a process is up.  Create the file at startup, and delete
it in an END block.  Using sysopen() (q.v.) for creation should make that
reasonably safe.

If you can use file locking (not sure about the windows side), that would
be the way to go.  Again you use a file, but it isn't created/deleted
with program runs, but only locked (exclusively).  The advantage is that
it's easier to get correct (because it's what locking is about), and
you're not responsible for deleting the file.  The system takes care
of the lock.

Nothing of this is particular to Perl, the solutions apply more-or-less
to a process written in any language.

Anno


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

Date: Sun, 23 Nov 2003 09:06:49 +1100
From: Edo <eddhig22@yahoo.com>
Subject: Re: bit sequence match
Message-Id: <3FBFDDF9.8020601@yahoo.com>


> : no, I don't want the match but rather 5 values starting from the first 
> : record in %h2, to feed to a sub, then another 5 values starting from the 
> : second record in %h2 to feed to the sub and ... each group of values 
> : from %h2 is being put in @v2 and feed to sub sim(\@v1, \@v2)
> 
> Now I understand.
> 
> We've seen array slices and hash slices.  Now we get to see a list
> slice.  It looks almost just like an array slice.
> 
>     for( 0 .. keys(%h2) - 5 ) {
>         my @v2 = @h2{ (keys %h2)[ $_ .. $_+4 ] };
>         sim( \@v1, \@v2 );
>     }
> 
> The "keys(%h2)" in the first line is in scalar context, so it returns
> the number of keys in %h2.
> 
> the "(keys %h2)" in the second line is in list context, so it returns a
> list of all keys in %h2.  Since %h2 is tied to the Tie::IxHash class,
> that list of keys will already be sorted.  The list slicing is done by
> the square brackets.
> 
> The "@h2{ ... }" is a hash slice, which you are already familiar with.
> 
ok, good, now this hash slice I also want to push @results, \%hash-slice,
the below is not doing that, I got somthing wrong

for( 0 .. keys(%h2) - @k1+0 ) {
     my @v2 = @h2{ (keys %h2)[ $_ .. $_+@k1-1 ] };
     tie my %section, 'Tie::IxHash';
     %section = %h2{$_ .. $_+@k1-1}; <---- list not a hash slice!?
     if (...) {
	push @results, \%section;
     }
}



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

Date: Sun, 23 Nov 2003 04:49:24 +1100
From: Edo <eddhig22@yahoo.com>
Subject: code structure
Message-Id: <3FBFA1A4.5000602@yahoo.com>

Hello

I am confused, I keep using the tie on each hash I make in the example 
below, I need to keep all hashs sorted but I feel this way is a waste of 
resources.

thanks

#!/usr/local/bin/perl
use strict;
use warnings;
use Tie::IxHash;

foreach my $item (@things) {
     tie my %data, 'Tie::IxHash';
     %data = load ($item);

     tie my %info, 'Tie::IxHash';
     %info = prepair (\%data);
}

sub load {
	my $i = shift;
	tie my %h, 'Tie::IxHash';
	... some code
	return %h;
}

sub prepair {
	my $j = shift;
	tie my %hj, 'Tie::IxHash';
	... some code
	return %hj;
}



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

Date: Sat, 22 Nov 2003 16:17:26 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Edo <eddhig22@yahoo.com>
Subject: Re: code structure
Message-Id: <Pine.SGI.3.96.1031122161155.243499C-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Sun, 23 Nov 2003, Edo wrote:

>I am confused, I keep using the tie on each hash I make in the example 
>below, I need to keep all hashs sorted but I feel this way is a waste of 
>resources.

>foreach my $item (@things) {
>     tie my %data, 'Tie::IxHash';
>     %data = load ($item);

I would pass %data to the load() function (as a reference).

    load($item => \%data);

via:

  sub load {
    my ($i, $d) = @_;
    # store stuff in %$d
  }

Then you don't need to return anything or do any extra tie()s.

>     tie my %info, 'Tie::IxHash';
>     %info = prepair (\%data);

Same here:

    prepare(\%data => \%info);

via:

  sub prepare {
    my ($d, $i) = @_;
    # get from %$d, put in %$i
  }

You can make your code look "nicer" by using prototypes, too:

  # the function and prototype must be AT LEAST declared
  # BEFORE the function is called
  sub load ($\%);
  sub prepare (\%\%);

  for my $item, (...) {
    tie my(%data), 'Tie::IxHash';
    load($item => %data);  # %data will automatically become \%data
    tie my(%info), 'Tie::IxHash';
    prepare(%data => %item);  # automatically referenced
  }

with functions

  sub load ($\%) {
    my ($i, $d) = @_;
    # ...
  }

  sub prepare (\%\%) {
    my ($d, $i) = @_;
    # ...
  }

Of course, you could define the functions up top too, but I tend to leave
function definitions for the bottom of the program.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sun, 23 Nov 2003 10:00:21 +1100
From: Edo <eddhig22@yahoo.com>
Subject: Re: code structure
Message-Id: <3FBFEA85.5020202@yahoo.com>

Jeff 'japhy' Pinyan wrote:
> [posted & mailed]
> 
> On Sun, 23 Nov 2003, Edo wrote:
> 
> 
>>I am confused, I keep using the tie on each hash I make in the example 
>>below, I need to keep all hashs sorted but I feel this way is a waste of 
>>resources.
> 
> 
>>foreach my $item (@things) {
>>    tie my %data, 'Tie::IxHash';
>>    %data = load ($item);
> 
> 
> I would pass %data to the load() function (as a reference).
> 
>     load($item => \%data);
> 
> via:
> 
>   sub load {
>     my ($i, $d) = @_;
>     # store stuff in %$d
>   }
> 
> Then you don't need to return anything or do any extra tie()s.
> 
> 
>>    tie my %info, 'Tie::IxHash';
>>    %info = prepair (\%data);
> 
> 
> Same here:
> 
>     prepare(\%data => \%info);
> 
> via:
> 
>   sub prepare {
>     my ($d, $i) = @_;
>     # get from %$d, put in %$i
>   }
> 
> You can make your code look "nicer" by using prototypes, too:
> 
>   # the function and prototype must be AT LEAST declared
>   # BEFORE the function is called
>   sub load ($\%);
>   sub prepare (\%\%);
> 
>   for my $item, (...) {
>     tie my(%data), 'Tie::IxHash';
>     load($item => %data);  # %data will automatically become \%data
>     tie my(%info), 'Tie::IxHash';
>     prepare(%data => %item);  # automatically referenced
>   }
> 
> with functions
> 
>   sub load ($\%) {
>     my ($i, $d) = @_;
>     # ...
>   }
> 
>   sub prepare (\%\%) {
>     my ($d, $i) = @_;
>     # ...
>   }
> 
> Of course, you could define the functions up top too, but I tend to leave
> function definitions for the bottom of the program.
> 

inside those functions, when I need to refrence the hash, do I have to 
deref. them? $d and $i are hash-refs, %{$d} and %{$i} are the hashs to use?

thanks



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

Date: Sat, 22 Nov 2003 17:09:33 GMT
From: "Jerry C." <jerry_c48@cordollisonline.com>
Subject: Re: dumb newbie question (or newbie dumb question)
Message-Id: <3FBF9848.53CBA61F@cordollisonline.com>

>     ($sentence) = $sentence =~ /(\d\d)/;
>
> : p.s. I really appreciate your help! If you could answer this question,
> : too, it would be greatly appreciated: In Perl Version 5.6.1, this code
> : worked, but in version 5.8.0, it no longer works. Any idea why?
> :
> :       $sentence = "January 23, 1992";
> :       $sentence =~ s/[^\d]+//g;
> :       $sentence = substr($sentence,0,2);
> :       $sentence =~ s/\b0//;
> :       print $sentence;
>
> "It no longer works" does nothing to describe the problem.
>
> What should the code do that it does not?
> What does the code do that it should not?

Sorry, but I should have mentioned that the code is supposed to do what this
does:
($sentence) = $sentence =~ /(\d\d)/;
(e.g. find the first 2 digits in the string $sentence)
It worked fine in Perl 5.6.1 but doesn't work for me in 5.8.0



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

Date: Sat, 22 Nov 2003 18:50:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: dumb newbie question (or newbie dumb question)
Message-Id: <bpo7ou$1pul8e$1@ID-184292.news.uni-berlin.de>

Jerry C. wrote:
> Jay Tilton wrote:
>> "Jerry C." wrote:
>>> 
>>>       $sentence = "January 23, 1992";
>>>       $sentence =~ s/[^\d]+//g;
>>>       $sentence = substr($sentence,0,2);
>>>       $sentence =~ s/\b0//;
>>>       print $sentence;
>> 
>> "It no longer works" does nothing to describe the problem.
>> 
>> What should the code do that it does not?
>> What does the code do that it should not?
> 
> Sorry, but I should have mentioned that the code is supposed to do
> what this does:
> ($sentence) = $sentence =~ /(\d\d)/;
> (e.g. find the first 2 digits in the string $sentence)
> It worked fine in Perl 5.6.1 but doesn't work for me in 5.8.0

For me, the code prints '23' (in 5.8.0), which I suppose it's supposed
to do. You are still failing to explain the nature of the problem.

- What _does_ the code do when you run it?

- Which error and/or warning messages do you receive?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 22 Nov 2003 13:18:31 -0600
From: Master Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: dumb newbie question (or newbie dumb question)
Message-Id: <MPG.1a297283366d84c89896de@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <3FBF82DD.9F5E448E@cordollisonline.com>, jerry_c48
@cordollisonline.com says...
> Hi, I have the following code which finds and prints the first 2 digits
> in a string. I'm trying to make it more efficient. Here's the code:
> 
> $sentence = "January 23, 1992";
> if ($sentence =~ /\d\d/) { $sentence = "$&"; }
> print $sentence;
> 
> If I know that "$sentence" will ALWAYS have a two digit date, is there a
> way I can get rid of the "if - then" statement and just have it print
> $sentence??? I tried this, and it doesn't work:
> 
> $sentence = "January 23, 1992";
> $sentence = /\d\d/;
> print $sentence;
> 
> I'm just trying to make my script slightly more efficient by getting rid
> of that "if - then" statement.
> 
> Thanks,
> -Jerry
> 
> p.s. I really appreciate your help! If you could answer this question,
> too, it would be greatly appreciated: In Perl Version 5.6.1, this code
> worked, but in version 5.8.0, it no longer works. Any idea why?
> 
>       $sentence = "January 23, 1992";
>       $sentence =~ s/[^\d]+//g;
>       $sentence = substr($sentence,0,2);
>       $sentence =~ s/\b0//;
>       print $sentence;

use English;

$sentence =~ m/\d\d/;
print $MATCH;



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

Date: Sat, 22 Nov 2003 20:33:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: dumb newbie question (or newbie dumb question)
Message-Id: <x7wu9s3zzz.fsf@mail.sysarch.com>

>>>>> "MWS" == Master Web Surfer <raisin@delete-this-trash.mts.net> writes:

  >> $sentence =~ s/[^\d]+//g;
  >> $sentence = substr($sentence,0,2);
  >> $sentence =~ s/\b0//;
  >> print $sentence;

  MWS> use English;

  MWS> $sentence =~ m/\d\d/;
  MWS> print $MATCH;

oh crap! no one uses English for two reasons. it is dumb and it slows
down all your s/// operations since it refers to $& and brethren. there
is no need to ever use $& when you can just explicitly grab the match
you want.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 22 Nov 2003 22:29:13 GMT
From: "bbxrider" <bxtrap01@comcast.net>
Subject: newbie regular expression questions
Message-Id: <ZqRvb.280961$Fm2.290586@attbi_s04>

i' ve found this code for parsing form input
 foreach (split(/[&;]/, $buffer)) {
        s/\+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        $value=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        ..........
i know it works but the data is ascii characters to begin with and don't
understand what is the need for the substitution after converting all the
+'s to spaces??
i know am cycling thru the input field names and their values character by
character for searching for only digits and upper+lower case alphabet
to substitute but
don't understand significance of the % sign,
not really sure what the {2} grouping is doing
and basically it seems to be saying look for ascii digits and alphabet and
convert the hex value of those characters to the same value as starting
with, in other words, convert the original value back to the original
value????????
is type of conversion only necessary due to properties of form input data on
the web????




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

Date: Sat, 22 Nov 2003 19:42:18 GMT
From: Default@IO_Error_1011101.xyz
Subject: Printing to one x-y co-ord
Message-Id: <u_Ovb.5348$yy5.801@nwrdny01.gnilink.net>

any way i can accomplish this?  the initial print never seems to work,
untill there is another command after the initial print. (\n <stdin> etc..)

#!
@numbers = (1..10);
foreach $number (@numbers)
{	print "$number";
	print "\b\b  \b\b";
}


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

Date: Sat, 22 Nov 2003 21:25:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Printing to one x-y co-ord
Message-Id: <bpogrg$1o0mg4$1@ID-184292.news.uni-berlin.de>

Default@IO_Error_1011101.xyz wrote:
> any way i can accomplish this?

Accomplish what?

> the initial print never seems to work,

Work?

> untill there is another command after the initial print.
> (\n <stdin> etc..)

Sorry, don't understand.

Please (re-)read the posting guidelines
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
and rewrite your question, following the advice in the guidelines.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 22 Nov 2003 21:45:56 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Printing to one x-y co-ord
Message-Id: <oOQvb.4201$7%4.1084@nwrdny03.gnilink.net>

> Default@IO_Error_1011101.xyz wrote:
> > any way i can accomplish this?
> 
> Accomplish what?
> 

Yea nothing comes out on the screen.  What it is is..

Would like to print a character to the screen.

Then backspacer over that character and print a different character
in its place.

sorry i thought the code was self explanitory.



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

Date: Sat, 22 Nov 2003 21:57:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Printing to one x-y co-ord
Message-Id: <gZQvb.2690$Pm4.1407@nwrddc03.gnilink.net>

Default@IO_Error_1011101.xyz wrote:
> any way i can accomplish this?  the initial print never seems to work,
> untill there is another command after the initial print. (\n <stdin>
> etc..)
>
> #!
> @numbers = (1..10);
> foreach $number (@numbers)
> { print "$number";
> print "\b\b  \b\b";
> }

I am guessing you are looking for Curses, but it is quite difficult to tell
because your description is somewhat lacking in clarity.

jue




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

Date: Sat, 22 Nov 2003 22:04:56 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Printing to one x-y co-ord
Message-Id: <3fbfdd8d.72601951@news2.news.adelphia.net>

On Sat, 22 Nov 2003 19:42:18 GMT, Default@IO_Error_1011101.xyz wrote:

>any way i can accomplish this?  the initial print never seems to work,
>untill there is another command after the initial print. (\n <stdin> etc..)
>
>#!
>@numbers = (1..10);
>foreach $number (@numbers)
>{	print "$number";
>	print "\b\b  \b\b";
>}

Either your buffering is keeping output away, or the computer is working so
fast it's erasing your numbers before you see them.


Try:

>>>>>>>>>>>>>>>>>>>>>>

#!/usr/bin/perl -w
# always use strict during development
use strict;
# turn output buffering off
$| = 1;

my @numbers = (1..10);
foreach my $number (@numbers)
{	print "$number";
	# pause to see things
	sleep 1;
	print "\b\b  \b\b";
}

<<<<<<<<<<<<
---
Use the domain skylightview (dot) com for the reply address instead.


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

Date: Sat, 22 Nov 2003 22:06:29 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Printing to one x-y co-ord
Message-Id: <F5Rvb.4273$7%4.1824@nwrdny03.gnilink.net>

> Default@IO_Error_1011101.xyz wrote:
> > any way i can accomplish this?  the initial print never seems to work,
> > untill there is another command after the initial print. (\n <stdin>
> > etc..)
> >
> > #!
> > @numbers = (1..10);
> > foreach $number (@numbers)
> > { print "$number";
> > print "\b\b  \b\b";
> > }
> 
> I am guessing you are looking for Curses, but it is quite difficult to tell
> because your description is somewhat lacking in clarity.
> 
> jue
> 
> 
> 

Hmmm curses ok, never heard of it.. ill check that out thanks.
See i just want to print something then run a time consuming function, 
then backspace over what was just printed, so that i can print something new
in the same place on the screen as the previously printed char.



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

Date: Sat, 22 Nov 2003 22:14:57 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Printing to one x-y co-ord
Message-Id: <BdRvb.5695$yy5.3769@nwrdny01.gnilink.net>

> # turn output buffering off
> $| = 1;

Ahh very cool, didn't know that trick.

> 	# pause to see things
> 	sleep 1;

Yes! ive been looking for a built in pause like function.
I've been using <STDIN> to create pauses.  That sleep command is very
helpfull indeed, thank you very much.

Ahh yes and not only all that.. your solution works :-)
It was the output buffering setting.
Thanks


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

Date: Sat, 22 Nov 2003 20:15:05 -0000
From: Trotsky <me@privacy.net>
Subject: reading and writing to text file via form newbie
Message-Id: <MPG.1a29d4288fa5f723989680@news.ispserve.co.uk>

Hi all,
Im trying to read and write to a text file using two scripts.
One to read the file into a text box, make changes then post it to 
another script to actually overwrite the text file.
Ive cobbled together the scripts from various tutorials online, and as 
you can see I have not got a clue what I am doing really.
Ive succeeded in making a script to delete a text file.
anyway heres the code for the READ.PL script

#!/usr/bin/Perl # This line applies to non-IIS users only
print "Content-type:text/html\n\n";
open(fileIN,"test.txt") or dienice("Cannot open test.txt: $!");
@logData = <fileIN>;
close(fileIN);
print <<EndHTML;
    <html>\n<head>\n
    <title> Log File Data </title>\n
    </head>\n<body>\n
    <h2>Log File Data</h2>\n
EndHTML
foreach $line (@logData)
{
    chomp($line);
    print "<form method=post action=write.pl><textarea cols=100 rows=20 
name=text>$line<br>\n";
}
print "</textarea><input type=submit></form></body>\n</html>";
# Error Trapping Sub...should things go pear shaped!
sub dienice
{
    my($msg) = @_;
    print "<html>\n<head>\n<title>Error Opening File!</title>\n";
    print "</head>\n";
    print "<body><h2>Error</h2>\n<b>";
    print $msg;
    print "\n</b></body>\n</html>";
    exit;
}

This code reads the text file perfectly (I think)


And heres the code for the WRITE.PL script

#!/usr/bin/perl
print "Content-type:text/html\n\n";
#makes data readable
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach$pair (@pairs) 
{
    ($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
     $Form{$name} = $value;
} 
#opens text file
open(fileOUT, ">test.txt") or dienice("Can't open log.txt for writing: 
$!");
#WRITES FORM DATA TO TEXT FILE 
print fileOUT "$value";
close(fileOUT);
# If all went well, output thank you message
print <<EndHTML;
<html><head><title>Thank You</title></head>
<body>
<h2>Thank You!</h2><br>
The following information has been logged:<br><br>
$line.<br>
</body></html>
EndHTML

Im running on IIS 5.1 locally with perl 5.6.1
Any help appreciated. Im a complete newbie so you may have to talk quite 
slow..
Thanks
John


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

Date: Sat, 22 Nov 2003 22:11:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: reading and writing to text file via form newbie
Message-Id: <bpojil$1r7ah1$1@ID-184292.news.uni-berlin.de>

Trotsky wrote:
> Im trying to read and write to a text file using two scripts. One
> to read the file into a text box, make changes then post it to 
> another script to actually overwrite the text file.

Okay.

> Ive cobbled together the scripts from various tutorials online, and
> as you can see I have not got a clue what I am doing really.

That's a bad approach. Really bad. Never use such code unless you
don't understand what it does!!

You'd better learn enough to understand what the code you have
"cobbled together" does. That way you'll undoubtedly get input to fix
some of the bugs.
Before having done so, it's rude to post the code here.

An even better approach, of course, is to read some book - paper or on
line - about Perl and CGI, and learn some of the basics before
starting to write your own code that accomplishes the above task.

> Any help appreciated.

Believe it or not, but my intent with the above is to help.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 22 Nov 2003 17:07:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Top level blocks and indentation
Message-Id: <bpo542$n65$1@mamenchi.zrz.TU-Berlin.DE>

Top level blocks, that is, blocks at file level, serve many useful
purposes.  An example is, in a module file, a related module or class
you want to incorporate in the main file.  It rightly belongs into a
BEGIN block.  Another example is a test file (t/*.t), where tests often
form groups.  It is useful to put each group in its lexical space, which
means that most of the file is inside one top level block or another.

In such cases, indentation comes as a nuisance.  I have taken to using
double braces, '{{' and '}}' to delimit top level blocks that aren't
indented.  I'm using them because the don't appear "naturally" in Perl
(or do they?) and they don't hurt (or do they?).  I also hope to say
something like "Yes, this *is* a block.  I'm still not indenting", but
that is perhaps hoping a bit much.

The main question is, of course, how much does the lack of indentation
hurt?  I don't notice more block structure mixups in sources where I'm
using that style, but then I'm biased.  I did notice more mixups when
trying to *nest* double braces, so I'm not totally insensitive.  Never
nest them, by definition double braces only apply to top level blocks.

In any case, before I release any code in this style to CPAN, I'd like
to test the waters and ask if that would, umm..., get me talked about.

If anyone cares to take a look at some code, I have put up two examples,
a module and a test file, under

http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/Module.pm
http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/test-file

Please, these are only to look at.  They are taken as-is out of some
ongoing work.  I'm reasonably sure they compile, but that's it.  (And
don't anyone *dare* tell me it's undocumented, man do I know it :)

Anno


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

Date: Sat, 22 Nov 2003 19:58:56 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Top level blocks and indentation
Message-Id: <20031122145855.6a1f9721.jwillmore@remove.adelphia.net>

On 22 Nov 2003 17:07:14 GMT
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

<snip>
> If anyone cares to take a look at some code, I have put up two
> examples, a module and a test file, under
> 
> http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/Module.pm
> http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/double_brace/test-file
> 
> Please, these are only to look at.  They are taken as-is out of some
> ongoing work.  I'm reasonably sure they compile, but that's it. 
> (And don't anyone *dare* tell me it's undocumented, man do I know it
> :)

I looked and have the following opinion - just take the comments as
opinion and nothing more.

You're method is a lot like getting the first new model of a car -
some will embrace the change and others will long for the good olde
days and question the change.  I'm sitting on the fence (and boy does
my butt hurt :-) )  I can follow the code, but the "accepted method of
indenting" filtering device in my brain is flashing red and saying
"Something is wrong".

If it were me, I'd do indenting so I can understand what's going on,
then run perltidy againist the code to make it "acceptable".  But
that's me :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Distinctive, adj.:  A different color or shape than our
competitors. 


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

Date: 22 Nov 2003 21:17:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Top level blocks and indentation
Message-Id: <bpojpj$cmu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Anno Siegel:

> Top level blocks, that is, blocks at file level, serve many useful
> purposes.  An example is, in a module file, a related module or class
> you want to incorporate in the main file.  It rightly belongs into a
> BEGIN block.  Another example is a test file (t/*.t), where tests often
> form groups.  It is useful to put each group in its lexical space, which
> means that most of the file is inside one top level block or another.
> 
> In such cases, indentation comes as a nuisance.  I have taken to using
> double braces, '{{' and '}}' to delimit top level blocks that aren't
> indented.  I'm using them because the don't appear "naturally" in Perl
> (or do they?) and they don't hurt (or do they?).  I also hope to say
> something like "Yes, this *is* a block.  I'm still not indenting", but
> that is perhaps hoping a bit much.

This sounds familiar. My vim always wants to indent my C headers when
they conventionally start with

    #ifdef __cplusplus
    extern "C" {
    #endif 

It's a similar case where blocks aren't really meant to be blocks.

> The main question is, of course, how much does the lack of indentation
> hurt?  I don't notice more block structure mixups in sources where I'm
> using that style, but then I'm biased.  I did notice more mixups when
> trying to *nest* double braces, so I'm not totally insensitive.  Never
> nest them, by definition double braces only apply to top level blocks.
> 
> In any case, before I release any code in this style to CPAN, I'd like
> to test the waters and ask if that would, umm..., get me talked about.

Not by me anyway. I'd say that the ordinary indentation would look odder
for this case. Any reader would quickly realize that it serves no
purpose. I am pretty sure that the first thing I'd do when inspecting
the code would be left-shifting it. Therefore, not indenting these
top-level blocks is reasonable.

Besides, I think the samples you provided are extremely readable and
tidy, even when measured with the generally quite good CPAN-standards.
That's not going to get you talked about in an undesirable way. ;-)

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: 22 Nov 2003 10:27:34 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: what does "/usr/bin/perl: relocation error:" mean?
Message-Id: <776e0325.0311221027.f807721@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpnole$gfn$1@mamenchi.zrz.TU-Berlin.DE>...
> Sara <genericax@hotmail.com> wrote in comp.lang.perl.misc:
> > Perl was running fine on this box last night, now I get this error:
> > 
> > ./user.pl
> > /usr/bin/perl: relocation error:
> > /usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/libperl.so:
> > undefined symbol: Perl_rxres_fr
> > 
> > 
> > uhhhhh.. OK? I searched news for "Perl_rxres_fr" - is this the first
> > time this ever happened?
> 
> It's not a Perl error, your system can't load Perl, or probably something
> Perl wants to load dynamically.  Does perl run by itself (/usr/bin/perl
> -e '')?  What non-core modules does "user.pl" use?  Could there be a
> version mixup?
> 
> The prefix "Perl_" was introduced to some of the symbols in the perl core
> rather late in the game, and some XS modules have taken even longer to
> catch up.  There may still be some that haven't.
> 
> Anno



Good day and Thank-You Anno:

 
** Perl sees to run OK here:

  [tux@tux perl]$ perl -v

  This is perl, v5.8.0 built for i386-linux-thread-multi

  Copyright 1987-2002, Larry Wall


** and this little program is OK:

  #!/usr/bin/perl -w

  print "Hi Anno its me Perl!\n\n";


** But this program which was running FINE last night, and has had no
changes since then (I compared it with the last EMACS ~ file and the
only diff is an edit I made). ALso there have been no system installs
or updates:

  #!/usr/bin/perl -wd

  use LWP::UserAgent;
  use LWP::Simple;
  use HTTP::Request::Common qw(POST);
  use HTTP::Cookies;

  use Net::Nslookup;

  use lib qw(sql);
  use SNsql;
  use IPsql;

  use DBI;

   .
   .
  quite a few more lines.......




Perhaps tonight it will run OK again? Very odd!


  /usr/bin/perl: relocation error:   
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/libperl.so:
undefined symbol: Perl_rxres_fr

Perhaps I need to edit libperl.so to investigate the missing symbol?

G


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

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


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