[18970] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1165 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 20 11:10:31 2001

Date: Wed, 20 Jun 2001 08:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993049812-v10-i1165@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 20 Jun 2001     Volume: 10 Number: 1165

Today's topics:
    Re: Removing ^M characters <somewhere@in.paradise.net>
    Re: Removing ^M characters (RJF)
        Salary for teaching intro to perl <tl082@yahoo.com>
    Re: Salary for teaching intro to perl <tl082@yahoo.com>
        simple reference question (sierra)
    Re: simple reference question <pne-news-20010620@newton.digitalspace.net>
    Re: simple reference question <tschmelter@statesman.com>
    Re: Unix - NT problems.... <tschmelter@statesman.com>
    Re: UserAgent <esheesley@mitre.org>
    Re: Why does this split not work? <nospam@cfl.rr.com>
    Re: Why does this split not work? <jurgenex@hotmail.com>
    Re: Why does this split not work? <ren@tivoli.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Jun 2001 21:44:41 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Removing ^M characters
Message-Id: <N20Y6.19$uy2.793612@news.interact.net.au>


"paul spandler" <p.m.spandler@bton.ac.uk> wrote in message
news:3B3052C9.E6963C49@bton.ac.uk...
>
> Failing that, sed works rather nicely too:
>
> cat infile | sed 's/.$//' > outfile

BING!  Even nicer without the UUOC

sed 's/.$//' infile >outfile





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

Date: 20 Jun 2001 07:44:14 -0700
From: rfrinder@fginfotech.com (RJF)
Subject: Re: Removing ^M characters
Message-Id: <7ba75fca.0106200644.3c9dfff5@posting.google.com>

Thahn, if this is in a file, I would use a sed to globaly replace the
^M characters with
nothing; i.e sed /^M//g or something like that or use dos2unix
conversion utility if available
supplied with some unix systems. It has been a while since I have used
UNIX but that is what I used to do.

Thanh Q Lam <thanh.q.lam@alcatel.com> wrote in message news:<3B26717D.BE551C2E@alcatel.com>...
> Does anyone know how to remove the "^M" characters at the end of each line which without
> removing uppercase M that may have in the same line in perl?
> 
> Examples:
> This is a book^M
> That is a Mango^M
> 
> If I use tr -d in unix which will remove all "M"
> 
> Result:
> This is a book
> That is a ango
> 
> 
> Your help will be very appreciated.
> 
> -Thanh


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

Date: Wed, 20 Jun 2001 10:31:50 -0400
From: "Allan Peda" <tl082@yahoo.com>
Subject: Salary for teaching intro to perl
Message-Id: <20010620.103148.480298490.1213@yahoo.com>

I am interested in teaching a basic perl class, say 20
hours, which I expect will cover references and possibly
some object oriented programming (just how to create an object).

OK, so perhaps 20 hours is not enough, but in any case, I was 
asked what this is worth salary wise.  Well here I am asking.

I am in the New York City area, and have been doing embedded perl
and DBI stuff (mixed with shell) on Linux, HP UX, and Sun.

What are reasonable salary numbers?

Thanks

Allan


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

Date: Wed, 20 Jun 2001 10:39:42 -0400
From: "Allan Peda" <tl082@yahoo.com>
Subject: Re: Salary for teaching intro to perl
Message-Id: <20010620.103942.1590079444.1213@yahoo.com>

I omitted that I have have about 3 years experience. oops

In article <20010620.103148.480298490.1213@yahoo.com>, "Allan Peda"
<tl082@yahoo.com> wrote:

>
> I am in the New York City area, and have been doing embedded perl and
> DBI stuff (mixed with shell) on Linux, HP UX, and Sun.
> 
> What are reasonable salary numbers?
>


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

Date: 20 Jun 2001 06:51:58 -0700
From: sierra@ecclectic.net (sierra)
Subject: simple reference question
Message-Id: <eb41cf6a.0106200551.4444d5b4@posting.google.com>

I'm writing a BOM program that relies on user input to call the
correct perl package for the product needed.  when i put code in
thusly (simplified for illustration)...

#! /usr/bin/perl -w
print "Enter product code\n";
$input = <STDIN>;
chomp $input;

use $input;
 
etc...

perl does not resolve to the .pm file corresponding to the user input.
 What symbology/syntax am i missing ?  This is running on RH Linux v.
6.2, perl 5.

thanks for any help... or smacking upside of the head, as it may be,
since i'm sure this is a simple problem i just can't see!

-s


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

