[30382] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1625 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 9 21:09:49 2008

Date: Mon, 9 Jun 2008 18:09:17 -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, 9 Jun 2008     Volume: 11 Number: 1625

Today's topics:
    Re: A dumb question but... <jurgenex@hotmail.com>
    Re: A dumb question but... <m@rtij.nl.invlalid>
    Re: A dumb question but... <uri@stemsystems.com>
    Re: A dumb question but... <dragnet\_@_/internalysis.com>
    Re: A dumb question but... <tadmc@seesig.invalid>
    Re: FAQ 5.23 All I want to do is append a small amount  <uri@stemsystems.com>
    Re: FAQ 5.28 How can I read in an entire file all at on <uri@stemsystems.com>
    Re: FAQ 5.38 How do I select a random line from a file? <jurgenex@hotmail.com>
    Re: FAQ 5.38 How do I select a random line from a file? <jimsgibson@gmail.com>
    Re: FAQ 5.38 How do I select a random line from a file? <simon.chao@gmail.com>
    Re: Good intro to perl to a "newbie to programming" <joost@zeekat.nl>
    Re: Good intro to perl to a "newbie to programming" <dragnet\_@_/internalysis.com>
    Re: Good intro to perl to a "newbie to programming" <ignoramus25756@NOSPAM.25756.invalid>
    Re: Good intro to perl to a "newbie to programming" <tadmc@seesig.invalid>
        Moving from delimited to XML <bill@ts1000.us>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 09 Jun 2008 20:17:54 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: A dumb question but...
Message-Id: <1u3r44tp60tupu4786dpcr2vm1s7qqtrk3@4ax.com>

Martijn Lievaart <m@rtij.nl.invlalid> wrote:
>On Mon, 09 Jun 2008 12:26:26 -0700, Bill H wrote:
>> while it runs, but I have always wondered. Would perl be notified and /
>> or care if I closed that shell window or would it just continue on till
>> it was done?
>
>On most (all) shells, that would send a SIGHUP to the process. If you 
>don't catch that signal, it kills the process.
>
>If you don't want that, either use nohup or batch.

Or dissaccoiate that process from the process group or from the terminal
or or or....
There are many ways.

jue


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

Date: Mon, 9 Jun 2008 23:01:17 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: A dumb question but...
Message-Id: <pan.2008.06.09.21.01.08@rtij.nl.invlalid>

On Mon, 09 Jun 2008 21:43:35 +0200, Joost Diepenmaat wrote:

> If you want to, you could run the program in screen instead (I actually
> prefer this for long-running processes, since it can be slightly too
> easy to kill an xterm / ssh session).

I second that, screen is a /very/ good solution.

M4


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

Date: Mon, 09 Jun 2008 21:12:17 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A dumb question but...
Message-Id: <x7bq2a48k0.fsf@mail.sysarch.com>

>>>>> "BH" == Bill H <bill@ts1000.us> writes:

  BH> I have this perl script that I have been using for bout 10 years that
  BH> sends out a mass email to one of my clients member list (about 4,000)
  BH> people. I run it at a shell prompt on an Apache server and it will
  BH> display back a "sent email address" for each one it processes. Takes
  BH> about 2 hours to run through. I am not concerned about speeding it up
  BH> or anything since I only do it once a week and usually off eating
  BH> lunch while it runs, but I have always wondered. Would perl be
  BH> notified and / or care if I closed that shell window or would it just
  BH> continue on till it was done?

regardless of the other shell issues and solutions, this is a poor way
to do this. you would be much better off installing a mailing list
manager such as majordomo or mailman and creating a list for this. then
you send it one email and it does the work for you in the background and
a hell of a lot faster than 2 hours. your perl script is reduced to
sending a single email out to that list and it will be done
immediately. also this means users (email receivers) could
subscribe/unsubscribe and manage their list features without your help.

btw, how does apache offer a shell prompt? the word server is overloaded
and abused too many ways. any box which can run programs that handle
network apps is a 'server' as are many of those apps themselves. those
two meanings must not be conflated.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 09 Jun 2008 17:06:57 -0500
From: Marc Bissonnette <dragnet\_@_/internalysis.com>
Subject: Re: A dumb question but...
Message-Id: <Xns9AB8B84532AD7dragnetinternalysisc@216.196.97.131>

