[28994] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 238 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 19 18:10:31 2007

Date: Mon, 19 Mar 2007 15:09:14 -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           Mon, 19 Mar 2007     Volume: 11 Number: 238

Today's topics:
        A Perl Beginner <tochiunamka@gmail.com>
    Re: A Perl Beginner <jurgenex@hotmail.com>
    Re: A Perl Beginner usenet@DavidFilmer.com
    Re: A Perl Beginner <bik.mido@tiscalinet.it>
    Re: A Perl Beginner krakle@gmail.com
    Re: checking for filehandle anno4000@radom.zrz.tu-berlin.de
    Re: Demo of a shrinking perl script <DJStunks@gmail.com>
    Re: Demo of a shrinking perl script xhoster@gmail.com
    Re: Demo of a shrinking perl script <hjp-usenet2@hjp.at>
        Does using dbmopen/tie make programs memory-efficient? <hjs@cadence.com>
    Re: Does using dbmopen/tie make programs memory-efficie anno4000@radom.zrz.tu-berlin.de
    Re: Does using dbmopen/tie make programs memory-efficie <glex_no-spam@qwest-spam-no.invalid>
        eval or do for <DATA> <henry.townsend@not.here>
    Re: eval or do for <DATA> <uri@stemsystems.com>
    Re: Find Missing Column and Extra Column <glex_no-spam@qwest-spam-no.invalid>
    Re: I dotn understand this error <hackeras@gmail.com>
    Re: I dotn understand this error <hackeras@gmail.com>
    Re: I dotn understand this error <wahab-mail@gmx.de>
    Re: I dotn understand this error krakle@gmail.com
    Re: I dotn understand this error anno4000@radom.zrz.tu-berlin.de
        regex question eldwindollente@gmail.com
    Re: regex question <jurgenex@hotmail.com>
    Re: regex question <wahab-mail@gmx.de>
    Re: regex question <hjp-usenet2@hjp.at>
    Re: regex question <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Mar 2007 07:39:54 -0700
From: "The light" <tochiunamka@gmail.com>
Subject: A Perl Beginner
Message-Id: <1174315194.575442.128730@l77g2000hsb.googlegroups.com>

I wish to use Perl with a page i designed with Front page.What will be
best
way to start?



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

Date: Mon, 19 Mar 2007 15:22:08 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: A Perl Beginner
Message-Id: <AUxLh.8588$282.923@trndny04>

The light wrote:

Hi The

> I wish to use Perl with a page i designed with Front page.What will be
> best
> way to start?

Perl is a universal programming language. It does not have pages. Frontpage 
is a web page editor and web site publishing system. Those two have about 
nothing in common.
Your question is like "I wish to use English for a newspaper that I designed 
with a pencil. What would be the best way to start".

Maybe you should take a few steps back and reevaluate what it really is that 
you trying to do.

As far as Perl itself is concerned: Because you mentioned Frontpage you are 
probably using a Windows-based system. Therefore I suggest to go to 
activestate.com und just install their ActivePerl system (it's free, 
although you have to dig a bit for the free version). And then run the 
build-in help "perldoc -q books" to check for suggestions on helpful books.

Of course, this will get you started with Perl. It has nothing to do with 
pages or Frontpage or ...

jue 




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

Date: 19 Mar 2007 09:37:06 -0700
From: usenet@DavidFilmer.com
Subject: Re: A Perl Beginner
Message-Id: <1174322226.470131.73080@d57g2000hsg.googlegroups.com>

On Mar 19, 7:39 am, "The light" <tochiuna...@gmail.com> wrote:
> What will be best way to start?

http://learn.perl.org

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)





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

Date: Mon, 19 Mar 2007 18:06:17 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A Perl Beginner
Message-Id: <9kgtv25a1kjap7o88tidg626tjn7ms9ta9@4ax.com>

On Mon, 19 Mar 2007 15:22:08 GMT, "Jrgen Exner"
<jurgenex@hotmail.com> wrote:

