[16625] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4037 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 16 21:05:29 2000

Date: Wed, 16 Aug 2000 18:05:14 -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: <966474314-v9-i4037@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 16 Aug 2000     Volume: 9 Number: 4037

Today's topics:
    Re: active perl and xitami metza@my-deja.com
    Re: archive of perl scripts (Abigail)
    Re: Array Printing <elephant@squirrelgroup.com>
    Re: Array Printing <elephant@squirrelgroup.com>
        Articles, Stories ... <joeb@jagas.demon.co.uk>
        August Denver Perl Mongers meeting (Chris Fedde)
    Re: Can I use perl for automated builds? (Abigail)
    Re: Can I use perl for automated builds? (Mark-Jason Dominus)
    Re: Certain Items in a string (Keith Calvert Ivey)
    Re: Certain Items in a string <elephant@squirrelgroup.com>
        cross platform newline processing <MarkAJohnson@yahoo.com>
    Re: date and time in perl <elephant@squirrelgroup.com>
        FileHandle in array <ceeeya@my-deja.com>
    Re: Grabbing ALL parameters in a cgi script <wyzelli@yahoo.com>
    Re: Grabbing ALL parameters in a cgi script <godzilla@stomp.stomp.tokyo>
    Re: How to know if a scalar contain string or numeric d ()
    Re: Image Manipulation Question (Logan Shaw)
    Re: Listing users in Win NT <elephant@squirrelgroup.com>
        OT: newsreaders and Microsoft [was: Perl code for a new <elephant@squirrelgroup.com>
    Re: Perl Newbie trying to parse file <elephant@squirrelgroup.com>
    Re: PERLXS Samples Please (Logan Shaw)
    Re: Replacing lines in a file (Abigail)
        sorting ?? pape_98@my-deja.com
    Re: sorting ?? <stephenk@cc.gatech.edu>
        Unix Perl to OpenVMS Perl <sbishop@mincom.com>
        Useful perl macros for Developer Studio (Thomas Brusca)
    Re: windows headache <jeff@vpservices.com>
    Re: windows headache <yhvhboy1@home.com>
    Re: windows headache: make <yhvhboy1@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 16 Aug 2000 23:07:32 GMT
From: metza@my-deja.com
Subject: Re: active perl and xitami
Message-Id: <8nf6r6$em$1@nnrp1.deja.com>

ok, thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Aug 2000 23:39:02 GMT
From: abigail@foad.org (Abigail)
Subject: Re: archive of perl scripts
Message-Id: <slrn8pm9fi.tj3.abigail@alexandra.foad.org>

Nick Condon (nickco3@yahoo.co.uk) wrote on MMDXLII September MCMXCIII in
<URL:news:399AA768.18653548@yahoo.co.uk>:
:} John A Timmons wrote:
:} 
:} > I'm learning perl as my first language. I'm looking for an archive of
:} > perl scripts of varying difficulty that are well documented.
:} >
:} > I am in the process of reading some good books on the language but I
:} > seem to have this brain that learns best through example.
:} >
:} > Thank you,
:} >
:} > Jack
:} 
:} The Comprehensive Perl Archive Network has lots of scripts and an
:} unimaginably vast collection of modules. CPAN is primarily an archive of
:} real-world scripts rather than teaching examples so they can be pretty
:} complex, but the documentation is always excellent. Anyway you'll find it
:} here: http://www.cpan.org
:} 
:} I learn best from example too, and my most used Perl guide is O'Reilly's
:} "Perl Cookbook". It gets mixed reviews from the Perl community at large,
:} but it is by far the best suited to my learning style (and I've read
:} quite a few).


While the Cookbook is a good Perl book, I find that the book I used most
in my Perl programming is 'Advanced Programming in the Unix Environment',
followed by 'Introduction to Algorithms'.

The only Perl book I might consult during programming is 'Learning Perl/Tk'.

The manuals on the other hand, I consult all the time.


Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Wed, 16 Aug 2000 23:13:44 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Array Printing
Message-Id: <MPG.1405bd95fed301c09896b1@localhost>