Uri Guttman <uri@stemsystems.com> fell face-first on the keyboard. This
was the result: news:x7bq2a48k0.fsf@mail.sysarch.com: 

>>>>>> "BH" == Bill H <bill@ts1000.us> writes:
> 
>   BH> I have this perl script that I have been using for bout 10 years
>   that BH> sends out a mass email to one of my clients member list
>   (about 4,000) BH> people. I run it at a shell prompt on an Apache
>   server and it will BH> display back a "sent email address" for each
>   one it processes. Takes BH> about 2 hours to run through. I am not
>   concerned about speeding it up BH> or anything since I only do it
>   once a week and usually off eating BH> lunch while it runs, but I
>   have always wondered. Would perl be BH> notified and / or care if I
>   closed that shell window or would it just BH> continue on till it
>   was done? 
> 
> regardless of the other shell issues and solutions, this is a poor way
> to do this. you would be much better off installing a mailing list
> manager such as majordomo or mailman and creating a list for this.
> then you send it one email and it does the work for you in the
> background and a hell of a lot faster than 2 hours. your perl script
> is reduced to sending a single email out to that list and it will be
> done immediately. also this means users (email receivers) could
> subscribe/unsubscribe and manage their list features without your
> help. 

[snip]

Out of curiosity, what kind of speed improvements would you see from using 
Majordomo over a perl script ? 

I've got a self-written mass-mailer for 400 clients that takes probably 
just under 30 minutes to run (sleeping for 3 seconds every 15 mails - 
holdover from a previous ISP that told me I needed to do this to avoid 
their spam trapping software). I only run it every two or three months, but 
still, now you've got me curious :)



-- 
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.


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

Date: Mon, 9 Jun 2008 19:52:45 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: A dumb question but...
Message-Id: <slrng4rk2t.ejb.tadmc@tadmc30.sbcglobal.net>

Bill H <bill@ts1000.us> wrote:

> Subject: A dumb question but...


I don't know about the question, but the Subject is certainly dumb.

(as in "it doesn't say much")


Please put the subject of your article in the Subject of your article.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 09 Jun 2008 21:06:30 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 5.23 All I want to do is append a small amount of text to the end of a file.  Do I still have to use locking?
Message-Id: <x7fxrm48tl.fsf@mail.sysarch.com>

