[28212] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9576 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 8 11:05:54 2006

Date: Tue, 8 Aug 2006 08:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Aug 2006     Volume: 10 Number: 9576

Today's topics:
        ''Get  free calling cards now  '' socald.smit@gmail.com
        Control characters - regex to match/lose these? <justin.0511@purestblue.com>
    Re: Control characters - regex to match/lose these? <mritty@gmail.com>
        exit value of system versus back quotes shrajan@gmail.com
    Re: exit value of system versus back quotes <mritty@gmail.com>
    Re: FAQ 5.21 I still don't get locking. I just want to  <simon.chao@fmr.com>
        Here is the corresponding AppleScript code: <martinmichel@ame-electroplating.com>
    Re: Here is the corresponding AppleScript code: <bart@nijlen.com>
    Re: How to get the column name in a spreadsheet app? <bart@nijlen.com>
    Re: How to get the column name in a spreadsheet app? <martinmichel@ame-electroplating.com>
    Re: How to get the column name in a spreadsheet app? <bart@nijlen.com>
    Re: How to use OO and package? <bik.mido@tiscalinet.it>
    Re: How to use OO and package? <zhushenli@gmail.com>
    Re: Net FTP -- Size showing different results on AIX sy <fmbright@gmail.com>
        Perl eats alot of memory <melco@yandex.ru>
        Perl eats alot of memory <melco@yandex.ru>
    Re: Perl eats alot of memory <bik.mido@tiscalinet.it>
    Re: Segmentation fault (core dumped) <eliyah_kilada@yahoo.co.uk>
    Re: Segmentation fault (core dumped) <daveandniki@ntlworld.com>
    Re: Segmentation fault (core dumped) <no@email.com>
    Re: Simple file list in directory to array anno4000@radom.zrz.tu-berlin.de
    Re: Simple file list in directory to array <bik.mido@tiscalinet.it>
    Re: Simple file list in directory to array <1usa@llenroc.ude.invalid>
    Re: Simple file list in directory to array <1usa@llenroc.ude.invalid>
    Re: Upload a file on server <1usa@llenroc.ude.invalid>
    Re: What bless() do actually? <jimi@webu.co.uk>
    Re: What bless() do actually? (Randal L. Schwartz)
    Re: What bless() do actually? <mritty@gmail.com>
    Re: What bless() do actually? anno4000@radom.zrz.tu-berlin.de
    Re: What bless() do actually? <jimi@webu.co.uk>
    Re: What bless() do actually? <jimi@webu.co.uk>
    Re: What bless() do actually? <jimi@webu.co.uk>
        which file, regestry, environment variables do perl ins yan.vulich@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 Aug 2006 04:37:08 -0700
From: socald.smit@gmail.com
Subject: ''Get  free calling cards now  ''
Message-Id: <1155037028.926933.169830@m79g2000cwm.googlegroups.com>

                 ''Get  free calling cards now  ''
Hi Friends,

I found a great site to call anywhere in the World for free!
What we have to do is  just signup and earn freecalling cards.

After signingup with Globalfreecalling you  can findout lot of very
simple and easy offers
(Just Contact Information Required).Some Offers may Required only
E-Mail and Zip Code Only.
Just complete the Offers and get Free calling Cards.

signup with below link::

http://ww3.6URL.com/0P8U

Hurry Up Friends !



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

Date: Tue, 08 Aug 2006 14:04:27 -0000
From: Justin C <justin.0511@purestblue.com>
Subject: Control characters - regex to match/lose these?
Message-Id: <slrnedh6fb.7m7.justin.0511@stigmata.purestblue.com>