Gwyn Judd wrote ..
>I was shocked! How could Logan Shaw <logan@cs.utexas.edu>
>say such a terrible thing:
>>In article <39984B9A.CDA18AE0@attglobal.net>,
>>Drew Simonis  <care227@attglobal.net> wrote:
>>>marxjkj123@my-deja.com wrote:
>>>> for ($x = 0; $x < @block; $x++){
>>>>                 print $block[$x],"\n";
>>>>         }
>>>> 
>>>
>>>the above is better written as:
>>>
>>>for (@block)
>>>{
>>>	print;
>>>}
>>
>>Or,
>>
>>	print @block;
>>
>>Or, to add the newlines:
>>
>>	print map ("$_\n", @block);
>
>Or even:
>
>$, = "\n";
>print @block;

eek .. please - never pass up a genuine opportunity to use 'local'

  {
    local $, = "\n";
    print @block;
  }

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 16 Aug 2000 23:19:35 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Array Printing
Message-Id: <MPG.1405bef5774203c59896b2@localhost>

lee taggard ayres wrote ..
>marxjkj123@my-deja.com writes:
>
>> @block
>> = "e:/WEBLOGIC/Local/ejb_basic_containerManaged.ja
>> r, \
>> e:/weblogic/Local/ejb_basic_statelessSession.jar,
>> \";
>
>What you expect to be the contents of block is being treated as a single
>string and the backslash at the end escapes the second quote.
>
>Backslashes have a special meaning in perl Strings (as they do in many
>languages). The backslash 'escapes' the meaning of the charater the precede.
>To include the backslashes, you need to escape them.  This is a matter
>of adding another backslash, so a string with a single backslash in it
>looks like this. "\\".
>
>Might I recomend the following code block to get the results you seem to
>be looking for.
>
>
>@block = ("e:/WEBLOGIC/Local/ejb_basic_containerManaged.ja",
>	  "\\",
>	  "e:/weblogic/Local/ejb_basic_statelessSession.jar",
>	  "\\");

or even

  @block = qw( e:/WEBLOGIC/Local/ejb_basic_containerManaged.jar
               \
               e:/weblogic/Local/ejb_basic_statelessSession.jar
               \
             );

no double-backwacks and no messy double quotes .. my WTDI would be

#!/usr/bin/perl -w
use strict;

my @block = qw( e:/WEBLOGIC/Local/ejb_basic_containerManaged.jar
                \
                e:/weblogic/Local/ejb_basic_statelessSession.jar
                \
              );

{
  local $, = "\n";
  print @block;
}

__END__

of course that still doesn't answer the question that the originator's 
post raises of what sort of translation was expected from the 
backslashes

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 16 Aug 2000 23:33:05 +0100
From: JoeB <joeb@jagas.demon.co.uk>
Subject: Articles, Stories ...
Message-Id: <399B16A1.A97BC87A@jagas.demon.co.uk>

Hello,

Being fed up with some of the in-adequacies of printed magazines etc...
I have decided to publish
a magazine, which will hopefully fill the gap left by the big publishing
houses. As a result, I am looking
for stories, articles about PERL that will make a good read for the
techie or for the beginner or a
decision maker. If you feel you have something to say or share with
others, then please
let me have your story etc... of course full credits will be given to
you in the publication.


Many Thanks,




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

Date: Thu, 17 Aug 2000 00:18:55 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: August Denver Perl Mongers meeting
Message-Id: <PbGm5.353$P1k.193576960@news.frii.net>

Come one, come all, to the August Perl Mongers meeting.

Where:  

        Dave & Busters
        I-25 at Colorado Blvd. 
        (303) 759-1515

        Just exit Colorado Blvd. from I-25 - You can't miss it.

When:

        Tuesday, August 22nd
        6:00pm

Michael Granger, Senior Web Developer for Active.com, will be presenting
"Advanced Web Application Design in Perl."

Michael has been hard at work building Active.com's next generation
application server, templating system, and Oracle table adapter, now in
beta release.  He also bears the distinction of having led the
Active.com development team to 2nd place in the Perl Quiz Show at the
Perl Whirl, led by Larry Wall.  (We lost 1st place to a team led by
Lincoln Stein.)

A more complete announcement is available at denver.pm.org.

I hope to see you there,

-Collin

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Collin Starkweather                           (303) 428-0100 x 112
Lead Developer                      collin.starkweather@active.com
Active.com, Inc.                             http://www.starky.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
    chris fedde
    303 773 9134


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

Date: 16 Aug 2000 23:48:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Can I use perl for automated builds?
Message-Id: <slrn8pma1d.tj3.abigail@alexandra.foad.org>