>probably using a Windows-based system. Therefore I suggest to go to 
>activestate.com und just install their ActivePerl system (it's free, 
>although you have to dig a bit for the free version). And then run the 

Not too much: it's at
<http://www.activestate.com/Products/ActivePerl/> anyway. (Also it's
not "the free version", because there's only one version, which
happens to be free. AIUI they sell development tools, but the language
i.e. AP is the same.)


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: 19 Mar 2007 10:20:06 -0700
From: krakle@gmail.com
Subject: Re: A Perl Beginner
Message-Id: <1174324806.796695.300050@e65g2000hsc.googlegroups.com>

On Mar 19, 8:39 am, "The light" <tochiuna...@gmail.com> wrote:
> I wish to use Perl with a page i designed with Front page.What will be
> best
> way to start?

It sounds to me like you want to use Perl as a CGI script. Front Page
produces a generated HTML document. You can't use Perl in an HTML
document (with exception of Mason and other embedded Perl
technologies). You can use HTML inside of a Perl script to output HTML
code. To do this you will need to familiarize yourself with CGI and
also read up on the CGI.pm module.

ie:

#!/usr/bin/perl -w

use strict;
use warnings;

use CGI;

my cgi = new CGI;

print $cgi->header("text/html");

print <<End_Html;
<html>
  <head>
    <title>HTML Document</title>
  </head>

  <body bgcolor="#ffffff" text="#000000">
    <h1>HTML Document</h1>
    <hr>
    This is a basic CGI script.
  </body>
</html>

End_Html

__END__


Basically, you're just outputting a header and HTML code for the
browser to read. And obviously you need to use a web server for your
script to actually run as a CGI.



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

Date: 19 Mar 2007 14:13:04 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: checking for filehandle
Message-Id: <567k3gF277gh9U1@mid.dfncis.de>

Yakov <iler.ml@gmail.com> wrote in comp.lang.perl.misc:
> On Mar 19, 7:23 am, anno4...@radom.zrz.tu-berlin.de wrote:
> > Yakov <iler...@gmail.com> wrote in comp.lang.perl.misc:
> >
> > > Let's say I want to check whether $fh is a filehandle. Take 1
> > > is to: defined(fileno($fh)). Perfect solution ? No. When $fh is a
> > > tied-filehandle, $fh may not have real filedescriptor behind it
> > > ( for example, it sends output to the shared memory ).
> >
> > > How do I check for $fh being a  filehandle, the check  would work
> > > even for tied filehandles  that do not have real filedescriptor ?
> >
> > In general it is hard to say for sure what a tied variable will respond
> > to.  You can use tied() to access the underlying object and make
> > plausibility tests:
> >
> >     my $is_fh = tied( $h) && tied( $h)->isa( 'File::Handle');
> >
> > or
> >
> >     my $is_fh = tied( $h) && tied( $h)->can( 'READ');
> >
> > or similar.  Both can go wrong, but will give the correct answer in most
> > cases.
> 
> Ok thanks. This seems to be the check:
> 
>    defined(fileno($fh)) || (tied( $fh) && tied($fh)-
> >can( 'TIEHANDLE' ))
> 
> Looks ok ?

Yes.  In fact, testing for "TIEHANDLE" should be pretty much watertight.

Anno


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

Date: 19 Mar 2007 07:07:34 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Demo of a shrinking perl script
Message-Id: <1174313254.408992.200080@p15g2000hsd.googlegroups.com>