Some of the text files I have to parse with perl have control characters
within them. They are controls to turn on and off things when printing
(stuff like "make this bold", "make this bigger", "draw a box around
this", that kind of thing). If I view the text file with /usr/bin/less I
see them as: ESC(s12H  ESC&16D  ESC(s16H  ESC&18D

Viewed in vim they look like: ^[(s12H  ^[&16D  ^[(16H  ^[&18D

Those are the four that jump out at me while scrolling this document,
there are probably more.

I've tried perldoc -q control and perldoc -q escape but neither of those
mentions control characters or escape sequences. Can someone point me at
the documentation I need to help me catch these and strip them out? Will 
a regex work? What does perl see these as?

Thank you for your help.


	Justin.

-- 
Justin C by the sea.


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

Date: 8 Aug 2006 07:32:44 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Control characters - regex to match/lose these?
Message-Id: <1155047564.611294.125930@n13g2000cwa.googlegroups.com>

Justin C wrote:
> Some of the text files I have to parse with perl have control characters
> within them. They are controls to turn on and off things when printing
> (stuff like "make this bold", "make this bigger", "draw a box around
> this", that kind of thing). If I view the text file with /usr/bin/less I
> see them as: ESC(s12H  ESC&16D  ESC(s16H  ESC&18D
>
> Viewed in vim they look like: ^[(s12H  ^[&16D  ^[(16H  ^[&18D
>
> Those are the four that jump out at me while scrolling this document,
> there are probably more.
>
> I've tried perldoc -q control and perldoc -q escape but neither of those
> mentions control characters or escape sequences. Can someone point me at
> the documentation I need to help me catch these and strip them out? Will
> a regex work? What does perl see these as?

Just a guess, but I'd try to use the [:cntrl:] character class.  See
perldoc perlre

s/[[:cntrl:]]//g;

Paul Lalli



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

Date: 8 Aug 2006 06:13:53 -0700
From: shrajan@gmail.com
Subject: exit value of system versus back quotes
Message-Id: <1155042833.087360.316380@n13g2000cwa.googlegroups.com>

Hi,
     I have a script where I am running a command using system and then
using back quotes and I getting different exit status in both cases.
This only happens on linux Redhat 4.0 EL.

     `opcmon OSSPI-syslogproc_2=0`;
      print "value1 = $?\n";
      system("opcmon OSSPIlogproc_2=0");
      print "value2 = $?\n";

      value1 is -1 and value2 is printed as 0.
Thanks,
Shiju,



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

Date: 8 Aug 2006 07:35:22 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: exit value of system versus back quotes
Message-Id: <1155047722.336569.164960@i3g2000cwc.googlegroups.com>

shrajan@gmail.com wrote:
>      I have a script where I am running a command using system and then
> using back quotes

No you're not.

> and I getting different exit status in both cases.

Which is not surprising when you run two different commands.

> This only happens on linux Redhat 4.0 EL.
>
>      `opcmon OSSPI-syslogproc_2=0`;

"OSSPI-syslogproc"

>       print "value1 = $?\n";
>       system("opcmon OSSPIlogproc_2=0");

"OSSPllogproc"

>       print "value2 = $?\n";
>
>       value1 is -1 and value2 is printed as 0.

Why are you expecting anything different?

Paul Lalli



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

Date: 8 Aug 2006 06:30:07 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: FAQ 5.21 I still don't get locking. I just want to increment the number in the file. How can I do this?
Message-Id: <1155043807.220660.221370@m73g2000cwd.googlegroups.com>


PerlFAQ Server wrote:
> This is an excerpt from the latest version perlfaq5.pod, which
> comes with the standard Perl distribution. These postings aim to
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
>
> --------------------------------------------------------------------
>
> 5.21: I still don't get locking.  I just want to increment the number in the file.  How can I do this?
>
>
>     Didn't anyone ever tell you web-page hit counters were useless? They
>     don't count number of hits, they're a waste of time, and they serve only
>     to stroke the writer's vanity. It's better to pick a random number;
>     they're more realistic.

What do web-page hit counters count then?



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

Date: 8 Aug 2006 07:54:52 -0700
From: "Martin M." <martinmichel@ame-electroplating.com>
Subject: Here is the corresponding AppleScript code:
Message-Id: <1155048892.810287.295140@i42g2000cwa.googlegroups.com>

Hi Bart,

thanks for explaining the code to me in detail. Now I really
understand, what is going on there and was finally able to write a
small function in AppleScript, which does the same:

http://www.schoolscout24.de/tmp/get_column_name.html

Well, yes, the code is 'longish', but it works :-)

Once again: Thank you, you really helped me out!

Martin



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

Date: 8 Aug 2006 07:57:29 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Here is the corresponding AppleScript code:
Message-Id: <1155049048.906727.5450@m79g2000cwm.googlegroups.com>

Martin M. wrote:

> thanks for explaining the code to me in detail. Now I really
> understand, what is going on there and was finally able to write a
> small function in AppleScript, which does the same:
>
> http://www.schoolscout24.de/tmp/get_column_name.html

Now THAT was magic :-)

-- 
 Bart



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

Date: 8 Aug 2006 04:08:37 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How to get the column name in a spreadsheet app?
Message-Id: <1155035317.729466.57860@75g2000cwc.googlegroups.com>

Martin M. wrote:

> I am currently developing a small AppleScript, which will help our
> staff to automate tasks in our spreadsheet app (RagTime 6). But now I
> am at a point, where I need a function in my AppleScript to determine
> the name of a column name in a table. Here is an example, just to give
> you an idea:
>
> Position: 5 -> Column name: "E"
> Position: 28 -> Column name: "AB"
>
> Now, I found a Perl module, which does exactly this: Converting number
> positions into column names, but...I am not (yet) familiar with Perl.
> [...]

No need for a module here:

  my $nr = 5; # fill in position here
  my $t  = A;
  ++$t for (1..$nr-1);
  print "Position: $nr -> Column name: $t\n";

-- 
 Bart



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

Date: 8 Aug 2006 05:30:28 -0700
From: "Martin M." <martinmichel@ame-electroplating.com>
Subject: Re: How to get the column name in a spreadsheet app?
Message-Id: <1155040228.788448.132410@m79g2000cwm.googlegroups.com>

> No need for a module here:
>
>   my $nr = 5; # fill in position here
>   my $t  = A;
>   ++$t for (1..$nr-1);
>   print "Position: $nr -> Column name: $t\n";
>

Hi Bart,

thank you very much for posting this piece of code. I tried it on my
Mac and it works like a charm. The only thing is: I don't know how it
works :)

Of course, first your are creating a variable containing the position
value, then you are creating a second variable containing the A value.
But is this a string? Finally there is this kind of loop in line 3,
which loops $nr minus 1 times, thereby adding <something> to the A
value. Well, what is going on in line 3? ;-)

I am now using your code for getting the column names via the shell
('do shell script'-command in AppleScript), because it works just
beautiful and blazing fast, but I really want to know, how the magic is
done.

Thanks so much,

Martin



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

Date: 8 Aug 2006 07:20:29 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How to get the column name in a spreadsheet app?
Message-Id: <1155046829.228956.121250@m79g2000cwm.googlegroups.com>

Martin M. wrote:

> > No need for a module here:
> >
> >   my $nr = 5; # fill in position here
> >   my $t  = A;
> >   ++$t for (1..$nr-1);
> >   print "Position: $nr -> Column name: $t\n";
> >
> thank you very much for posting this piece of code. I tried it on my
> Mac and it works like a charm. The only thing is: I don't know how it
> works :)
>
> Of course, first your are creating a variable containing the position
> value, then you are creating a second variable containing the A value.
> But is this a string? Finally there is this kind of loop in line 3,
> which loops $nr minus 1 times, thereby adding <something> to the A
> value. Well, what is going on in line 3? ;-)

Frankly I don't see much magic here :) Let's rewrite it a bit so it's
easy to follow:

    #!/perl
    use strict;
    use warnings;

    # Fill in position here that you wish to convert.
    my $nr = 29;

    # Just a start value, like first col in xls file
    # (actually quotes around it is better practice).
    # Yes it's an "ordinary" var.
    my $t = 'A';

    # Find the next column with ++ by just adding up
    # the current value (A becomes B, AZ becomes BA,
    # EWKLR becomes EWKLS, etc), it's like in Excel.
    # You could do (0..$nr-2) or (2..$nr) as well.
    for (1..$nr-1)
    {
     $t++;
    }

    # Print result to screen.
    print $t;

-- 
 Bart



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

Date: 8 Aug 2006 12:29:09 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to use OO and package?
Message-Id: <csogd2peqqa8bivqarqf2liqffqalsaisp@4ax.com>

On 7 Aug 2006 15:57:50 GMT, John Bokma <john@castleamber.com> wrote:

>Michele Dondi <bik.mido@tiscalinet.it> wrote:
>
>> Are you asking why it is so? Well, there are good reasons, but I think
>> you won't be interested in knowing. You may want to know that there's
>> people who whish there were a way to use the actual return value
[snip]
>The perldoc -f for require shows that do is used, so I would say that you 
>actually might be able to get the value returned (at least by require).

Yes, I know that *something* can already be done. There problems,
though. I was implicitly, but specifically referring to discussions
like this:

http://perlmonks.org/?node_id=559798


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 8 Aug 2006 04:08:09 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Re: How to use OO and package?
Message-Id: <1155035289.113040.38240@m73g2000cwd.googlegroups.com>


Michele Dondi wrote:
> On 7 Aug 2006 22:29:23 -0700, "Davy" <zhushenli@gmail.com> wrote:
>
> >Hi Michele,
> >
> >I am sorry, but what's top-post mean? Thanks!
> >
> >Davy
> >
> >Michele Dondi wrote:
> >> On 7 Aug 2006 03:44:18 -0700, "Davy" <zhushenli@gmail.com> wrote:
> [snip]
>
> Exactly this: putting your text on *top* of the quoted content. You'd
> better trim the latter and put your remarks after each relevant
> portion of it.
>
[snip]

Hi, Michele,

I understand, thanks!

Davy

>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,



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

Date: 8 Aug 2006 07:27:24 -0700
From: "fmbright" <fmbright@gmail.com>
Subject: Re: Net FTP -- Size showing different results on AIX system and Linux system
Message-Id: <1155047243.926630.159870@m79g2000cwm.googlegroups.com>

Len,

I installed the latest copies from CPAN and installed the lastest
version of Perl on both boxes.  Could the different unixes make
different results??

Thanks!

Frank

l v wrote:
> fmbright wrote:
> > To All:
> >
> > This is my first post.  My name is Frank.  I have been using  Net FTP
> > to create an automated FTP process.  I developed it on an AIX box (AIX
> > 5.2.0.7)  and now want to move it to our Linux box (Redhat).  The size
> > subroutine gives different results when running on the AIX version
> > Linux box.  On the AIX the size functions returns the size of the file
> > on the FTP while the call on the Linux box returns undefined.
> >
> > I am calling the same FTP site each time and using the same version of
> > the script.  What else would need to be done to get these version in
> > sync??
> >
> > Thanks!
> >
> >
> > Frank Bright
> > Univ. of the Arts
> > 215.717.6081
> > fbright@uarts.edu
> > 
> 
> Are your Net::FTP modules the same version?
> 
> -- 
> 
> Len



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

Date: 8 Aug 2006 07:00:31 -0700
From: "melco" <melco@yandex.ru>
Subject: Perl eats alot of memory
Message-Id: <1155045631.858845.37080@75g2000cwc.googlegroups.com>

Hi to all.
I worote a program which uses LWP::Simple and fork to grab links from
site.
For each found link I start fork() and again LWP content.
At some point it uses too much system memory and my Linux box
freezes...
How can i limit maximum amount of RAM which main perl process can use?



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

Date: 8 Aug 2006 07:00:41 -0700
From: "melco" <melco@yandex.ru>
Subject: Perl eats alot of memory
Message-Id: <1155045641.589199.312020@i42g2000cwa.googlegroups.com>

Hi to all.
I worote a program which uses LWP::Simple and fork to grab links from
site.
For each found link I start fork() and again LWP content.
At some point it uses too much system memory and my Linux box
freezes...
How can i limit maximum amount of RAM which main perl process can use?



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

Date: 8 Aug 2006 16:30:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl eats alot of memory
Message-Id: <9r7hd291krs5ij86sd8uhmnniulbpoca46@4ax.com>

On 8 Aug 2006 07:00:31 -0700, "melco" <melco@yandex.ru> wrote:

>Hi to all.
>I worote a program which uses LWP::Simple and fork to grab links from
>site.
>For each found link I start fork() and again LWP content.
>At some point it uses too much system memory and my Linux box
>freezes...
>How can i limit maximum amount of RAM which main perl process can use?

Huh?!? If this is recursive chances are that you hit ulimit (or
completely fill up the process table, depending on your setup) rather
than have a memory problem. Hence I suggest you keep a mechanism to
limit the number of fork()ed copies.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 8 Aug 2006 03:08:53 -0700
From: "ekilada" <eliyah_kilada@yahoo.co.uk>
Subject: Re: Segmentation fault (core dumped)
Message-Id: <1155031733.546657.33420@m73g2000cwd.googlegroups.com>

Hi Brian,
No, it occurs while reading line number 13457941
FYI: I use while (<>) to read line by line.

Regards,
Eliyah

Brian Wakem wrote:
> ekilada wrote:
>
> > Hi,
> > Using Perl, when I try to open a 1.8G file for reading, I get a
> > 'Segmentation fault (core dumped)' error.
> > Please, is there any way to segment huge files for reading ?
>
>
> If the error occurs when *opening* the file then the filesize is irrelevant.
>
>
> --
> Brian Wakem
> Email: http://homepage.ntlworld.com/b.wakem/myemail.png



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

Date: Tue, 8 Aug 2006 14:16:57 +0200
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: Segmentation fault (core dumped)
Message-Id: <44d880cc$0$861$ba4acef3@news.orange.fr>


"ekilada" <eliyah_kilada@yahoo.co.uk> wrote in message 
news:1155031733.546657.33420@m73g2000cwd.googlegroups.com...
> Hi Brian,
> No, it occurs while reading line number 13457941
> FYI: I use while (<>) to read line by line.
>
> Regards,
> Eliyah
>
> Brian Wakem wrote:
>> ekilada wrote:
>>
>> > Hi,
>> > Using Perl, when I try to open a 1.8G file for reading, I get a
>> > 'Segmentation fault (core dumped)' error.
>> > Please, is there any way to segment huge files for reading ?
>>
>>
>> If the error occurs when *opening* the file then the filesize is 
>> irrelevant.
>>
>>
>> --
>> Brian Wakem
>> Email: http://homepage.ntlworld.com/b.wakem/myemail.png
>

Questions:
Which version of Perl?
On what platform?
Does it happen on any huge file or is there something special about this one 
(like a huge line).
Can you post a short but complete script that demonstrates the problem (if 
run on a huge file)?




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

Date: Tue, 08 Aug 2006 13:19:20 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Segmentation fault (core dumped)
Message-Id: <4jrdq4F9d5h1U1@individual.net>

ekilada wrote:

> Hi Brian,
> No, it occurs while reading line number 13457941
> FYI: I use while (<>) to read line by line.
>

Is that the last line?

Perhaps the file is not the size is filesystem thinks it is.

Can you open the file and seek to the end with something like vi?


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: 8 Aug 2006 10:25:41 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Simple file list in directory to array
Message-Id: <4jr755F97mo2U1@news.dfncis.de>

Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
> Jim Gibson schreef:
> > darkmoo:
> 
> >> how to grab a list
> >> of all files in a directory and load it up into an array.
> >
> > In addition to the other, more recommended ways, there is always:
> >
> >    my @array = `ls /my/directory`;
> 
> If ls is available, and directories and links are welcome.

 ...plus line-feeds at the end of each file name (a *very* popular trap).

    chomp( my @array = `ls ...`);

comes closer.

Anno


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

Date: 8 Aug 2006 12:32:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Simple file list in directory to array
Message-Id: <8spgd2pq8ltmpqpomgi6dmu970kobv5nlp@4ax.com>

On Mon, 07 Aug 2006 23:41:39 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:

>> That approach is not good.  You should instead skip the array and do
>> something like this:
>> 
>>    foreach my $file( [something that gets a list of files] ) {
>>       # do something with $file
>>    }
>
>Wait a minute ;-) 
>
>The list will still be constructed in its entirety before the loop.

I don't think his remark was as much about constructing the list as a
whole as opposed to using an iterator, as much as it is about avoiding
unnecessary intermediate variables: which is sensible, provided that

  [something that gets a list of files]

is short enough. How short short enough is is a matter of personal
taste and preference, of course.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 8 Aug 2006 13:19:24 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Simple file list in directory to array
Message-Id: <Xns98195ED78A98Easu1cornelledu@132.236.56.8>

usenet@DavidFilmer.com wrote in news:1155023239.620102.294040
@b28g2000cwb.googlegroups.com:

> A. Sinan Unur wrote:
>> In both cases, processing won't begin until the list has been
>> constructed.
> 
> Of course this is true (for this example). The difference is whether or
> not you create an unnecessary named element in your namespace.

OK, I was more focused on not creating the list.

That is one reason why I still stick with File::Find. When I had to write 
something to organize my digital photos (all 30000 or so of them, most of 
them should be deleted probably), it was really much more satisfiying when 
the processing began immediately (I am not sure if there was an overall 
performance difference though, I did not measure it).

> But I prefer to avoid these whenever possible.  It is
> certinally not necessary to create such a redundant named structure in
> the example I cited, and is contrary to conventional Perl programming
> practice (which prefers "while (<DATA>)" to "for (@DATA)").

The same convention would indicate using File::Find, wouldn't it?

Sinan


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

Date: Tue, 8 Aug 2006 13:20:05 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Simple file list in directory to array
Message-Id: <Xns98195EF4A5B78asu1cornelledu@132.236.56.8>

Michele Dondi <bik.mido@tiscalinet.it> wrote in 
news:8spgd2pq8ltmpqpomgi6dmu970kobv5nlp@4ax.com:

> On Mon, 07 Aug 2006 23:41:39 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
> 
>>> That approach is not good.  You should instead skip the array and do
>>> something like this:
>>> 
>>>    foreach my $file( [something that gets a list of files] ) {
>>>       # do something with $file
>>>    }
>>
>>Wait a minute ;-) 
>>
>>The list will still be constructed in its entirety before the loop.
> 
> I don't think his remark was as much about constructing the list as a
> whole as opposed to using an iterator, as much as it is about avoiding
> unnecessary intermediate variables:

I got it. Thank you.

Sinan


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

Date: Tue, 8 Aug 2006 13:15:37 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Upload a file on server
Message-Id: <Xns98195E32CB96Fasu1cornelledu@132.236.56.8>

pjsenthil@gmail.com wrote in
news:1155028851.231766.113310@m79g2000cwm.googlegroups.com: 

> But in my case.I have so many images .i will list in the the browser
> with check box for each and image preview for each.

This is not a Perl question. You are understanding of CGI is lacking.

To be able to create a form with a thumbnail for each image, you need to 
upload each image to the server.

Or, use a signed Java applet or Activex object. Check out how online 
photo stores do it.

(Yes, one could ask the user for a directory to browse on the hard drive, 
then trust client-side Javascript to display such thumbs, or create and 
serve an HTML document with links to images on the user's hard drive,  
but I would not even consider it for obvious security issues).

> the below is partial code...

This code is worse than useless in that it creates the distinct 
impression that you don't have the foggies idea what you are doing.

You should post a small script that others can run just by copying and 
pasting.

If you want to insert extended comments in the middle of the script, just 
use

=for usenet

blah blah blah

=cut

>                # start reading users HD 1 kb at a time.

I won't be visiting your site soon!

>                   while(read($file, $buffer, 1024))
> {
> 
> print NEW $e;
> }


You probably want sysread and syswrite. However, you would do yourself a 
favor by reading about uploading in the CGI.pm manual even if you end up 
not using CGI.pm.

>                # close the new file on the server and we're done
>                close NEW;

By the way, this is exactly the kind of place where you should put a 
limit on POSTs, check if every single output operation succeded, if close 
succeded etc.

I don't understand any part of the code below, presumably because it is 
missing crucial parts and it is formatted awfully.

>           } else {
>                # return the server's error message if the new file
>                could not be 
> created
>                return qq~Error: Could not open new file on server.
>                $!~; 
>           }
> 
>           # check limit hasn't just been overshot
>           if(-s "$destination$S{S}$fileName" > $limit){ # -s is the
>           file size 
>                unlink("$destination$S{S}$fileName"); # delete it if
>                it's over the 
> specified limit
> 
>           return qq~File exceeded limitations : $fileName~;
>           }
>      } else {
> 
>           return qq~Bad file type : $file_type~;
>      }
>      if(-s "$destination$S{S}$fileName"){
> 
>           return qq~Success $fileName~; #success
>      } else {
>                unlink("$destination$S{S}$fileName");
> 
> 
>           return ; qq~Upload failed : No data in $fileName. No size on
>           server's 
> copy of file.
>           Check the path entered. $VAR{err}~;
>      }
> -------------------------------------------
> 
> i have written the comments with in the code above..as (%-------%).

Don't. Why make it harder for people to help you?


> So can one suggest me wat problem it can be,.

Learn about CGI in general. Read the posting guidelines for this group, 
and conform to them.

Sinan


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

Date: Tue, 08 Aug 2006 10:05:49 GMT
From: Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk>
Subject: Re: What bless() do actually?
Message-Id: <pan.2006.08.08.10.05.54.972128@webu.co.uk>

[snippetty snip]

>> You might do well to remember that classes are cleverly emulated in Perl
>> but don't actually exist (although I heard they might be available in a
>> later version)
> 
> What do you mean by that?
> 
> A Perl class is a (special case of a) package.  A package is a (special
> case of a) hash.  In what sense does the class not exist?
> 
> Anno

Sorry, for top-posting...

what I mean is that it's not the same as classes in C++...
yes classes can be emulated, but there's no class keyword (in perl5) to
create a class, new is a sub you need to write yourself instead of being a
keyword to instantiate a class and there are not private/public keywords.

Perl was never really an Object Oriented language, it's just that [select
members of] the perl community has been clever enough to emulate it...
compare this will C++ which was specifically designed as OO, or Java, VB,
etc.

The guy who wrote the original question, Davy, has come from a C++
background and seems to expect classes to exist in perl in the same way
they do in C++, but this simply isn't the case... perhaps
"declarative classes with strong encapsulation" are hard coded into perl6,
but most people are still on 5.8.8 or lower.

J



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

Date: 08 Aug 2006 05:55:33 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk>
Subject: Re: What bless() do actually?
Message-Id: <86d5bbfku2.fsf@blue.stonehenge.com>

>>>>> "Jimi-Carlo" == Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk> writes:

Jimi-Carlo> Perl was never really an Object Oriented language, it's just that [select
Jimi-Carlo> members of] the perl community has been clever enough to emulate it...
Jimi-Carlo> compare this will C++ which was specifically designed as OO, or Java, VB,
Jimi-Carlo> etc.

Oh, the irony of this statement!

Apparently, you're too young to know (or too old to remember) that C++ was
originally just a pre-processor for C, to see if C could support "objects"
without adding anything at all to the language.

In this sense, C++ is to C precisely what Perl5 is to Perl4.  It's *just* as
designed, it has just as much capability (I'd argue Perl5 has *more* OO
functionality than C++ because of the introspection) and it's just as usable.

Just because you don't type "c l a s s" in Perl5 doesn't mean you don't have
*true* classes.  Get off your high horse there.

Perl5 *is* OO.  Perl5 doesn't *emulate* OO.  Unless you also say that C++
"emulates" OO, in which case the term means nothing.

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: 8 Aug 2006 06:08:09 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: What bless() do actually?
Message-Id: <1155042489.742434.11040@h48g2000cwc.googlegroups.com>

Jimi-Carlo Bukowski-Wills wrote:
> what I mean is that it's not the same as classes in C++...
> yes classes can be emulated, but there's no class keyword (in perl5) to
> create a class, new is a sub you need to write yourself instead of being a
> keyword to instantiate a class and there are not private/public keywords.
>

This may be na=EFve, but isn't this akin to saying that since Perl
doesn't have the 'float' keyword, it doesn't have floating-point
values?  Or that since C doesn't have the 'sub' keyword, it doesn't
have subroutines?

Paul Lalli



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

Date: 8 Aug 2006 13:56:17 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: What bless() do actually?
Message-Id: <4jrjg1F9e3fvU1@news.dfncis.de>

Jimi-Carlo Bukowski-Wills  <jimi@webu.co.uk> wrote in comp.lang.perl.misc:
> [snippetty snip]
> 
> >> You might do well to remember that classes are cleverly emulated in Perl
> >> but don't actually exist (although I heard they might be available in a
> >> later version)
> > 
> > What do you mean by that?
> > 
> > A Perl class is a (special case of a) package.  A package is a (special
> > case of a) hash.  In what sense does the class not exist?
> > 
> > Anno
> 
> Sorry, for top-posting...
> 
> what I mean is that it's not the same as classes in C++...

Well, me no speakee C++, so the comparisons are somewhat lost on me.

> yes classes can be emulated, but there's no class keyword (in perl5) to
> create a class, new is a sub you need to write yourself instead of being a
> keyword to instantiate a class and there are not private/public keywords.
> 
> Perl was never really an Object Oriented language, it's just that [select
> members of] the perl community has been clever enough to emulate it...
> compare this will C++ which was specifically designed as OO, or Java, VB,
> etc.

It is true, OO is only minimally supported in Perl.  In fact, Larry Wall
has been quoted as saying it was an experiment in how little you can get
away with in an OO implementation.  There was perhaps little choice
than doing it minimally, given that Perl existed as a procedural
language and had to be kept compatible.

> The guy who wrote the original question, Davy, has come from a C++
> background and seems to expect classes to exist in perl in the same way
> they do in C++, but this simply isn't the case... perhaps
> "declarative classes with strong encapsulation" are hard coded into perl6,
> but most people are still on 5.8.8 or lower.

The view of OO you get through Perl is certainly different from the
one you get from dedicated OO languages, C++ or otherwise.  There is
a degree of freedom in just *how* you use Perl's OO features that 
is absent in dedicated languages.  Thus, the Exporter module elegantly
solves the problem "how to import the import() routine" by using
inheritance (and nothing else) from Perl's OO repertoire.  It can
hardly be called an OO module.

But freedom has its price.  Dealing with incompatible types of object
(hash, array, scalar, code, glob) is one of them.  Another (related)
one is lack of support for data inheritance.  The invention of
Inside-out objects is a recent progress in that area. Having to
invent parts of the mechanism would certainly come as a surprise
to users of a dedicated OO language.

Anno


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

Date: Tue, 08 Aug 2006 14:35:40 GMT
From: Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk>
Subject: Re: What bless() do actually?
Message-Id: <pan.2006.08.08.14.35.47.622576@webu.co.uk>

On Tue, 08 Aug 2006 13:56:17 +0000, anno4000 wrote:

> Jimi-Carlo Bukowski-Wills  <jimi@webu.co.uk> wrote in comp.lang.perl.misc:
>> [snippetty snip]
 [snippetty snip]
> It is true, OO is only minimally supported in Perl.  In fact, Larry Wall
[snippetty snip]
> But freedom has its price.  Dealing with incompatible types of object
> (hash, array, scalar, code, glob) is one of them.  Another (related)
> one is lack of support for data inheritance.  The invention of
> Inside-out objects is a recent progress in that area. Having to
> invent parts of the mechanism would certainly come as a surprise
> to users of a dedicated OO language.
> 
> Anno
I agree.
Davy must be wishing he'd never bothered with Perl now.
Hang in there Davy, it's worth it!  Perl is beautiful!



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

Date: Tue, 08 Aug 2006 14:39:50 GMT
From: Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk>
Subject: Re: What bless() do actually?
Message-Id: <pan.2006.08.08.14.39.58.55842@webu.co.uk>

On Tue, 08 Aug 2006 06:08:09 -0700, Paul Lalli wrote:

> Jimi-Carlo Bukowski-Wills wrote:
>> what I mean is that it's not the same as classes in C++...
>> yes classes can be emulated, but there's no class keyword (in perl5) to
>> create a class, new is a sub you need to write yourself instead of being a
>> keyword to instantiate a class and there are not private/public keywords.
>>
> 
> This may be naïve, but isn't this akin to saying that since Perl
> doesn't have the 'float' keyword, it doesn't have floating-point
> values?  Or that since C doesn't have the 'sub' keyword, it doesn't
> have subroutines?
> 
> Paul Lalli

Exactly!  "sub" in perl is like "function" in javascript... you can use it
to make named or anonymous subs and/or methods... a functionality which is
not available in c/c++.  And whilst we can work which floats in perl, what
we're actually working with is a compound scalar that could also be
interpreted as a string, without any work.  This makes it easy to send the
wrong data-type to a routine without testing the data or emulating the
float data-type using an object.

You are right!


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

Date: Tue, 08 Aug 2006 14:53:33 GMT
From: Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk>
Subject: Re: What bless() do actually?
Message-Id: <pan.2006.08.08.14.53.39.706932@webu.co.uk>

On Tue, 08 Aug 2006 05:55:33 -0700, Randal L. Schwartz wrote:

>>>>>> "Jimi-Carlo" == Jimi-Carlo Bukowski-Wills <jimi@webu.co.uk> writes:
> 
> Jimi-Carlo> Perl was never really an Object Oriented language, it's just that [select
> Jimi-Carlo> members of] the perl community has been clever enough to emulate it...
> Jimi-Carlo> compare this will C++ which was specifically designed as OO, or Java, VB,
> Jimi-Carlo> etc.
> 
> Oh, the irony of this statement!
Gulp!  [thinks: perhaps I've said something wrong]
> 
> Apparently, you're too young to know (or too old to remember) that C++ was
> originally just a pre-processor for C, to see if C could support "objects"
> without adding anything at all to the language.
I'm not really a C++ programmer, I just assumed it was OO... and I was
right.  I assumed that C++ was built on top of C... so... (your use of
the word originally implies that at one time I may have been correct, but
I'm now a dufus!  Sorry!)
> 
> In this sense, C++ is to C precisely what Perl5 is to Perl4.  It's
> *just* as designed, it has just as much capability (I'd argue Perl5 has
> *more* OO functionality than C++ because of the introspection) and it's
> just as usable.
 ...so yes, you're absolutely correct.
> 
> Just because you don't type "c l a s s" in Perl5 doesn't mean you don't
> have *true* classes.  Get off your high horse there.
But it doesn't alter the fact that a C++ programmer who understands about
classes and inheritance and all that is gonna get a wee bit confused when
he realises that he has to implement the "new" keyword himself.  Coming
from a C++ direction (or Java) this must seem really weird!
And if we have *true* classes then how come I need instantiate an object
as an anonymous hash to keep it's data private?  If that's not emulation,
it's certainly simulation!  Hardly the model of encapsulation...

> 
> Perl5 *is* OO.  Perl5 doesn't *emulate* OO.  Unless you also say that
> C++ "emulates" OO, in which case the term means nothing.

OK, this depends on how you want to define OO.  When you need to write
what basically amounts to a hack to get yourself to the same place that
any other OO language [that I've used] can get you to with a single
keyword, I think maybe it requires some explaining.

However, I apologise for my ignorance of C++ history.  I should probably
know better!

> 
> print "Just another Perl hacker,"; # the original
> 
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See
> PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



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

Date: 8 Aug 2006 07:33:32 -0700
From: yan.vulich@gmail.com
Subject: which file, regestry, environment variables do perl install
Message-Id: <1155047612.052327.193500@m79g2000cwm.googlegroups.com>

Hi, all!
Please help me to find out what perl installation do on my computer:
Which files does perl installation extract and where?
Is perl installation write something to regestry?
And if perl installation sets some environment variable?

Any help will be appreciate.

Thanks a lot.



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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