Pierre Cadieux (cadieuxp@sympatico.ca) wrote on MMDXLII September
MCMXCIII in <URL:news:nyBm5.159495$Gh.2639480@news20.bellglobal.com>:
;; Hi!
;; 
;; I am a Perl beginner; but I have 20 years of programming and designing in
;; many languages.
;; 
;; I have to automate the nightly build of a bunch of C++ and Java software
;; that builds Web components. This means:
;; 
;; a) getting from source control (and controlling version labels and build
;; numbers)
;; b) invoking compilers/linkers/IDEs/makes
;; c) managing logfiles, error detection and reporting
;; d) possibly burning a CD
;; e) possibly installing the software on another machine
;; f) possibly running some automated tests
;; etc.
;; 
;; 1. Is Perl a good choice?

Yes. But that's not to say other languages aren't a good choice. It's
certainly possible to use "make" for most of the work you mention, with
a bunch of little tools in a broad spectrum of languages.

Perl has a long learning curve (although you can do useful things with a
subset), and it requires a specific mindset. If you don't have the mindset,
Perl will never be a good choice for you. But, if you have, you'll fall
in love.

;; 2. I have to build on Windows NT 4.0 and on Solaris. What version(s) of Perl
;; should I use if I want to have maximum portability of my Perl code between
;; these two platforms?

There should be no significant difference between Perl versions. Use a
modern version of Perl, 5.005_03, or, when it's available, 5.6.1. There
are some portability issues you might have to worry about. Many of them
are addressed in the perlport man page. Perl makes writing cross platform
programs relatively easy. It's easier than in C or Java.

;; 3. is there any existing Perl software (free or not, CPAN or otherwise) that
;; can help with aumated builds?
;; 
;; 4. I bought two books:
;;     - Learning Perl on Win32 systems
;;     - PERL in a nutshell
;; 
;; Is the nutshell book a good way to learn PERL real quick and start coding my
;; automated build?

No. And don't use Learning Perl either. (IMO)

;; Or do you have anything better to recommend?

Yes. Specially for experience programmers. Get "Perl: The Programmers
Compagnion" for Nigel Chapman. Or just skip the books and just read
the man pages. Heck, for someone with 20 years of experience in many
languages, Programming Perl (get the new third edition) should do as well.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Thu, 17 Aug 2000 00:25:03 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Can I use perl for automated builds?
Message-Id: <399b30de.5af8$399@news.op.net>
Keywords: Nordhoff, antennae, rich, stockholder

[mailed and posted]

You may want to have a look at the 'cons' package.
'cons' is an tool for automating build processes.

http://www.baldmt.com/cons-faq/current.html



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

Date: Wed, 16 Aug 2000 23:33:53 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Certain Items in a string
Message-Id: <399b2488.957571@news.newsguy.com>

"Ben Kennedy" <bkennedy99@home.com> wrote:

>In general, its easier to write Win32 filenames as
>
>$filename = 'c:\long\path\to\filename.txt';

And even easier to write them as

 $filename = 'c:/long/path/to/filename.txt';

Try it, you'll like it.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 17 Aug 2000 00:26:20 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Certain Items in a string
Message-Id: <MPG.1405ce9dc1d1c75a9896b4@localhost>

marxjkj123@my-deja.com wrote ..
>Hello and thank you for all the previous help.  I have a problem that
>I'm trying to solve.
>
>Problem: I need to select certain items within a string.
>
>for example, I have a string($iw_Workarea) and I need to select
>everything from Workarea on and put it into a variable called $test.
>Basically, omitting everything preceeding \\Workarea.
>
>$iw_Workarea = "Y:\\default\\main\\Web_Logic\\Workarea\\WL_Property_WA
>
>Result would should look like, $test = "Workarea\\WL_Property_WA";

take a look at the perlre documentation .. it's fairly simple to do this 
type of thing with capturing parenthesis .. or have a look in perlop at 
the substitution operator s/// .. again - pretty simple

the only real gotcha here is that while you're using double-backwacks in 
your assignment .. remember that in the variable itself these are single

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 16 Aug 2000 17:08:19 -0500
From: Mark Johnson <MarkAJohnson@yahoo.com>
Subject: cross platform newline processing
Message-Id: <399B10D1.C8B1EFB5@yahoo.com>

Hi,
    I need to read text files line by line. Problem is these text files
may have been created on Mac, PC or unix.  As a consequence I don't know
whether the newline code is CR or LF or CR LF.
    I have searched FAQs on CPAN and at www.perl.com, but I can't find
anything that deals with this situation.  Can anybody point me in the
direction of a solution?