On Mar 18, 10:19 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> Some time ago we had a discussion about the FAQ "How can I free an array
> or hash so my program shrinks?". I claimed that on Linux and other OSs
> with modern malloc implementations (probably BSDs including MacOS and
> Windows) perl can and does return memory to the OS, but couldn't come up
> with an example. Now I found one:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> sub a {
>     print "a\tcall\t", vm(), "\n";
>     my $h;
>     for ('a' .. 'z') {
>         $h->{$_} = $_ x 1_000_000;
>     }
>     print "a\treturn\t", vm(), "\n";
>     return $h;
>
> }
>
> sub c {
>     print "c\tcall\t", vm(), "\n";
>     a();
>     print "c\treturn\t", vm(), "\n";
>
> }
>
> c();
>
> sub vm {
>     open(my $fh, '<', "/proc/$$/status");
>     while (<$fh>) {
>         chomp;
>         return $_ if (/^VmSize:/);
>     }}
>
> __END__
>
> On my Linux box, this prints:
>
> c       call    VmSize:     5056 kB
> a       call    VmSize:     5056 kB
> a       return  VmSize:    31516 kB
> c       return  VmSize:     6036 kB
>
> demonstrating that the process grows by roughly 26 MB as the anonymous
> hash is created and then shrinks again when the reference to it goes out
> of scope. This also works with a simple hash or array.

So it shrinks, but leaks memory?

I'm also not clear why you return the hash ref $h from a(), but call
a() from void context.  Perhaps this is the source of the memory
leak.  I'm not on linux at the moment or I'd try it myself.

-jp



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

Date: 19 Mar 2007 16:23:52 GMT
From: xhoster@gmail.com
Subject: Re: Demo of a shrinking perl script
Message-Id: <20070319122353.874$33@newsreader.com>

"DJ Stunks" <DJStunks@gmail.com> wrote:
 ...
> >
> > On my Linux box, this prints:
> >
> > c       call    VmSize:     5056 kB
> > a       call    VmSize:     5056 kB
> > a       return  VmSize:    31516 kB
> > c       return  VmSize:     6036 kB
> >
> > demonstrating that the process grows by roughly 26 MB as the anonymous
> > hash is created and then shrinks again when the reference to it goes
> > out of scope. This also works with a simple hash or array.
>
> So it shrinks, but leaks memory?

While a single instance of shrinking is enough to say that it can indeed
shrink, a single increase in memory does not make a leak.  That extra
memory can perhaps be reused later and so is not lost.  And if you call c()
in a loop, you will see that this is in fact true--no leak.

c       call    VmSize:     9980 kB
a       call    VmSize:     9980 kB
a       return  VmSize:    36440 kB
c       return  VmSize:    10960 kB
c       call    VmSize:    10960 kB
a       call    VmSize:    10960 kB
a       return  VmSize:    36440 kB
c       return  VmSize:    10960 kB
c       call    VmSize:    10960 kB
a       call    VmSize:    10960 kB
a       return  VmSize:    36440 kB
c       return  VmSize:    10960 kB

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 19 Mar 2007 17:18:07 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Demo of a shrinking perl script
Message-Id: <slrnevtdtv.d9q.hjp-usenet2@yoyo.hjp.at>

On 2007-03-19 14:07, DJ Stunks <DJStunks@gmail.com> wrote:
> On Mar 18, 10:19 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> Some time ago we had a discussion about the FAQ "How can I free an array
>> or hash so my program shrinks?". I claimed that on Linux and other OSs
>> with modern malloc implementations (probably BSDs including MacOS and
>> Windows) perl can and does return memory to the OS, but couldn't come up
>> with an example. Now I found one:
>>
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>>
>> sub a {
>>     print "a\tcall\t", vm(), "\n";
>>     my $h;
>>     for ('a' .. 'z') {
>>         $h->{$_} = $_ x 1_000_000;
>>     }
>>     print "a\treturn\t", vm(), "\n";
>>     return $h;
>>
>> }
>>
>> sub c {
>>     print "c\tcall\t", vm(), "\n";
>>     a();
>>     print "c\treturn\t", vm(), "\n";
>>
>> }
>>
>> c();
[...]
>> On my Linux box, this prints:
>>
>> c       call    VmSize:     5056 kB
>> a       call    VmSize:     5056 kB
>> a       return  VmSize:    31516 kB
>> c       return  VmSize:     6036 kB
>>
>> demonstrating that the process grows by roughly 26 MB as the anonymous
>> hash is created and then shrinks again when the reference to it goes out
>> of scope. This also works with a simple hash or array.
>
> So it shrinks, but leaks memory?
>
> I'm also not clear why you return the hash ref $h from a(), but call
> a() from void context.