Date: Wed, 20 Jun 2001 16:13:04 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: simple reference question
Message-Id: <rob1jtc5qnpg6dnbgaroo4rj0f06b5c752@4ax.com>

On 20 Jun 2001 06:51:58 -0700, sierra@ecclectic.net (sierra) wrote:

> use $input;

'use' works at compile time, while $input isn't filled until runtime.

Also, use requires a bareword. You might be able to use something like

    require "$input.pm";
    import $input;

to simulate the 'use', but this will not make available constants or
change prototypes.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 20 Jun 2001 14:58:50 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: simple reference question
Message-Id: <3B30BA55.D28B234D@statesman.com>

sierra wrote:

> I'm writing a BOM program that relies on user input to call the
> correct perl package for the product needed.  when i put code in
> thusly (simplified for illustration)...
>
> #! /usr/bin/perl -w
> print "Enter product code\n";
> $input = <STDIN>;
> chomp $input;
>
> use $input;
>
> etc...
>
> perl does not resolve to the .pm file corresponding to the user input.
>  What symbology/syntax am i missing ?  This is running on RH Linux v.
> 6.2, perl 5.
>
> thanks for any help... or smacking upside of the head, as it may be,
> since i'm sure this is a simple problem i just can't see!
>
> -s

$ perldoc -f use
       use Module VERSION

       use Module LIST

       use Module

       use VERSION
               Imports some semantics into the current package
               from the named module, generally by aliasing
               certain subroutine or variable names into your
               package.  It is exactly equivalent to

                   BEGIN { require Module; import Module LIST; }