Thanks

Mark

p.s. The program will be running on a unix box if that matters.



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

Date: Wed, 16 Aug 2000 23:58:47 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: date and time in perl
Message-Id: <MPG.1405c827c1c4d13d9896b3@localhost>

Keith Calvert Ivey wrote ..
>"W Kemp" <bill.kemp@wire2.com> wrote:
>>Marr, Lincoln [HOOF:4713:EXCH] wrote in message
>><399907D3.E304A03B@europem01.nt.com>...
>>>Try this, I used it and it works beautifully:
>>>=============================================
>>
>><loads of stuff that could be replaced with >
>>
>>$date = localtime();
>
>... if you don't care about the format of the date and time.
>(Of course, Lincoln's code could be shortened.)

and corrected (or improved depending on how generous you're feeling) .. 
improper use of 'local' instead of 'my' .. two arrays (months and days) 
created and never used .. unecessary escaping of colons in double-quoted 
strings .. unecessary use of ampersand on function call

and that's forgetting the fact that (apart from leading zeros on days 
and months less than 10) Lincoln's code can be replaced by two lines

  use POSIX;
  $main::time = POSIX::strftime( '%m/%d/%Y at %H:%M:%S' => localtime);

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 17 Aug 2000 00:47:27 GMT
From: ceeeya <ceeeya@my-deja.com>
Subject: FileHandle in array
Message-Id: <8nfcmq$75d$1@nnrp1.deja.com>

Newbie question here for which I poked around but couldn't satisfy my
question so here goes:

Is there any way to reference the file handle in the array without
resorting to a temporary variable?:

@files = (
           [ "file0.txt", new FileHandle ],
           [ "file1.txt", new FileHandle ],
           [ "file2.txt", new FileHandle ]
         );

for $i ( 0 .. $#files ) {
  $fh = $files[$i][1];
  open $fh, $files[$i][0] or die "something happened: $!\n";
  while (<$fh>) {
    print $_;
  }
  close $fh;
}


Cory


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 17 Aug 2000 08:28:34 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Grabbing ALL parameters in a cgi script
Message-Id: <KqFm5.8$Pm2.1919@vic.nntp.telstra.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:399B09EC.8FCEB30@stomp.stomp.tokyo...
> Lithium wrote:

>
> I don't use cgi.pm and never will, even for testing.

>
> use CGI;
> my ($query) = new CGI;

I guess that is a ham sandwich then?

Sorry!

Wyzelli




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

Date: Wed, 16 Aug 2000 17:33:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Grabbing ALL parameters in a cgi script
Message-Id: <399B32CD.EDF71948@stomp.stomp.tokyo>

Wyzelli wrote:
 
> Godzilla!
> > Lithium wrote:
 
> > I don't use cgi.pm and never will, even for testing.

> > use CGI;
> > my ($query) = new CGI;
 
> I guess that is a ham sandwich then?
 
> Sorry!

 
Highly doubtful.

I never said I don't know how to use cgi-poopmaker.


*laughs*

Absolute classic British Litotes on my part,
one so blatant even Jon Jon the Constable
can appreciate, although he is incapable of
finding his own arse with both hands.

Godzilla!


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

Date: 17 Aug 2000 00:21:23 GMT
From: sth@ms1.hinet.net ()
Subject: Re: How to know if a scalar contain string or numeric data?
Message-Id: <8nfb63$fjq@netnews.hinet.net>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
: jason  <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
: >sth@ms1.hinet.net wrote ..
: >  perldoc perlfaq4
: >  "How do I determine whether a scalar is a number/whole/integer/float?"
: I'm not entirely sure if that is what the OP meant.  Even in Perl it 
: occasionally makes a difference whether you say $x = 123; or $x = '123';
: None of the regular expressions in the faq can tell these cases apart,
: but
:     ~$x ne ~"$x" ? 'numeric' : 'string'
: can.
: Anno

Hello

     Actually, I got this question when I needed to compare a lot of data
     to see if any item contains a negtive number. However, the raw data
     contains not only numeric data but also strings. I would like not to
     compare string with 0 or a warnning message will show up.

     Anno, would you please tell me how the following works? particully
     the "~" part.
         ~$x ne ~"$x" ? 'numeric' : 'string'

     Thanks.


Aaron



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

Date: 16 Aug 2000 19:16:24 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Image Manipulation Question
Message-Id: <8nfaso$d0g$1@provolone.cs.utexas.edu>

In article <uLDm5.3732$ZI2.91482@news1.rdc1.il.home.com>,
James <jthomson110@home.com> wrote:
>Does anyone know of any routines, scripts or recommendations on creating a
>script that would take
>a directory of images and create a new directory of those
>same images - only shrunken in size?
>
>Basically a script that would make REAL thumbnails
>from images in a certain directory.
>
>I'm guessing the GD module might need to be used, but don't know...
>
>Any help would be appreciated!

I would just install pbmplus and use that.  It can read and write jpegs
and gif files and maybe png if you install the right stuff.  Then, you
just do something like this:

    djpeg < foo.jpg | pnmscale -xysize 120 90 | cjpeg > thumbnails/foo.jpg

Put inside a perl loop, this looks like:

    $scale = 'pnmscale -xysize 120 90';

    opendir (DIR, ".") or die "Can't open dir because '$!'\n";
    foreach my $file (readdir DIR)
        {
	next if $file =~ /^\.{1,2}$/;

        my $tnfile = "thumbnails/$file":
        if ($file =~ /[.]jpe?g$/i)
            {
            system ("djpeg < '$file' | $scale | cjpeg > '$tnfile'");
            }
        elsif ($file =~ /[.]gif$/i)
            {
            system ("giftoppm < '$file' | $scale |  ppmtogif > '$tnfile');
            }
        }

Of course, that example isn't very careful about funky characters in
filenames and stuff, so it's not ready for prime time or anything.

  - Logan


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

Date: Thu, 17 Aug 2000 00:55:33 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Listing users in Win NT
Message-Id: <MPG.1405d56f120a80fa9896b7@localhost>

Dr. Peter Dintelmann wrote ..

>s24673 schrieb in Nachricht <3999e546.0@scctn03.sp.edu.sg>...
>>Does anyone know how to list the users who are logged on in Win NT using
>>Perl?
>
>    usually there is only one user logged in. You will
>    find the username in $ENV{USERNAME}.
>    If you are interested in a listing of available logins
>    on NT have a look at the GetUsers() method in
>    Win32::NetAdmin.

'usually' ? .. that's a simply incorrect answer .. certainly it would be 
true for the majority of NT workstations .. but NT hosts providing FTP 
or HTTP services .. or print services .. or NT domain services will 
usually have many more than one user logged in

the Win32::NetAdmin module provides a method to view the logged in users

  perldoc Win32::NetAdmin

for more information

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 17 Aug 2000 00:38:01 GMT
From: jason <elephant@squirrelgroup.com>
Subject: OT: newsreaders and Microsoft [was: Perl code for a newbie!!]
Message-Id: <MPG.1405d1541540218b9896b5@localhost>

Bart Lateur wrote ..
>jason wrote:
>
>>you (even with the followup that I'm responding to) still just 
>>included everything that was said previously .. you included it below 
>>your post and you made no attempt to even remove the signature
>>
>>this is known as jeopardy style posting .. and it is not conducive to 
>>good newsgroup discussion
>
>Look at what software he used to post. MS Outlook does this kind of
>quoting by default and *without you even noticing*. All you see in your
>message window is what you type yourself.

oh man .. that's so scarey .. I'm fearing the day that they wrap up all 
of usenet in a "Help Desk" button on the desktop

I haven't used Outlook Express (which - for the record is a different 
product to MS Outlook) for many years .. back when I used it - although 
you were placed above the quoted text - it was a simple operation to 
delete a few lines and jump to the bottom

now I use Gravity .. beautiful product with real power and good rules 
and filters and scoring and stuff .. of course it's combined with a 
ruthless nfilter so I don't have to read any stomping activity in tokyo

I guess I'll be adding another line to that filter

  X-Newsreader: Microsoft Outlook Express 5*

>Crappy tools, from the "most prestigious software company in the world";
>at least, that's what they'd like to be -- er, appear.

  s/presitgious/notorious/

here's hoping that by 2010 Microsoft is just an entry in a slang 
dictionary meaning to completely screw something up (actually I wouldn't 
mind it if they devoted their time to creating window managers - they 
really are very good at GUIs)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 17 Aug 2000 00:43:01 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Perl Newbie trying to parse file
Message-Id: <MPG.1405d27fd4f3fe479896b6@localhost>

SR wrote ..
>I have a bunch of files that need to be parsed and updated to a mysql
>database.
>
>Could someone please help me with parsing this file or provide ideas:
>
>
>Value1:    Data
>Value2:    Data
>                Data
>                Data
>
>Value3: Data
>Value4: Data
>              Data
>
>
>Now how do I handle if data has got new lines embedded.

the simplest solution .. assuming that the file is of a reasonable size

1. slurp the entire file into a scalar

2. use a global regex to get your values out

the more complex solution .. which will work well irrespective of file 
size

1. iterate over each line in the file using the '..' or '...' operator 
to determine where a record begins and ends

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 16 Aug 2000 19:22:46 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: PERLXS Samples Please
Message-Id: <8nfb8m$d1i$1@provolone.cs.utexas.edu>

In article <399B0C7C.DB11E30@yahoo.ca>,
Nektarios Rigas  <nrigas2@yahoo.ca> wrote:
>Does anyone have any decent  XS code that is willing to forward to me , or know
>where I can find some to download and look at.

Presumably, many of the modules on CPAN use this to link with C code.
I'm sure that there are many others, but the DBD modules (which are
database drivers, "Mysql-Msql-modules" being one example) are probably
a good place to start, since those modules have to call C code from
libraries in order to access the databases.

Also, I believe HTML::Parser also now has C code in it.

Hope that helps.

Oh, by the way, your post contained references to other posts in the
"References:" header line, even though you were trying to start a new
thread.  On my (threaded) newsreader, this made them show up as part of
that thread.  Next time, it would be better to use whatever feature of
your newsreader you'd use for new posts rather than following up to an
existing post and just deleting the subject.

  - Logan


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

Date: 16 Aug 2000 22:50:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Replacing lines in a file
Message-Id: <slrn8pm6kd.tj3.abigail@alexandra.foad.org>

Rafael Garcia-Suarez (rgarciasuarez@free.fr) wrote on MMDXLII September
MCMXCIII in <URL:news:slrn8pkvn3.6mv.rgarciasuarez@rafael.kazibao.net>:
// Marr, Lincoln [HOOF:4713:EXCH] wrote in comp.lang.perl.misc:
// >I am having a problem. I have a scalar $key which is time(). I have a
// >pipe delimited text file (using it as a database) and each record is
// >separated by a newline. The first field of each record is $key (ie a
// >unique index).
// >I want my script to look through the file, line by line (@input =
// ><FILE>;), then @split = split(/\|/,$_) and if $split[0] eq $key, then
// >remove that line. I've looked at the perlfaq5 (How do I change one line
// >in a file...) which didn't help me too much. 
// 
// Don't read the whole file in a big array in memory.
// Here's a one-liner that will do the job:
// 
// perl -nie 'BEGIN{$key='THEKEY'} print if /^$key|\/';
          ^^

That will make Perl do an inline edit, backup up the file using "e" as
extension for the backup. Perl will then try to execute the program in
the file 'BEGIN{$key='THEKEY'} print if /^$key|\/', and, if it can find
that file, and find a valid Perl program in it, get confused as there's
no file to apply the program on.

Now, perhaps you meant:

    perl -ni -we 'BEGIN{$key='THEKEY'} print if /^$key|\/' file

but that has some problems. First, "THEKEY" is interpretated by the
shell, because of your use of '' inside ''. Then, the match is never
terminated, as you escape the trailing /. So, your program will not
compile. And it beats me why you assign to $key in the BEGIN. Oh, and
if you fix all the problems, your program only keeps what needs to
be deleted....

// See the perlrun manpage if you don't understand the -nie switches.

Use perlrun and use some more switches:

    perl -F'/\|/' -nawe 'print unless $F [0] == time' file

(However this is very strange. The value of time() changes every
second. So, such a program is very time dependent on which lines it will
remove. But that's how Lincoln described his problem....)

Command line switches are your friends. Use them.


Abigail
-- 
:$:=~s:$":Just$&another$&:;$:=~s:
:Perl$"Hacker$&:;chop$:;print$:#:


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

Date: Wed, 16 Aug 2000 22:07:04 GMT
From: pape_98@my-deja.com
Subject: sorting ??
Message-Id: <8nf39p$s76$1@nnrp1.deja.com>

hi,
I was wondering if any of you could help me with a problem.
I have a file that needs to be sorted. It looks something like this:
 NIH,B1D-410,52 51 36,135 256,15413,1512
 NIH,B1D-416,52,135 6,1513,52 hi,
 NIH,B1D-403,01 36,13 5 26,15 43,1 5 2 5 2 4
 Suburban,Cardiology Office,52 51,5256,15 13,152
 ...

I've written a script that sorts it but it only sorts from 1 to 9;
i.e 1,12,131,2,23,26,...
this is the script I wrote:

use strict;
my $file = '/home/common/tourep/public_html/ntboxes';
open (DATA, $file) or die "Can't open file: $!\n";
my @data;
while (<DATA>) {
        s/(\d+)\/(\d+)\/(\d+)/sprintf "$3".'%02d'x2,$2,$1/e;
        push @data,$_;
}
close T;

Now my question is how do i modify it so that it's sorts by number,
i.e 1,2,3,13,23,131,...

Any suggestions would be greatly appreciated.

Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 16 Aug 2000 19:14:20 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: sorting ??
Message-Id: <399B204B.F2A7A2CB@cc.gatech.edu>

pape_98@my-deja.com wrote:

> hi,
> I was wondering if any of you could help me with a problem.
> I have a file that needs to be sorted. It looks something like this:
>  NIH,B1D-410,52 51 36,135 256,15413,1512
>  NIH,B1D-416,52,135 6,1513,52 hi,
>  NIH,B1D-403,01 36,13 5 26,15 43,1 5 2 5 2 4
>  Suburban,Cardiology Office,52 51,5256,15 13,152
>  ...
>
> I've written a script that sorts it but it only sorts from 1 to 9;
> i.e 1,12,131,2,23,26,...
>

> Now my question is how do i modify it so that it's sorts by number,
> i.e 1,2,3,13,23,131,...
>

perldoc -q sort

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Tue, 15 Aug 2000 15:29:55 +1000
From: "Stephen Bishop" <sbishop@mincom.com>
Subject: Unix Perl to OpenVMS Perl
Message-Id: <8nakcg$kku$1@sol.mincom.oz.au>

Hi everyone,

I'm totally new to Perl and VMS, and have been given a Perl script in Unix
and have been asked to convert it, so that it will run on an OpenVMS system.
Has anyone ever done this before?

I'm wondering what sort of changes I will need to make.
Obviously I will need to remove any references to Unix commands (like dd),
and will also have to change the directory structures, but I would greatly
appreciate any hints or clues as to exactly what I will need to change.

Thanks in advance for any help offered,

Cheers!

Steve




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

Date: 16 Aug 2000 19:10:08 GMT
From: tebrusca@oakland.edu (Thomas Brusca)
Subject: Useful perl macros for Developer Studio
Message-Id: <8neoug$hv3$1@news2.acs.oakland.edu>

I'm using Perl on NT and Microsoft Developer Studio
as my editor.  I checked out a few perl editors but
haven't been overly impressed and I don't want to
pay anyway.

Today I discovered the macros, I made one that will
put a # at the beginning of every highlighted line.
Very useful, much potential for building scripts
quickly and consistently with a few clicks.

There's one problem, the macros are in VBScript, I
don't know VBScript, it's not hard but has anybody
already done this?

I'm using Developer Studio 5.0, I believe 7.0 will 
support perl, that is recognize the commands.

All comments are welcome.


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

Date: Wed, 16 Aug 2000 15:34:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: windows headache
Message-Id: <399B16EA.A529AB84@vpservices.com>



Larry Rosler wrote:
> 
> In article <399B01E6.B8D8D754@vpservices.com> on Wed, 16 Aug 2000
> 14:04:38 -0700, Jeff Zucker <jeff@vpservices.com> says...
> >
> > If you should happen to get the message I just canceled ...
>
> Huh?  

I seem to have these bad days where nothing I say makes sense. 

-- 
Jeff "moving his hands slowly away from the keyboard" Z.


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

Date: Thu, 17 Aug 2000 00:00:47 GMT
From: yhvhboy1 <yhvhboy1@home.com>
Subject: Re: windows headache
Message-Id: <399B2C44.4FC47529@home.com>



Larry Rosler wrote:

> In article <399B01E6.B8D8D754@vpservices.com> on Wed, 16 Aug 2000
> 14:04:38 -0700, Jeff Zucker <jeff@vpservices.com> says...
> > yhvhboy1 wrote:
> >
> > > print OUT (<IN>);
> >
> > If you should happen to get the message I just canceled, please ignore
> > my idiocy about context.  Putting the parens around <IN>, of course puts
> > it in a list context. So that part of your script is fine.
>
> Huh?  It is list context with or without the parentheses.
>
> But that part of the program isn't fine, because it unnecessarily reads
> the entire file into memory before printing it, a 'line at a time' yet
> (whatever that means for a binary file).

# well, i am losing data, not running out of memory.
# but thank you for clearing that up for me.
# i think i've always had this problem with win-perl.
# reading and writing files that is --
#    i also tried using IO::File with the same prob.
# i am starting to get the feeling perl in windows
# isn't perl - or perhaps it is like a far distant relative.
# at least by comparing to it the perl i've always known.
use Common::Sense;
Common::Sense->says("Jesus is Lord!");
__END__



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

Date: Wed, 16 Aug 2000 23:42:17 GMT
From: yhvhboy1 <yhvhboy1@home.com>
Subject: Re: windows headache: make
Message-Id: <399B27ED.5618EDDF@home.com>



Abe Timmerman wrote:

> If you want to know what make to use, type
>         perl -V:make
>

Jesus C:\> perl -V:make
make='nmake';

>
> I guess you're using ActivePerl, so it should say "make='nmake';"
> (This value is used by ExtUtils::MakeMaker to generate specific make
> files when you do 'perl Makefile.PL')
>

indigo perl (but i have tried with active perl 616 (or was it 612?) the
current

>
> > # i can't get either to work- but i don't know
> > # for sure if it is the make program
> > # or else perhaps some other program
> > # i download the build files fine, unzip them fine
> > # (and untar them fine)
> > # the problems begin when i make them.
>
> It would be nice if you told us what went wrong and wich modules you are
> trying to install.
>

## i've tried installing many of them -- none work all perl or perl/c
## here's the output from MIDI::Perl (i believe it is an all perl one

Going to read \.cpan\sources\authors\01mailrc.txt.gz
CPAN: Compress::Zlib loaded ok
Going to read \.cpan\sources\modules\02packages.details.txt.gz
Scanning cache \.cpan\build\. for sizes

  There's a new CPAN.pm version (v1.57) available!
  [Current version is v1.52]
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...

Going to read \.cpan\sources\modules\03modlist.data.gz
Running make for S/SB/SBURKE/MIDI-Perl-0.77.tar.gz
CPAN: MD5 loaded ok
Checksum for \.cpan\sources\authors\id\S\SB\SBURKE\MIDI-Perl-0.77.tar.gz ok
MIDI-Perl-0.77/
MIDI-Perl-0.77/lib/
MIDI-Perl-0.77/lib/MIDI/
MIDI-Perl-0.77/lib/MIDI/Filespec.pod
MIDI-Perl-0.77/lib/MIDI/Event.pm
MIDI-Perl-0.77/lib/MIDI/Track.pm
MIDI-Perl-0.77/lib/MIDI/Opus.pm
MIDI-Perl-0.77/lib/MIDI/Simple.pm
MIDI-Perl-0.77/lib/MIDI/Score.pm
MIDI-Perl-0.77/lib/MIDI.pm
MIDI-Perl-0.77/MANIFEST
MIDI-Perl-0.77/ChangeLog
MIDI-Perl-0.77/Makefile.PL
MIDI-Perl-0.77/test.pl
MIDI-Perl-0.77/README
Removing previously used \.cpan\build\MIDI-Perl-0.77\.

  CPAN.pm: Going to build S/SB/SBURKE/MIDI-Perl-0.77.tar.gz

Checking if your kit is complete...
Looks good
Unable to find a perl 5 (by these names: C:\perl\bin\perl.exe miniperl perl
perl5 perl5.6.0, in these dirs: C:\PERL\BIN C:\GNU\BIN C:\WINDOWS
C:\WINDOWS\COMMAND C:\perl\bin)
Writing Makefile for MIDI-Perl
  C:\perl\bin\nmake.exe  -- NOT OK
Running make test
  Oops, make had returned bad status
Running make install
  Oops, make had returned bad status

## i suppose it is strange that it can't find perl 5
## is there an environment variable i need for this?

>
> Did you have a look at PPM (the Perl Package Manager)? And check at the
> ActiveState site which (binary) modules they have available?
>
> Pure Perl modules from CPAN should install with nmake.

# i tried the package manager which came with indigo, dpm
# it doesn't want to install any better than CPAN.pm

## be sure to check out the open windows project
## they haven't done much work, but i'm sure they could
## use some help with things -- anyone interested
## stop by their site http://www.owpcentral.com/



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4037
**************************************


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