Leftover from an earlier version of the test program. There used to be
an intermediate sub b, but that turned out not to be necessary.

> Perhaps this is the source of the memory leak.

I think the "leak" is an internal buffer used to construct
"$_ x 1_000_000" which is kept around just in case a() is called again
(it's 1_000_000 rounded up to the next page size, and if you do an strace
of the program you can see that it allocates *27* memory regions of that
size, although the hash contains only 26 entries (and when the hash is
destroyed only 26 are freed).

	hp



-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: Mon, 19 Mar 2007 11:48:54 -0700
From: Henry Salvia <hjs@cadence.com>
Subject: Does using dbmopen/tie make programs memory-efficient?
Message-Id: <45FEDB16.77D960ED@cadence.com>

I have inherited a script that uses dbmopen to create a hash that holds
up to
500,000 keys. Does use of dbmopen (or tie) make a script use less memory
or
provide any other efficiency, or is it just the persistence of the data
that
adds value? How would I go about measuring (on UNIX) memory usage
between using
dbmopen/tie and not? The docs for dbmopen and tie don't talk about
memory
use or efficency that I can find.
Thanks.
Henry Salvia


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

Date: 19 Mar 2007 19:01:09 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Does using dbmopen/tie make programs memory-efficient?
Message-Id: <5684vlF288d10U1@mid.dfncis.de>

Henry Salvia  <hjs@cadence.com> wrote in comp.lang.perl.misc:

[please keep your line length below 72]

> I have inherited a script that uses dbmopen to create a hash that holds
> up to
> 500,000 keys. Does use of dbmopen (or tie) make a script use less memory
> or

dbmopen() is deprecated.  You should use tie() instead. 

> provide any other efficiency, or is it just the persistence of the data
> that

It's often the primary purpose of DB_File (or whatever) to remove
a large hash from memory and keep it on disk.  Persistence is another.

> adds value? How would I go about measuring (on UNIX) memory usage
> between using
> dbmopen/tie and not? The docs for dbmopen and tie don't talk about
> memory
> use or efficency that I can find.

For coarse comparisons, follow the process(es) with ps and look at
their storage consumption.

Anno


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

Date: Mon, 19 Mar 2007 13:59:29 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Does using dbmopen/tie make programs memory-efficient?
Message-Id: <45feeba1$0$513$815e3792@news.qwest.net>

Henry Salvia wrote:
> I have inherited a script that uses dbmopen to create a hash that holds
> up to
> 500,000 keys. Does use of dbmopen (or tie) make a script use less memory

Compared to what?

> or
> provide any other efficiency, or is it just the persistence of the data
> that
> adds value? How would I go about measuring (on UNIX) memory usage
> between using dbmopen/tie and not? 

Write something that doesn't use it and compare it.


 >The docs for dbmopen and tie don't talk about
> memory use or efficency that I can find.

It uses much less memory, compared to reading the data into a hash.


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

Date: Mon, 19 Mar 2007 16:59:14 -0400
From: Henry Townsend <henry.townsend@not.here>
Subject: eval or do for <DATA>
Message-Id: <C7ednQxjyt44ZGPYnZ2dnUVZ_vWtnZ2d@comcast.com>

I have an irritating little problem - I have a hash (generated by 
Data::Dumper) underneath a __DATA__ token and want the script to 'do' 
it. E.g. something like this (freehand):

my $hash = do <DATA>;
__DATA__
(Data::Dumper output)

But unfortunately according to "perldoc -f do" it's only defined to 
operate on a file name, not a file handle. I really don't want to store 
the data in a separate file. Does anyone know a way to drag this stuff 
in as if it was in a separate file and I could use "do 'filename'"?

Thanks,
HT


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

Date: Mon, 19 Mar 2007 17:08:22 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: eval or do for <DATA>
Message-Id: <x78xdsvqcp.fsf@mail.sysarch.com>

>>>>> "HT" == Henry Townsend <henry.townsend@not.here> writes:

  HT> I have an irritating little problem - I have a hash (generated by
  HT> Data::Dumper) underneath a __DATA__ token and want the script to 'do'
  HT> it. E.g. something like this (freehand):

  HT> my $hash = do <DATA>;
  HT> __DATA__

  HT> But unfortunately according to "perldoc -f do" it's only defined to
  HT> operate on a file name, not a file handle. I really don't want to
  HT> store the data in a separate file. Does anyone know a way to drag this
  HT> stuff in as if it was in a separate file and I could use "do
  HT> 'filename'"?

so you put eval in the subject. why did you do that? all do does is
slurp in the file and run eval. so apply the same concept to the DATA
handle. you can slurp it yourself by setting $/ to undef (best in a
local) or use File::Slurp:

use File::Slurp ;

my %hash = eval read_file \*DATA ;

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: Mon, 19 Mar 2007 12:48:36 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Find Missing Column and Extra Column
Message-Id: <45fedb04$0$497$815e3792@news.qwest.net>

Rahul wrote:

> I am getting "Unrecognised option: ForceArray at cellcount.pl line
> 27". I have installed XML:Simple. What is the reason for this errors?

How the heck is anyone supposed to know, without any code?

If you're following the documented way of using XML::Simple, then you 
must have an error around line 27.


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

Date: 19 Mar 2007 13:10:12 -0700
From: "=?utf-8?B?zp3Or866zr/Pgg==?=" <hackeras@gmail.com>
Subject: Re: I dotn understand this error
Message-Id: <1174335012.256116.151210@n76g2000hsh.googlegroups.com>


Yakov wrote:
> On Mar 19, 5:58 am, "=CE=9D=CE=AF=CE=BA=CE=BF=CF=82" <hacke...@gmail.com>=
 wrote:
> > Wehn i try to run my script i get this error:
> >
> > [Mon Mar 19 11:49:06 2007] index.pl: Use of uninitialized value in
> > concatenation (.) or string at (eval 17) line 43. Content-Type: text/
> > html; charset=3Dutf-8
> >
> > i llok at line 43 but cant un derstand what the problem.
> [snip]
> > Do you see anything wrong?
>
> Which line is line 43 ?


I opened index.pl with notepad and saw that line 43 is an empty line
between

my $passage =3D param('select') || "=C3=8E=E2=80=98=C3=8F=C2=81=C3=8F=E2=80=
=A1=C3=8E=C2=B9=C3=8E=C2=BA=C3=8E=C2=AE =C3=8E=C2=A3=C3=8E=C2=B5=C3=8E=C2=
=BB=C3=8E=C2=AF=C3=8E=C2=B4=C3=8E=C2=B1!";
        <=3D this one
if ( param('select') )

An empty line? i dont understand.
also i dotn understand what eval 17 is supposed to mean.



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

Date: 19 Mar 2007 13:14:58 -0700
From: "=?utf-8?B?zp3Or866zr/Pgg==?=" <hackeras@gmail.com>
Subject: Re: I dotn understand this error
Message-Id: <1174335298.681472.198130@p15g2000hsd.googlegroups.com>


anno4000@radom.zrz.tu-berlin.de wrote:
> Yakov <iler.ml@gmail.com> wrote in comp.lang.perl.misc:
> > On Mar 19, 5:58 am, "=CE=9D=CE=AF=CE=BA=CE=BF=CF=82" <hacke...@gmail.co=
m> wrote:
> > > Wehn i try to run my script i get this error:
> > >
> > > [Mon Mar 19 11:49:06 2007] index.pl: Use of uninitialized value in
> > > concatenation (.) or string at (eval 17) line 43. Content-Type: text/
> > > html; charset=3Dutf-8
> > >
> > > i llok at line 43 but cant un derstand what the problem.
> > [snip]
> > > Do you see anything wrong?
> >
> > Which line is line 43 ?
>
> None of the code lines.  It's line 43 of eval 17.

This is what i dont understand... when i see line 43 i opne index.pl
and look at line 43 but this isnt the problem line as it seems....

Can you plz explain?



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

Date: Mon, 19 Mar 2007 21:19:24 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: I dotn understand this error
Message-Id: <etmriq$mfd$1@mlucom4.urz.uni-halle.de>

Νίκος wrote:
> my $passage = param('select') || "Ã�â��Ã�Â�Ã�â�ḂÃ�ÂṗÃ�ÂẃÃ�® Ã�£Ã�ÂṁÃ�ÂṠÃ�ŸÃ�ÂṀÃ�Âḟ!";
>         <= this one

    Bareword found where operator expected at nikostest.pl line 1,
    near """Ã" Missing operator before Ã?)

Your "string" (what encoding is this anyway) gets interpreted
and bails. What's the purpose of this string and why would
you put it in ""'s

Regards

M.


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

Date: 19 Mar 2007 14:27:33 -0700
From: krakle@gmail.com
Subject: Re: I dotn understand this error
Message-Id: <1174339653.490251.146160@l75g2000hse.googlegroups.com>

On Mar 19, 2:10 pm, "=CE=9D=CE=AF=CE=BA=CE=BF=CF=82" <hacke...@gmail.com> w=
rote:
> I opened index.pl with notepad

You use notepad?

> An empty line? i dont understand.

You are using an undefined variable. It's a warning. Example:

my $fatcat =3D "Milo"; # Look defined scalar!

if ($fatcar eq "Milo") { ... } # Using a defined scalar


my $fatdog; # Look a scalar with no value (undef)

if ($fatdog eq "Pepper") { ... } # Using an UNdefined scalar


You only receive that WARNING when you are trying to use a variable
that is undefined...

Do realise that a value of NOTHING is still SOMETHING that can be used
but an undefined variable is the value of NOTHING that can't be
used. :-P




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

Date: 19 Mar 2007 21:41:33 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: I dotn understand this error
Message-Id: <568ecdF2733gaU1@mid.dfncis.de>

 ίκο  <hackeras@gmail.com> wrote in comp.lang.perl.misc:
> 
> anno4000@radom.zrz.tu-berlin.de wrote:
> > Yakov <iler.ml@gmail.com> wrote in comp.lang.perl.misc:
> > > On Mar 19, 5:58 am, "Νίκος" <hacke...@gmail.com> wrote:
> > > > Wehn i try to run my script i get this error:
> > > >
> > > > [Mon Mar 19 11:49:06 2007] index.pl: Use of uninitialized value in
> > > > concatenation (.) or string at (eval 17) line 43. Content-Type: text/
> > > > html; charset=utf-8
> > > >
> > > > i llok at line 43 but cant un derstand what the problem.
> > > [snip]
> > > > Do you see anything wrong?
> > >
> > > Which line is line 43 ?
> >
> > None of the code lines.  It's line 43 of eval 17.
> 
> This is what i dont understand... when i see line 43 i opne index.pl
> and look at line 43 but this isnt the problem line as it seems....
> 
> Can you plz explain?

Please use complete English words.

It means the offending line isn't in the source code.

Some part of the source is compiled and/or run as a string eval.  That
means, a Perl program is built in a string and immediately compiled
and executed by the eval() function (perldoc -f eval).  A warning was
generated in that process, in line 43 of the eval'ed program.  The
other thing the message tells you is it was the 17th (string-) eval
during the run of the program.

Unfortunately, nothing more can be concluded from the error message.

BTW, that's another reason to avoid string eval if possible.

Anno


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

Date: 19 Mar 2007 10:22:07 -0700
From: eldwindollente@gmail.com
Subject: regex question
Message-Id: <1174324927.915515.177410@o5g2000hsb.googlegroups.com>

Hi all,

I'm new to regex. I have a string of 32 characters and i need to
ignore the first 28 characters, change the next 2 (29, 30) and ignore
the last 2 (31,32.)

I have something like this so far s/AD01.{28}/xx/  but that's just
changing the 28 characters to XX.

Any help would be appreciated.

Thanks



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

Date: Mon, 19 Mar 2007 17:30:21 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: regex question
Message-Id: <NMzLh.5551$DX5.1490@trndny06>

eldwindollente@gmail.com wrote:
> I'm new to regex. I have a string of 32 characters and i need to
> ignore the first 28 characters, change the next 2 (29, 30) and ignore
> the last 2 (31,32.)

Why do you want to use regular expressions for this task?

> I have something like this so far s/AD01.{28}/xx/  but that's just
> changing the 28 characters to XX.
>
> Any help would be appreciated.

What about a simple

    my $s = '12345678901234567890123456789012';
    substr($s, 28, 2, 'XY');
    print $s;

jue




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

Date: Mon, 19 Mar 2007 20:41:39 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: regex question
Message-Id: <etmpc1$lrl$1@mlucom4.urz.uni-halle.de>

eldwindollente@gmail.com wrote:
> Hi all,
> 
> I'm new to regex. I have a string of 32 characters and i need to
> ignore the first 28 characters, change the next 2 (29, 30) and ignore
> the last 2 (31,32.)
> 
> I have something like this so far s/AD01.{28}/xx/  but that's just
> changing the 28 characters to XX.

Jrgen already wrote the appropriate solution
and I'll add the regex here (in case of ...)

Lets start with a 32 char string of alternating slashes:

     my $string = '\/\/' x 8;  # 32 characters ('x' repeats 'wave')

To replace string[28->29], we could do a:

     $string =~ s/ (?<=.{28}) .. /XX/x;

which means:

    ..           ==> replace 2 characters

    (?<=.{28})   ==>  if exactly 28 characters are in front of them



Another possibility would be to
set the next match position explicitly:

     ...
     my $string = '\/\/' x 8; # 32 characters (repeats 'wave')

     pos($string) = 28;       # set match position
     $string =~ s/\G../XX/x;  # change 2 characters there
     ...

pos(x) sets the next regex trial position
and \G anchor forces the regex to appreciate it.


Regards

Mirco


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

Date: Mon, 19 Mar 2007 20:39:41 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: regex question
Message-Id: <slrnevtpnt.i6j.hjp-usenet2@yoyo.hjp.at>

On 2007-03-19 17:30, Jürgen Exner <jurgenex@hotmail.com> wrote:
> eldwindollente@gmail.com wrote:
>> I'm new to regex. I have a string of 32 characters and i need to
>> ignore the first 28 characters, change the next 2 (29, 30) and ignore
>> the last 2 (31,32.)
[...]
> What about a simple
>
>     my $s = '12345678901234567890123456789012';
>     substr($s, 28, 2, 'XY');

Or:

      substr($s, 28, 2) = 'XY';

>     print $s;

	hp

-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: Mon, 19 Mar 2007 14:55:40 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: regex question
Message-Id: <x7wt1duhxf.fsf@mail.sysarch.com>

>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:

  PJH> On 2007-03-19 17:30, Jrgen Exner <jurgenex@hotmail.com> wrote:
  >> eldwindollente@gmail.com wrote:
  >>> I'm new to regex. I have a string of 32 characters and i need to
  >>> ignore the first 28 characters, change the next 2 (29, 30) and ignore
  >>> the last 2 (31,32.)
  PJH> [...]
  >> What about a simple
  >> 
  >> my $s = '12345678901234567890123456789012';
  >> substr($s, 28, 2, 'XY');

  PJH> Or:

  PJH>       substr($s, 28, 2) = 'XY';

4 arg substr is faster than lvalue substr and noticeably so the last
time i checked. it makes sense as 4 arg substr is one internal perl op
but lvalue substr needs to make a substr ref thing and then overwrite it
with the assignment. it has at least 2 op calls there vs 1 for 4 arg
substr. a deparse would probably show this too.

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: 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 V11 Issue 238
**************************************


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