<SNIP>
               The `BEGIN' forces the `require' and `import' to
               happen at compile time.  The `require' makes sure
               the module is loaded into memory if it hasn't been
               yet.  The `import' is not a builtin--it's just an
               ordinary static method call into the `Module'
               package to tell the module to import the list of
               features back into the current package.

So, you're wanting to do it runtime, not compile time, as specified by the
docs. Since the semantics of use are exactly equivalent to "BEGIN {...}",
the solution looks to be: remove the guts of the "BEGIN" block.

That's what it *looks* to be. In fact, read

perldoc -f require

and pay special attention to the bottom of the doc.

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951



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

Date: Wed, 20 Jun 2001 14:30:34 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: Unix - NT problems....
Message-Id: <3B30B3B8.1B8C441B@statesman.com>

Rajesha wrote:

> Hello,
>
> I'm working on a project in which my perl script has to search for
> particular keyword in a file (of size 2.9+ MB, 85000+ lines) & replace some
> data matching that keyword
> stored in array. On NT, i have installed ActivePerl version 5.003_07.
> Execution in this version takes only 3 minutes. But on Unix ( solaris os, I
> have perl version 5.005_03) same script is taking 20+ minutes.
>
> I'm using grep command to fetch/search the keywords from array/file. I guess
> that this grep is slowing the processing in UNIX. Why is this problem
> occurs? Is there any solution or alternate solution to solve my problem?
>
> I'm using following statements to fetch the data from file or array.
> I'm searching $var_label in global array.
>
>   @line_val=grep{/[\s]*$var_label/} @globaltypes::array_details;
>
>   #@line_val = grep{/[\s]*$var_label/} <MAPDATA>;
>
> I tried hash. Eventhough hash is faster in search, it is very slow in
> inserting the data into hash.
>
> Can anyone help me to make the code run faster in unix?

You need to decide what is slowing you down: search, replace, file access... If
you're slurping the entire 2.9MB file into memory, you may be paging out.

Really, though, 2.9 MB isn't that big a file. I run processes every night on my
linux box against a file with 60K-120K+ lines, ranging from 1.5-5.0 MB, and the
script takes about 20 seconds. That's slurping the file, running a bucket of
regex searches & replaces, and writing a formatted destination file.

I'd run a profile against it (it's written with good subroutines, right? :-), to
see where the script is spending the majority of its time.

perldoc Devel::DProf

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951




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

Date: Wed, 20 Jun 2001 10:21:12 -0400
From: Eric Sheesley <esheesley@mitre.org>
Subject: Re: UserAgent
Message-Id: <3B30B158.E5C7B2B3@mitre.org>

Thanks, I did.  I had never posted here so once i got the faq I found my
answer with no problem.  Thanks for the help.

Eric

brian d foy wrote:
> 
> In article <3B2E3D79.9743AF4F@mitre.org>, Eric Sheesley
> <esheesley@mitre.org> wrote:
> 
> > I am trying to run a perl script called checklink.pl downloaded from
> > validator.w3.org.  I can't seem to get it to work.  I got the latest
> > version of perl(perl 5.6.1) and compiled and installed it.  Still a no
> > go.  Where can I find this library or addon?
> 
> if you are missing a module, then you can most likely find it
> on CPAN.
> 
>     http://search.cpan.org
> 
> --
> brian d foy <comdog@panix.com>
> CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
> Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html


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

Date: Wed, 20 Jun 2001 10:55:07 GMT
From: tuxy <nospam@cfl.rr.com>
Subject: Re: Why does this split not work?
Message-Id: <3B3081D8.542D5237@cfl.rr.com>

Hmm sounds like I found a perl problem. I tried -d and it fails with
that message when I step over that line. I'll try to reduce the size f
the file and try again. I'll also try another box to see if its some
installation-specific problem.

Thanks!



Bob Walton wrote:
> 
> tuxy wrote:
> >
> > I'm trying to split a pretty large buffer (>1000 lines) into sections
> > based on a line that looks like
> >
> >         NAME Jane Doe
> >
> > The file is a series of name-values like
> >
> >         NAME Jane Doe
> >         AGE 21
> >         ADDRESS Anytown USA
> >         !
> >         NAME John Smith
> >            .
> >            .
> >
> > so I'm using something like
> >
> >    my @people=split /^\s*NAME\s+/m,$buf;
> >
> > and I'm getting very odd results. It consistently fails with this
> > message:
> >
> >    Use of uninitialized value in split at datax.pm line 447, <IN> line
> > 21 (#1)
> >
> > which I cannot comprehend. I checked perldoc perlfunc for split and
> > didn't see anything that looked like this problem discussed.  How could
> > something be "uninitialized"? $buf is definitely initialized since I
> > guess from the message it managed to get through 10 lines of it before
> > it failed. What could be "uninitialized" at line 10? Even empty lines
> > parse OK with /m.
> >
> > Another oddity- tweaking the code above this line (for unrelated tasks)
> > CHANGES the line this fails at- sometimes it says <IN> line 2, line 10,
> > 21, etc for the exact same input file. I looked at the file and see
> > nothing unusual on any of those lines. I also turned on diagnostics and
> > it didn't offer any further insight.
> >
> > By the way, the resultant array is one element which contains the entire
> > buffer, even though there are many lines that meet the regex criteria.
> 
> The regex and the split seem to work as you indicate you think it should
> in my tests.
> 
> The only way I can get your statement to fail with that message is for
> $buf to be undefined.  I suggest you put something like:
> 
>      die "Aha, buf is undef" unless defined $buf;
> 
> just ahead of your problem statement and see if you get the die.  If so,
> check your code to see how $buf got undef'ed.  Maybe perl -d would help.
> 
> ...
> --
> Bob Walton


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

Date: Wed, 20 Jun 2001 07:30:49 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why does this split not work?
Message-Id: <3b30b39a@news.microsoft.com>

"tuxy" <nospam@cfl.rr.com> wrote in message
news:3B2F8801.3473B055@cfl.rr.com...
> I'm trying to split a pretty large buffer (>1000 lines) into sections
> based on a line that looks like
>
[...]
>
> so I'm using something like
>
>    my @people=split /^\s*NAME\s+/m,$buf;
>
> and I'm getting very odd results. It consistently fails with this
> message:
>
>    Use of uninitialized value in split at datax.pm line 447, <IN> line
> 21 (#1)
>
> [...] $buf is definitely initialized since I
> guess from the message it managed to get through 10 lines of it before
> it failed. What could be "uninitialized" at line 10? Even empty lines
> parse OK with /m.
[...]
> By the way, the resultant array is one element which contains the entire
> buffer, even though there are many lines that meet the regex criteria.

Wait a second, what are you talking about? Is 'buf' an array or a scalar?
When you where talking about ">1000 lines" at the beginning I guessed those
lines where stored as elements of an array. And here at the end you mention
an array again.
On the other hand in the split you are referring to the scalar "$buf".

This is a wild guess but could that be the reason for your problem?

jue




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

Date: 19 Jun 2001 22:45:10 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Why does this split not work?
Message-Id: <m3lmmnak6x.fsf@dhcp9-173.support.tivoli.com>

On Wed, 20 Jun 2001, nospam@cfl.rr.com wrote:

> This doesn't occur in any loops, and I don't even have a filehandle
> named IN! Is this weird or what? Good suggestion though with the $/
> - I'll try it (But I shouldn't HAVE TO!)..

See if you can reproduce the problem outside of the larger context and
post the relevant code here.

-- 
Ren Maddox
ren@tivoli.com


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

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


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