>>>>> "PS" == PerlFAQ Server <brian@stonehenge.com> writes:

  PS> This is an excerpt from the latest version perlfaq5.pod, which
  PS> comes with the standard Perl distribution. These postings aim to 
  PS> reduce the number of repeated questions as well as allow the community
  PS> to review and update the answers. The latest version of the complete
  PS> perlfaq is at http://faq.perl.org .

  PS> --------------------------------------------------------------------

  PS> 5.23: All I want to do is append a small amount of text to the end of a file.  Do I still have to use locking?

 
  PS>     If you are on a system that correctly implements flock() and
  PS>     you use the example appending code from "perldoc -f flock"
  PS>     everything will be OK even if the OS you are on doesn't
  PS>     implement append mode correctly (if such a system exists.) So
  PS>     if you are happy to restrict yourself to OSs that implement
  PS>     flock() (and that's not really much of a restriction) then
  PS>     that is what you should do.

  PS>     If you know you are only going to use a system that does correctly
  PS>     implement appending (i.e. not Win32) then you can omit the seek() from
  PS>     the code in the previous answer.

  PS>     If you know you are only writing code to run on an OS and
  PS>     filesystem that does implement append mode correctly (a local
  PS>     filesystem on a modern Unix for example), and you keep the
  PS>     file in block-buffered mode and you write less than one
  PS>     buffer-full of output between each manual flushing of the
  PS>     buffer then each bufferload is almost guaranteed to be written
  PS>     to the end of the file in one chunk without getting
  PS>     intermingled with anyone else's output. You can also use the
  PS>     syswrite() function which is simply a wrapper around your
  PS>     systems write(2) system call.

  PS>     There is still a small theoretical chance that a signal will
  PS>     interrupt the system level write() operation before
  PS>     completion. There is also a possibility that some STDIO
  PS>     implementations may call multiple system level write()s even
  PS>     if the buffer was empty to start. There may be some systems
  PS>     where this probability is reduced to zero.

File::Slurp has append_file which does this feature but without
locking. if you want an atomic version without locking you can slurp in
the file and write it out with the new data in atomic mode like this:

write_file( $file_name, {atomic => 1},
	    read_file( $file_name, $appended_text ) ) ;

this will write it all to a new file and rename it to the original
name. it is as good as locking in most situations that need this. it
isn't super efficient if the file is getting large.

i could add lock support for append_file (which is really a call to
write_file with the 'append' option enabled). this would be added to my
long list of todo's for the slurp module.

thanx,

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 09 Jun 2008 20:56:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 5.28 How can I read in an entire file all at once?
Message-Id: <x7ve0i49a7.fsf@mail.sysarch.com>

>>>>> "PS" == PerlFAQ Server <brian@stonehenge.com> writes:

  PS> 5.28: How can I read in an entire file all at once?
 
  PS>     You can use the File::Slurp module to do it in one step.

you should state that this is on cpan and not a core module. i tried to
get it into core but was violently shot down. :/

  PS>             use File::Slurp;

  PS>             $all_of_it = read_file($filename); # entire file in scalar
  PS>             @all_lines = read_file($filename); # one line per element

  PS>     The customary Perl approach for processing all the lines in a file is to
  PS>     do so one line at a time:

  PS>             open (INPUT, $file)     || die "can't open $file: $!";
  PS>             while (<INPUT>) {
  PS>                     chomp;
  PS>                     # do something with $_
  PS>                     }
  PS>             close(INPUT)            || die "can't close $file: $!";

  PS>     This is tremendously more efficient than reading the entire file into
  PS>     memory as an array of lines and then processing it one element at a
  PS>     time, which is often--if not almost always--the wrong approach. Whenever
  PS>     you see someone do this:

i beg to differ on that statement. slurping is usually faster than line
by line for most reasonable file sizes. and i mean most common config,
text, source, etc files, not genetic data or logs. the perl i/o system
is slower than slurping and looping. there is a benchmark script in the
File::Slurp distribution which compares different slurp styles. the next
version of the module (in process) will have a better benchmark and may
even compare for vs while looping.

  PS>             @lines = <INPUT>;

  PS>     you should think long and hard about why you need everything
  PS>     loaded at once. It's just not a scalable solution. You might
  PS>     also find it more fun to use the standard Tie::File module, or
  PS>     the DB_File module's $DB_RECNO bindings, which allow you to
  PS>     tie an array to a file so that accessing an element the array
  PS>     actually accesses the corresponding line in the file.

  PS>     You can read the entire filehandle contents into a scalar.

  PS>             {
  PS>             local(*INPUT, $/);
  PS>             open (INPUT, $file)     || die "can't open $file: $!";
  PS>             $var = <INPUT>;
  PS>             }

this is where File::Slurp really excels over that perl version. it is
MUCH faster in almost all cases.

  PS>     That temporarily undefs your record separator, and will automatically
  PS>     close the file at block exit. If the file is already open, just use
  PS>     this:

  PS>             $var = do { local $/; <INPUT> };

  PS>     For ordinary files you can also use the read function.

  PS>             read( INPUT, $var, -s INPUT );

sysread is even faster but it won't deal with line ending issues on
different platforms.

and you miss the most important reason to slurp into a scalar. it isn't
speed of slurping but ease of processing and parsing. with line by line
it is a pain to look for start/end of range lines and even more painful
if the markers aren't line oriented (think html and its ilk). when you
slurp into a scalar you can easily parse out chunks with regexes and not
need state like when using .. .

another idea is to link to my article on perl.com (if it still can be
linked) or in the distro on cpan. it covers much more about slurping,
why it is better/faster and such. it is in the extras dir in pod format:

http://search.cpan.org/src/URI/File-Slurp-9999.12/extras/slurp_article.pod

a link to that may break when new versions are uploaded so saying it is
in the extras dir of the File::Slurp distro may be best.

thanx,

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 09 Jun 2008 20:12:31 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <2e3r44dttkqdm6g1i9aaef58iilug4d52c@4ax.com>

nolo contendere <simon.chao@fmr.com> wrote:
>Wouldn't determining the maximum line length require you to go through
>the entire file? So right there the cost is more than the solution in
>the FAQ (the one referencing the Camel book), right?

Yes, but -depending upon your application- presumably it is a one-time
cost only, and thus you don't incurr is for every run.

>Unless you're
>saying not to count this initial work, but then, is that fair when
>trying to compare solutions?

Depends. If the file really doesn't change then the difference is O(n)
with n being the number of lines for the FAQ approach and O(1) + c for
the alternate pre-compile approach.

jue


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

Date: Mon, 09 Jun 2008 17:27:59 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <090620081727596867%jimsgibson@gmail.com>

In article
<2856722a-0c9e-42fe-8b35-5987a2b13e7e@s50g2000hsb.googlegroups.com>,
nolo contendere <simon.chao@fmr.com> wrote:

> On Jun 9, 3:20 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> > In article <080620080134579524%brian.d....@gmail.com>, brian d  foy
> >
> >
> >
> > <brian.d....@gmail.com> wrote:
> > > In article <484adab2$0$30196$4c368...@roadrunner.com>, Dan Rumney
> > > <danrum...@warpmail.new> wrote:
> >
> > > > Peter J. Holzer wrote:
> > > > > On 2008-06-04 19:03, PerlFAQ Server <br...@stonehenge.com> wrote:
> > > > >> 5.38: How do I select a random line from a file?
> > > Has anyone solved this for something non-trivial? Say, for something
> > > with huge numbers of lines or large file sizes, or where you want to
> > > choose several random lines?
> >


> > For a reservoir of size one, the algorithm can be simplified to
> > something like (untested):
> >
> >   1. Read the first line of the file into a scalar
> >   2. Read the subsequent lines in the file and, for each line, replace
> >      the saved line with a probability of 1/n, where n is the number
> >      of lines read so far (e.g. $.). Generate a random number
> >      in the interval (0,1) and replace the saved value if the random
> >      value is less than 1/n.
> >
> > After reading the entire file, each line in the file has equal
> > probability of being selected and remaining in the scalar variable.
> 
> Isn't that what the solution in the FAQ does?
> 
>             srand;
>             rand($.) < 1 && ($line = $_) while <>;
> 
> for the first line, rand($.) will always be less than 1, so your 1st
> instruction is done. for the subsequent lines, the chance of rand($.)
> being less than 1 is ~ 1/$., etc.
> 
> is that what you were saying? or were you saying something else?

Yes, that is what the FAQ was saying. I was responding to brian's
question, and didn't look at the FAQ before I did that. So -- never
mind!

-- 
Jim Gibson


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

Date: Mon, 9 Jun 2008 17:49:13 -0700 (PDT)
From: nolo contendere <simon.chao@gmail.com>
Subject: Re: FAQ 5.38 How do I select a random line from a file?
Message-Id: <810ff974-d109-48cf-8cea-c28d414185da@a70g2000hsh.googlegroups.com>

On Jun 9, 8:27=A0pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article
> <2856722a-0c9e-42fe-8b35-5987a2b13...@s50g2000hsb.googlegroups.com>,
>
>
>
> nolo contendere <simon.c...@fmr.com> wrote:
> > On Jun 9, 3:20=A0pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> > > In article <080620080134579524%brian.d....@gmail.com>, brian d =A0foy
>
> > > <brian.d....@gmail.com> wrote:
> > > > In article <484adab2$0$30196$4c368...@roadrunner.com>, Dan Rumney
> > > > <danrum...@warpmail.new> wrote:
>
> > > > > Peter J. Holzer wrote:
> > > > > > On 2008-06-04 19:03, PerlFAQ Server <br...@stonehenge.com> wrote=
:
> > > > > >> 5.38: How do I select a random line from a file?
> > > > Has anyone solved this for something non-trivial? Say, for something=

> > > > with huge numbers of lines or large file sizes, or where you want to=

> > > > choose several random lines?
>
> > > For a reservoir of size one, the algorithm can be simplified to
> > > something like (untested):
>
> > > =A0 1. Read the first line of the file into a scalar
> > > =A0 2. Read the subsequent lines in the file and, for each line, repla=
ce
> > > =A0 =A0 =A0the saved line with a probability of 1/n, where n is the nu=
mber
> > > =A0 =A0 =A0of lines read so far (e.g. $.). Generate a random number
> > > =A0 =A0 =A0in the interval (0,1) and replace the saved value if the ra=
ndom
> > > =A0 =A0 =A0value is less than 1/n.
>
> > > After reading the entire file, each line in the file has equal
> > > probability of being selected and remaining in the scalar variable.
>
> > Isn't that what the solution in the FAQ does?
>
> > =A0 =A0 =A0 =A0 =A0 =A0 srand;
> > =A0 =A0 =A0 =A0 =A0 =A0 rand($.) < 1 && ($line =3D $_) while <>;
>
> > for the first line, rand($.) will always be less than 1, so your 1st
> > instruction is done. for the subsequent lines, the chance of rand($.)
> > being less than 1 is ~ 1/$., etc.
>
> > is that what you were saying? or were you saying something else?
>
> Yes, that is what the FAQ was saying. I was responding to brian's
> question, and didn't look at the FAQ before I did that. So -- never
> mind!
>

k, just checking. i thought i may have missed something there!


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

Date: Mon, 09 Jun 2008 22:15:08 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Good intro to perl to a "newbie to programming"
Message-Id: <87abhu9xgz.fsf@zeekat.nl>

Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid> writes:

> I am looking for a book on Perl that introduces it to a person who is
> not a programmer, and offers a track along with exercises, etc. 
>
> That would be for someone who does not know any programming, so it
> would need to explain a little more what is a "loop", "subroutine" and
> similar things in more depth than a book for people who are
> programmers already.
>
> Some useful recommendations would be appreciated. Thanks

"Learning Perl" from O'Reilly might be what you're looking for, though
IIRC it's not aimed squarely at non-programmers, it is a relatively
gentle introduction and it includes exercises.

/getting slightly off topic/

Is there a reason the "target" must start with perl? Perl's not that
hard to get started with, and it may be pretty good for whatever code
it is (s)he's going to want to write, but I think there may be as good
or better "pure introductionary programming" books that handle other
languages. 

OTOH, in my experience the best thing to do is to just start coding,
and perl makes *that* at least pretty easy.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

Date: Mon, 09 Jun 2008 15:30:19 -0500
From: Marc Bissonnette <dragnet\_@_/internalysis.com>
Subject: Re: Good intro to perl to a "newbie to programming"
Message-Id: <Xns9AB8A7E2E22B0dragnetinternalysisc@216.196.97.131>

Joost Diepenmaat <joost@zeekat.nl> fell face-first on the keyboard. This 
was the result: news:87abhu9xgz.fsf@zeekat.nl:

> Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid> writes:
> 
>> I am looking for a book on Perl that introduces it to a person who is
>> not a programmer, and offers a track along with exercises, etc. 
>>
>> That would be for someone who does not know any programming, so it
>> would need to explain a little more what is a "loop", "subroutine" and
>> similar things in more depth than a book for people who are
>> programmers already.
>>
>> Some useful recommendations would be appreciated. Thanks
> 
> "Learning Perl" from O'Reilly might be what you're looking for, though
> IIRC it's not aimed squarely at non-programmers, it is a relatively
> gentle introduction and it includes exercises.
> 
> /getting slightly off topic/
> 
> Is there a reason the "target" must start with perl? Perl's not that
> hard to get started with, and it may be pretty good for whatever code
> it is (s)he's going to want to write, but I think there may be as good
> or better "pure introductionary programming" books that handle other
> languages. 
> 
> OTOH, in my experience the best thing to do is to just start coding,
> and perl makes *that* at least pretty easy.

I'll add to that by saying that if this is your very first introduction to 
programming, follow and try *all* of the examples in the book. I started 
off many, many moons ago by teaching myself Commodore BASIC from the book 
that came with the computer. (Later Turbo Pascale, then an attempt at C, 
then HTML, then (finally, Perl and MySQL) - When the book says "write
#!/usr/bin/perl
print "hello world";
exit;

and save as "hello.pl" - do it and run it. It helps to reinforce what 
you're reading by actually seeing it happen on the screen, rather than 
assuming you got it by reading. 

Assuming you've got the knack for it, you'll be amazed at how quickly 
you'll pick it up by trying, observing and asking intelligent questions. 


-- 
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.


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

Date: Mon, 09 Jun 2008 15:45:26 -0500
From: Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid>
Subject: Re: Good intro to perl to a "newbie to programming"
Message-Id: <qqqdnfb_FLv7C9DVnZ2dnUVZ_ovinZ2d@giganews.com>

On 2008-06-09, Joost Diepenmaat <joost@zeekat.nl> wrote:
> Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid> writes:
>
>> I am looking for a book on Perl that introduces it to a person who is
>> not a programmer, and offers a track along with exercises, etc. 
>>
>> That would be for someone who does not know any programming, so it
>> would need to explain a little more what is a "loop", "subroutine" and
>> similar things in more depth than a book for people who are
>> programmers already.
>>
>> Some useful recommendations would be appreciated. Thanks
>
> "Learning Perl" from O'Reilly might be what you're looking for, though
> IIRC it's not aimed squarely at non-programmers, it is a relatively
> gentle introduction and it includes exercises.

Great. 

> /getting slightly off topic/
>
> Is there a reason the "target" must start with perl? Perl's not that

yes, it is a new hire for a specific task based on perl. (not a
general programming position, more like to write a certain kind of
test scripts within a framework)

> hard to get started with, and it may be pretty good for whatever
> code it is (s)he's going to want to write, but I think there may be
> as good or better "pure introductionary programming" books that
> handle other languages.

That's because for most people perl is not the first language.

> OTOH, in my experience the best thing to do is to just start coding,
> and perl makes *that* at least pretty easy.

True, but it may presume a higher level of foreknowledge. 

-- 
   Due to extreme spam originating from Google Groups, and their inattention 
      to spammers, I and many others block all articles originating 
       from Google Groups. If you want your postings to be seen by 
         more readers you will need to find a different means of 
                       posting on Usenet.
                   http://improve-usenet.org/


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

Date: Mon, 9 Jun 2008 20:15:53 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Good intro to perl to a "newbie to programming"
Message-Id: <slrng4rle9.ejb.tadmc@tadmc30.sbcglobal.net>

Joost Diepenmaat <joost@zeekat.nl> wrote:
> Ignoramus25756 <ignoramus25756@NOSPAM.25756.invalid> writes:
>
>> I am looking for a book on Perl that introduces it to a person who is
>> not a programmer, and offers a track along with exercises, etc. 
>>
>> That would be for someone who does not know any programming, so it
>> would need to explain a little more what is a "loop", "subroutine" and
>> similar things in more depth than a book for people who are
>> programmers already.
>>
>> Some useful recommendations would be appreciated. Thanks
>
> "Learning Perl" from O'Reilly might be what you're looking for, though
> IIRC it's not aimed squarely at non-programmers, it is a relatively
> gentle introduction and it includes exercises.


From the Preface of the 4th edition:

    Though you don't need to know about Perl to begin reading this 
    book, we recommend that you have familiarity with basic 
    programming concepts such as variables, loops, subroutines, 
    and arrays, and the all-important "editing a source code file 
    with your favorite text editor." We don't spend any time 
    explaining those concepts.

So it appears to be aimed squarely at programmers.  :-)



"Elements of Programming with Perl" (Andrew Johnson) was
targeted at non-programmers though.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 9 Jun 2008 16:53:11 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Moving from delimited to XML
Message-Id: <d1712007-9733-4392-93cd-430be6dbac18@z72g2000hsb.googlegroups.com>

In most of my programs I use small tab or | delimited text to store
data (mostly because the data came from excel files to begin with).
These "databases" are usually only 10 - 15 fields per record and about
100 or so records, so the overhead in using a real database is not
needed.

Recently I have started using XML in other areas and realize that this
format would be more easily maintained then the text files. So the
question of the day, can someone point me to some simple XML
implementation in perl that wont take days to learn and includes some
commentary on how it works that is geared more to the layman?

As a more detailed example of what I  am hoping to accomplish, say I
have a simple tab delimited record in a file that contains a persons
address:

First Name\tLast Name\tStreet Address\tCity\tState\t\Zip

and I wanted to get all the zip codes in this file I would load:

open(FILE,"thefile.txt");
@data = <FILE>;
close(FILE);

foreach $record (@data)
{
@temp = split("\t",$record);
$zips[@zips] = $temp[5];
}

Now if I decided later to have 2 street addresses and a middle name
the above code would have to be altered. But I was thinking if it was
in XML and each entry looked like this:

<record firstname="John" lastname="Doe" address="123 Main"
city="Anytown" state="NN" zip="12345" />

and the psuedo code would be something like

open xml file
get number of records (elements)
for each record
load record
$zips[@zips] = value of  attribute named "zip"
next record

This would allow the XML file to be changed, more information added
etc without changing the code.

I know one of your are going to tell me what module to include - thats
fine, just hopefully it includes a good description.

Bill H


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

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


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