[28488] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9852 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 16 11:05:58 2006

Date: Mon, 16 Oct 2006 08:05:06 -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, 16 Oct 2006     Volume: 10 Number: 9852

Today's topics:
    Re: alarm() - SIGALRM sent too eariy? anno4000@radom.zrz.tu-berlin.de
    Re: Archive::Zip - end up with empty file ... <lev.weissman@creo.com>
        Archive::Zip - writeToFileNamed log? <lev.weissman@creo.com>
    Re: How to access a property within a class (reading news)
    Re: How to access a property within a class anno4000@radom.zrz.tu-berlin.de
    Re: howto detect printables in a string - norwegian cha <gladpike@hotmail.com>
    Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
    Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
    Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
    Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
        Issue with Schedule::Cron module on SunOS <saradhi.nc@gmail.com>
        Net::SSH:W32Perl also uses getpwuid! <mabounajm@gmail.com>
    Re: Output of Concise <bol@adv.magwien.gv.at>
    Re: sending ctrl+C to pipe process <joe@inwap.com>
        system command - redirect also the STDERR to a file <lev.weissman@creo.com>
    Re: trouble merging files using nested loop to read fil <tadmc@augustmail.com>
        URGENT NEED FOR PERL PROGRAMMER <gethaider@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Oct 2006 13:14:42 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: alarm() - SIGALRM sent too eariy?
Message-Id: <4pheu2Filja0U1@news.dfncis.de>

Peter J. Holzer <hjp-usenet2@hjp.at> wrote in comp.lang.perl.misc:
> On 2006-10-15 20:48, anno4000@radom.zrz.tu-berlin.de
> <anno4000@radom.zrz.tu-berlin.de> wrote:
> > Re-running the test I find that Time::HiRes 1.66 works correctly for
> > 2700 secs (Time taken (Seconds): 2699.98529100418), so if it's a
> > bug in Time::HiRes it appears to be resolved.
> 
> Actually I'd expect the bug to show up only for times of 4295 seconds or
> more, although the microsecond count might be interpreted as negative
> for times between 2147 and 4295 seconds which might also have weird
> results.
> 
> I've seen the bug with Time::HiRes 1.59 and 1.86, so I'd be surprised if
> it wasn't present in any version between them. It might be
> platform-specific, though: I have tested it only on Linux/i386, and I
> haven't looked at the source code yet.

Okay, I'll check again when I have a few hours :)

Anno


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

Date: 16 Oct 2006 05:25:39 -0700
From: "MoshiachNow" <lev.weissman@creo.com>
Subject: Re: Archive::Zip - end up with empty file ...
Message-Id: <1161001539.639606.127530@b28g2000cwb.googlegroups.com>


>
> my $status = $zip->addFileOrDirectory($NAME);
> print "Didn't work: $status" unless $status == AZ_OK;
>
> Paul Lalli

Thanks,did that.All statuses are zero,however still get "Bad
descriptors" on all directories operations...

(I convert all paths to use "/" slash,but using "\\" also did not
help...



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

Date: 16 Oct 2006 05:27:50 -0700
From: "MoshiachNow" <lev.weissman@creo.com>
Subject: Archive::Zip - writeToFileNamed log?
Message-Id: <1161001669.967314.134420@b28g2000cwb.googlegroups.com>

HI,

How do I get it to log? the whole operation is long and silent...Only
the exit code is available...
$zip->writeToFileNamed($ZIPNAME);

It's a long operation on big files,but I do not seem to manage to get
it's log...
Appreciate any advise.(Windows)
Thanks



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

Date: Mon, 16 Oct 2006 09:27:50 GMT
From: "Mumia W. (reading news)" <paduille.4059.mumia.w@earthlink.net>
Subject: Re: How to access a property within a class
Message-Id: <qgIYg.10075$Y24.8457@newsread4.news.pas.earthlink.net>

On 10/16/2006 01:59 AM, rose999 wrote:
> Hi all,
> I have a question as below:
> #------------------------------------
> #myPM.pm
> package myPM;
> [ simple question about accessing object data snipped ]

Read the perl documentation for which you can get an overview by doing this:

Start->Run->"perldoc perl"

These are some more perl documents you should read:
perldoc boot
perldoc toot


-- 
Mumia W.
paduille.4059.mumia.w@earthlink.net
This is a temporary e-mail to help me catch some s-p*á/m.


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

Date: 16 Oct 2006 13:31:26 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How to access a property within a class
Message-Id: <4phfteFise9dU1@news.dfncis.de>

rose999 <myrose999@gmail.com> wrote in comp.lang.perl.misc:
> Hi all,
> I have a question as below:
> #------------------------------------
> #myPM.pm
> package myPM;
> 
> my $aProperty;
> sub new
> {
> my $this = {};
> bless $this;
> return $this;
> }

The creator function should always use its first argument (a class name)
to bless the object.

> sub OneSub
> {
> my $this = shift;
> $this->{'aProperty'} = "something";
> }
> 
> sub TwoSub
> {
> $aProperty = "something";
> }
> #------------------------------------------------------------------
> I need using which sub for accessed "aProperty"? OneSub or TwoSub?

You have an object property and a class property here. OneSub accesses
(sets) the object property and TwoSub sets the class property.  Both
could make sense.  Whether you want one or the other (or both) can't
be decided without knowing what you want to do with your class.

Anno


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

Date: 16 Oct 2006 01:57:13 -0700
From: "RanLi" <gladpike@hotmail.com>
Subject: Re: howto detect printables in a string - norwegian characterset
Message-Id: <1160989033.869298.281730@e3g2000cwe.googlegroups.com>

anno4000@radom.zrz.tu-berlin.de skrev:
> J=FCrgen Exner <jurgenex@hotmail.com> wrote in comp.lang.perl.misc:
> > anno4000@radom.zrz.tu-berlin.de wrote:
> > > RanLi <gladpike@hotmail.com> wrote in comp.lang.perl.misc:
> > >> i have a problem. I need to detect printables in a string.
> > >> using perl and regular expressions.
> > >> problem is that I could have norwegian characters in this string, and
> >
> > > The meaning of "\w" is "all characters that can appear in a Perl
> > > identifier".  That excludes special national characters and includes
> > > "_".  That's not what you want.
> >
> > Could you please provide some reference?
> > I'm asking because this behaviour would be contrary to the documentation
> > where it is clearly stated:
> >
> >     If "use locale" is in effect, the
> >     list of alphabetic characters generated by "\w" is taken from the
> >     current locale.
>
> I was wrong then.  Thanks for the correction and sorry about the
> misinformation.
>
> >
> > > Define the characters you want to allow in an explicit character
> > > class:
> > >
> > >    /^[a-z=E6=F8=E5A-Z=C6=D8=C5]+$/
> > >
> > > If you have a locale that supports your characters,
> > >
> > >    use locale;
> > >    /^[[:alpha:]]+$/
> >
> > Why do you suggest [:alpha:] when the OP is explicitely asking for prin=
table
> > characters? Wouldn't [:print:] be better?
>
> He(?) said "printable" and used "/w".  I assumed he actually meant
> "characters that appear in the words of the language".
>
> Anno

HI,
Thank you all for helping me.
Sorry that I didnt understand my problem good enough to explain it in
more detail. Its not always that easy when beeing a noob :)

since i only need to verify that there is (at least) one printable
(visible) sign in the current line, I ended up with this code:
$line =3D~ s/^M//g;
print UTFIL "$line \n" if ($line =3D~ /[[:print:]]/ or $line =3D~
/[=E6=F8=E5=C6=D8=C5]/);

that way i get all the printables and the language spesific characters.

Do anybody see any problem with this code? is there a way to check for
printables and =E6=F8=E5 in the same match / / thingi..??

thanks for all the help so far :)



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

Date: 16 Oct 2006 07:03:46 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161007426.120010.245220@k70g2000cwa.googlegroups.com>

Hi Micro,

I think I understand your code - the new thing for me is where you use
a comparitive operator =~  in a functional replace way with a s///g
construct.  I've not seen that in the examples I've read to date.

Also, my actual goal is to replace <form> </form> tags that have
multi-lined data in between and apparently the original code I posted
had a requisite which was the necessity to slurp the whole file into a
single variable because, (do you agree with this), regex can't process
multi-line data using while or for each loops.

This limitation seems improbable as it seems I've seen a number of
multi-line perl code parsers...but it may have been through the lense
of my "pre-evolved" Perl brain.

Thoughts?

L,
Samiam

Mirco Wahab wrote:
> Thus spoke samiam@mytrashmail.com (on 2006-10-14 02:59):
> > After about 6 months more of study...I might be able to replace a
> > simple string. Dang!
>
> I tried to think about what the real problem
> here is and came up with th program below,
> which is, what I think - your major hurdle.
>
> All you probably want -- can be boiled down
> to the following:
>
>
>    use strict;
>    use warnings;
>
>    my $intext = q{
>      A B C Cereals C B A
>      D E Cereals E D
>      F G Cereals Z Z
>    };
>
>    my $orgtext = 'Cereals';
>    my $newtext = 'Samiam';
>
>    $intext =~ s/$orgtext/$newtext/g;
>
>    print "Text is now:", $intext;
>    print "Searching for '$newtext'\n";
>
>    while( $intext =~ /$newtext/g )  {
>       print "got one '$newtext' at position $+[0]\n";
>    }
>
>
>
> You have a 'text file' $intext and want
> to replace sth. (Cereals by Samiam) You
> should probably stick to this example and
> try to understand it.
>
> Then, you may have done the first step
> in solving your whole problem.
> 
> Regards
> 
> Mirco



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

Date: 16 Oct 2006 07:10:29 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161007829.907454.159510@m7g2000cwm.googlegroups.com>


Hi Tad,

My bad. I just didn't clean up the comments for my app. It is
definitely an html file.

I have poured over the perldocs, though very rapidly searching for
useful to my app bits.

Thanks for the advice about the slashes. But I wonder if that will even
make the glob <file> function work with Perl32 from Active state.

The glob function on my Active State  on win32 doesn't seem to be able
to handle much beyond a <*> kind of usage.

#Globbing Example
#@ = <'C:\temp\data_audit_files\'>;
#@files = <*.vbs>;
foreach $file (@files) {
  print $file . "\n";
}

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

I tried so many variations while I'll spare you. But do you know if the
<*> glob function can use anything more than a *.vbs or * kind of
entry?

Contrary to the funny guy's post below, I am not just typing random
characters, though that makes me smile every time I think about it.  I
am digesting as many tuts as possible...but have so many projects,
memory and complete understanding are not coming as a dedicated effort
would yield.

L,
Samiam

Tad McClellan wrote:
> samiam@mytrashmail.com <samiam@mytrashmail.com> wrote:
>
> > My new code is still as useful as a no mouth dog at a frisbee contest:
>
>
> That's because the part that is supposed to do the work is commented out.
>
> Have you seen the Posting Guidelines that are posted here frequently?
>
>
> > my $infile = 'C:\russ\weights\preg.htm';
>
>
> You don't need to use silly slashes. This will work just fine:
>
>    my $infile = 'C:/russ/weights/preg.htm';
>
>
> > #while ($intext) $intext = {s/$orgtext/$newtext/ms;}
>              ^^^^     ^^^^          ^^^^     ^^^^
> > # the ms is for coping correctly with newlines (that can easily appear
> > in a binary).
>
>
> If it is binary you should not keep calling it text.
>
>
>
> [ snip TOFU. Please learn the proper way of composing a followup. Soon. ]
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



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

Date: 16 Oct 2006 07:25:11 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161008711.263691.144300@i3g2000cwc.googlegroups.com>


Comments inline jjjjjjjjjjjjj: comment

Tad McClellan wrote:
> samiam@mytrashmail.com <samiam@mytrashmail.com> wrote:
>
> > But I am just beginning Perl,
>
>
> Then you should probably ask for all the help that you can get.
>
> Put
>
>    use warnings;
>    use strict;
>
> at the top of every program you write, and perl will find
> many of your bugs for you.
>
>
> Have you read a basic tutorial such as "Learning Perl" yet?
>
> See also http://learn.perl.org
>
>
> > My task is sooo deceptively simple: Just replace a simple string with
>
>
> (your strings are not as "simple" as you think.)
>
>
> > another string. How hard could that be?
> >
> > My data file is here: http://home.comcast.net/~tankomail/preg.htm
> > And a sample is at the very bottom of this post. I just want to replace
> > /<form[.*]?*\/form>/ with the word "block"
>
>
> That is not a "simple string". That is markup. A robust solution
> requires a Real Parser rather than a pattern match (which is only
> good for a dirty hack).

jjjjjjjjjjjjjjj: Well, with all the examples I've read in the tutorial,
ie perdocs, I felt drunk with power and thought regexes could easily
handle any string multi-line or not.

>
> Why did you include the square brackets?
>
> They are not doing what you think they are doing.


jjjjjjjjjjjjjjjjjj: I just love this line - "They are not doing what
you think they are doing."

I thought the brackets isolated that inside them as a whole to apply to
the first precedent. I thought I read this in the perl docs.



>
>
> > Basically I just want to replace all <form> </form> fields and
> > everything in between with nothing, but in testing, I wanted to see my
> > work so I chose the word "block" as a good simple substitute which I
> > could then replace with nothing.
>
>
> > $orgtext = Whey;  # this one right here
>
>
> Is that a string with no quotes, or is that a function call?


jjjjjjjjjjjjjjjjjjjjjjjj: String no quotes.


>
> You should put quotes around your strings. If you had a function
> named Whey() defined, then it would be called here and its return
> value would be stored in $orgtext.

jjjjjjjjjjjjjjjjjjjjjj: I know... but in my tiny patch work programs
with no functions and only a smidgen of lines...I am likely to be as
sparse and functional as possible if their are no negative rams.
No...not male goats with bad attitudes.


>
> "use strict" will enforce putting quotes around your strings.
>
>
> > $newtext = Popcorn;
> >
> > The above works. I reduced it to it's simplest form as a sanity check.
> > Then I tried:
> >
> > $orgtext = /[Ww]hey/;  # this one right here
>
>
> "use warnings" would have helped you here. I expect you meant
> this instead:
>
>    $orgtext =~ /[Ww]hey/;


jjjjjjjjjjjjjjjjjjjjjjjjjj: Well...actually I was using the assign
operator deliberately to pop the whey into the $orgtext.   My pre/post
processing of $orgtext I think is what's lacking.



>              ^
>              ^
>
> > $newtext = Popcorn;
> >
> > But beyond the most primitive replacement, I invariably get:
> >
> > Use of uninitialized value in pattern match (m//) at
> > C:\russ\scripts\_Master_Snippets\clean_2_input_output_file.pl line 9.
>
>
> Oh. You _are_ using warnings.


jjjjjjjjjjjjjjjjjjjjjjj:  See? I am a pro!  Want to hire me to code the
next space shuttle launch?



>
> The uninitialized value is in $_.
>
> Since you don't have a proper binding operator (=~) the pattern
> is NOT attempting to match against the string in $orgtext, it
> is trying to match the string in $_, and it appears you do not
> have a string in there.

jjjjjjjjjjjjjjjjjjjjjj: but since I was not trying to match...to
assign.....

>
> You inserted a bug, and "use warnings" found it for you!
>
>
> > Eventually I want to try:
> >
> > $orgtext = /<form[.*]?*\/form>/;  # this one right here
> > $newtext = block;
> >
> > But I can't get past the staring blocks. I know this code works in
> > general,
>
>
> There is no way this code works. It has multiple errors in it.


It's someone else's and with simple code, ie. basic words....it worked
great for me. It was just in the modifying to parse multi-line html
that I had the problem. But from my reading, I understand a dedicated
parser is best, but for a tiny little job like this, and considering
the awesome might and claims and indeed history of plain regex, I saw
no reason I couldn't just use this code to do the task.



>
>
> > Any suggestions as to:
> >
> > 1.) Is my basic model okay, slurping the whole file into a variable? or
> > 2.) Should I use a while <> structure?
>
>
> That depends on whether or not you need to match across multiple lines.
>
> If you _need_ multiple lines then slurping is good, else line-by-line
> is better.


jjjjjjjjjjjjjjjjjjjjjjjjjj: Yup... defintely need multiple lines since
the <form> tags span quite a few lines and characters.

I am surprised there isn't just a:

Start at <form
read until one gets to </form> regardless of /n /t or anything else
remove all of it.

If this is not simple...it should be. Maybe I am talking like an
idyllic martian...but this kind of basic read until string and remove
it all function should be added if not extant now.


>
>
> > And even when I do get the simple Whey replaced with Popcorn - it only
> > does the first instance, basically, I am guessing, because there is no
> > iterative code in this script.
>
>
> You should read about the pattern match operator in perlop.pod if
> you are having trouble using the pattern match operator.
>
> It tells how to make a pattern find all occurrences.


Hmmm....I will find this mystical all occurance switch. I just wish
Master Regex 3rd addition was more reference like and less anecdote
chatty. Finding a specific piece of info in that Arthur Miller Play is
daunting.




>
>
> > Your input and examples are GREATLY appreciated because the red spot on
> > my banging against the cubicle wall head is growing.
>
>
> ----------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> use LWP::Simple;
>
> my $html = get 'http://home.comcast.net/~tankomail/preg.htm';
>
> $html =~ s#<form .*?</form>#BLOCK#sg;  # use alternate delimiters
>
> print $html;
> ----------------------------
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



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

Date: 16 Oct 2006 07:48:30 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161010110.601007.273320@e3g2000cwe.googlegroups.com>

comments inline like this jjjjjjjjjjjjjjjjjjjj:
Paul Lalli wrote:
> samiam@mytrashmail.com wrote:
> > My data file is here: http://home.comcast.net/~tankomail/preg.htm
> > And a sample is at the very bottom of this post. I just want to replace
> > /<form[.*]?*\/form>/ with the word "block"
>
> That pattern is not what you think it is.  It is searching for "<form",
> possibly followed by either a period or a star, followed by "/form>".
> Is that what you meant?  I'm guessing you wanted "<form" followed by
> any amount of anything, but only as much as is necessary, followed by
> "/form>".  That's:
> /<form(.*?)\/form>/

jjjjjjjjjjjjjjjjjjjjjjjj:
Thank you...I got my brackets confused :\



>
> > Basically I just want to replace all <form> </form> fields and
> > everything in between with nothing, but in testing, I wanted to see my
> > work so I chose the word "block" as a good simple substitute which I
> > could then replace with nothing.
> >
> > Way Below is my base code. But here, just under is the pulled line from
> > the base code that seems to be the issue:
> > $orgtext = Whey;  # this one right here
> > $newtext = Popcorn;
>
> If you're using those pieces of code, you must not be using warnings.
> Please start doing so.  They will catch 90% of the errors you're
> making.  In particular, they will tell you you should be quoting your
> strings, not using barewords.  Additionally, please make sure you use
> strict, which will force you to declare your variables.

jjjjjjjjjjjjjjjjjjjjjjj:
So many examples, most of them, don't seem to declare their variables,
even in the perldocs.  what benefit is there...aren't they
auto-declared when a value is assigned to them?  I know in vbscript one
must declare or dimension...but I thought Perl was free from that
contraint?  Again...so many examples don't seem to??




>
> my $orgtext = 'Whey';
> my $newtext = 'Popcorn';
>
>
> > The above works. I reduced it to it's simplest form as a sanity check.
> > Then I tried:
> >
> > $orgtext = /[Ww]hey/;  # this one right here
> > $newtext = Popcorn;
> >
> > But beyond the most primitive replacement, I invariably get:
> >
> > Use of uninitialized value in pattern match (m//) at
> > C:\russ\scripts\_Master_Snippets\clean_2_input_output_file.pl line 9.
>
> Which is the correct warning message for the line of code you typed.
> You using a pattern match, but not binding the pattern match to any
> variable (using the =~ operator).  Therefore, you are matching that
> pattern against the $_ variable.  The $_ variable does not currently
> have a value, and so Perl warns you to that effect.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
Paul - this was said VERY well. It clicks now.  It was said before, but
you were a bit more thorough and pedagogish. :)


>
> If $orgtext is supposed to be a string that will eventually be used in
> a regular expression, then make it a string:
> my $orgtext = ' [Ww]hey';
> If $orgtext is supposed to be a regular expression that you will
> pattern match against, make it a pattern match:
> my $orgtext = qr/[Ww]hey/;
>
>
> > Eventually I want to try:
> >
> > $orgtext = /<form[.*]?*\/form>/;  # this one right here
>
> Once again, that's assigning $orgtext to be the result of matching $_
> to that pattern.  And once again, your pattern isn't what you think it
> is.  See above.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
Oops..you lost me again in that I thought an tacit comparison was
always made to $_ in the absence of an explicit =~ comparison.  But
that line above seems to be the most basic assignment statement like
I've seen in myriad examples, albeit with a fault [.*] bracket bit
needing to be corrected.

In the same way I could assign a string to $orgtext, can't I assign a
regex to it for comparison to another variable or string later in the
script?


>
>
> > $newtext = block;
> >
> > But I can't get past the staring blocks. I know this code works in
> > general, but my modifications seem to break it.
>
> No, the code really doesn't work in general.  The code you claimed
> worked was assigning two strings (albeit in their bareword versions) to
> a variable.  Then you suddenly stopped doing that and started assigning
> the result of a pattern match to that variable, using the //
> delimiters.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
yes...I see your point and also possibly validation of assigning the
result of a pattern match to a variable?  Or is the distinction "result
of a pattern match" vs assigning the regex pattern itself to a
variable?


>
> > I also tried some while (<$intext>) variations, even removing the undef
> > $/ slurp line, so that the intext would receive the data line by line -
> > but no luck anywhere.
>
> "Throw it at the wall and see what sticks"  is rarely a good method of
> programming. Look at the warning message, figure out what it's telling
> you, and research that.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

Yes...it's a bit of spaghetti on the wall, but based on the 50 or so
pages I've read of the perldocs. It all makes so much sense in the
docs...and the code on the page matches the logic in my head. I feel
like I can program an auto air-traffic control collision deterance
system based on my 50 pages. But...apparently some pilots aren't happy
with the system. Hey...there are more planes where those came from.

But yes...point taken. Read up or clam up. Understood. I have quite a
library of Perl books, but all the O'Reilley books are these talkative
friendly Alice in wonderland meets it's a small world rambles.  I am
used to Linux book where a rule is stated tersely, an example given -
DONE!!!    The perldocs are this way and are beloved by me.  If I had 2
lifetimes...sure....teach me via anecdotal valley girl talk.  But I
have so little time...is there a book that just gives a brief
explanation of code snippets, a few examples of each, and we're off?
Kind of like the orignal Bjorn C books.





>
> > I have spent quite a bit of research time trying
> > various things - but apparently it's not a trivial task.
>
> Yes, it really is.  Instead of randomly typing code without knowing
> what you're doing, your "research time" would have been better spent
> actually doing research.  Please read some basic Perl documentation.
> In this case, start with:
> perldoc perlretut

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
Your "randomly typing code" line makes me warm all over. I love a funny
good critique!!!

I am a little guilty of benefitting from random code. It often works?
I once got a BMW to add 50 horsepower by randomly programming his chip,
albeit the horsepower only lasted until a piston was thrown 10 minutes
later. :(  Random code is a roller coaster ride of fun!



>
> > Any suggestions as to:
> >
> > 1.) Is my basic model okay, slurping the whole file into a variable? or
> > 2.) Should I use a while <> structure?
>
> In general, you don't want to slurp unless you actually need to. In
> this case, however, you do need to, because your pattern spans more
> than one line of the file.  So no, you cannot use the while() loop
> approach in your case.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
why can't while span lines?  can't it be told to process until /n or
something? I know there are all sorts of catchall whitespace /t /n /r
characters to account for this?  Again...something in my reading...but
it's all a blur...walls closing in....usb drive OVERHEATING!!!!



>
> > And even when I do get the simple Whey replaced with Popcorn - it only
> > does the first instance, basically, I am guessing, because there is no
> > iterative code in this script.
>
> STOP GUESSING.  READ.  LEARN.  Read the documentation I pointed you to
> above to see how to make a s/// operation replace all instances of a
> pattern.  Again, it's trivial, but you are not going to learn how to do
> it by just guessing and typing random characters.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
Yes...I am guessing a bit, but truly...honestly...based on lots of
reading and scouring examples. My code was VERY CLOSE to working wasn't
it? Wasn't it just a minor detail or two wrong?

But I am heeding your advice and will tatoo the perdocs to my arms.  I
really am reading a lot...as time permits...it's just that I'm trying
to also be productive along the way...WITH A LITTLE HELP FROM MY
FRIENDS.

Hey...when I get "My First Air Collision Deterrant" system
coded...purely in Regex...would you like to be my test passenger?  We
lost our first beta batch. Shhhhh.





>
> > And the only iterative examples I've
> > seen are not with a whole file in one "intext" variable, but always
> > with a while <> structure.
>
> Massive red herring.  Examples using while(<>) would have the same
> problem if the pattern appeard twice on the same line.  Only the first
> on each line would be replaced.

jjjjjjjjjjjjjjjjj: Now this seems true, but entirely addressable? Isn't
there a way to match 1st and 2nd and x occurances per line or spanning
lines?



>
> > Your input and examples are GREATLY appreciated because the red spot on
> > my banging against the cubicle wall head is growing.
>
> Your cranium would suffer less damage if you took the time to read the
> documentation instead of using a trial-and-error approach.
>
> Paul Lalli

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
Thank you Paul

L,
Samiam



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

Date: 16 Oct 2006 00:20:51 -0700
From: "Saradhi" <saradhi.nc@gmail.com>
Subject: Issue with Schedule::Cron module on SunOS
Message-Id: <1160983251.558269.6530@i3g2000cwc.googlegroups.com>

Hey

I am using SunOS 5.6 and Perl 5.8.6 and Schedule::Cron module doesn't
seem
to be working fine :(

Though my code works fine in linux boxes, the cron daemon  process
simply
dies in Sun box.

After analysis I came to conclusion that the line:
$0 = "Schedule::Cron MainLoop - next: ".scalar(localtime($time));
in Schedule::Cron is causing the issue and commenting that line out
seems to
fix the issue.

When  I start the cron on the Sun box, it seems to be writing the cron
pid
in the .pid file but immediately the process dies.

Any clues on this?

Thanks in advance!



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

Date: 16 Oct 2006 00:38:48 -0700
From: "enigma" <mabounajm@gmail.com>
Subject: Net::SSH:W32Perl also uses getpwuid!
Message-Id: <1160984328.221363.319020@h48g2000cwc.googlegroups.com>

I am a new Perl user trying to setup an SSH connection using Perl. So I
first downloaded the Net::SSH:Perl package. Since I am a Windows XP
user, the getpwuid function didn't work. I googled and found that
Net::SSH:W32Perl solves that problem. But when i downloaded
Net::SSH:W32Perl, and opened the W32Perl.pm file, i found that it uses
the Perl.pm file which uses the getpwuid function. and Thus i still get
the same error:

The getpwuid function is unimplemented at
C:/Perl/site/lib/Net/SSH/Perl.pm line 110.

Please help me in this issue.. 

Mazen



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

Date: Mon, 16 Oct 2006 10:19:20 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: Output of Concise
Message-Id: <1160986760.408781@proxy.dienste.wien.at>

Ben Morrow:

> The problem was not that the question appeared to be stupid, but rather
> that the answer is only to be found by grovelling aroung in the source.

Well, maybe there's people who is able to answer without grovelling
or just with some few lookups. I never wanted someone spend hours
for answering my questions.

> You appeared to be asking others to do that for you since you couldn't
> be bothered yourself.
>
> Maybe I was a little harsh, but I really think that if you don't
> understand the code well enough to figure things like this out for
> yourself then you don't know enough to make use of them.

Not understanding C code doesn't necessarily mean not understand
the internals of Perl too (like targets or scratchpads).

> > Reading almost completely uncommented source code is easy
> > for one person only - the one who wrotes the code.
>
> I disagree. Well, maybe it's not *easy*; understanding something complex
> is never easy. I don't think it's substantially harder than reading an
> 800-page book on the subject, though: in the end, you have to understand
> what the code does.

I disagree. Reading a book is always easier than hacking almost
completly undocumented code, especially when this code is made
with a lot of #ifdef's and partially _very_ complex macros.

> What do you hope to do with this information? (This is a serious
> question. I am having a hard time coming up with a use you could put it
> to that *doesn't* require you to have read and understood the source.)

As I wrote, I want to understand the internals of Perl better. You can
call it curiosity, but it's more than that...I just want to find out how the
parser works and which opcode does what under which circumstances.

>> BTW: would it have been so hard for the author of B::Concise
>> to add your explantation to the modules docs?
>
> It wouldn't have been *hard*, but I don't think it would have been
> *useful*, either.

Why not? There's a module which provides output, which is mentioned
at various places in the perldoc, it includes a documentation describing
its behaviour and its options, but not its output. Does this makes sense?

> Sometimes things are left intentionally undocumented,
> as a way of keeping people from playing with things they don't
> understand properly.

Why 'playing'? 'Playing' will occur when someone tries to find out what
code will do and how its output should be interpreted because of lack
of documentation. If there would be docs, there wouldn't be need to
"play".

It's just like "I'll give you some useful tools but you have to find out
yourself how to work with them" - this makes a lot less sense that the
"playing" you mentioned.

When writing code, it was always one of my principles, not only to
describe what the code does, but also, how the output it may generate
(including error messages) must be interpreted, including a lot of
commented examples.

Greetings, Ferry

-- 
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: bol@adv.magwien.gv.at




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

Date: Mon, 16 Oct 2006 02:52:22 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: sending ctrl+C to pipe process
Message-Id: <z8-dnf15OboHy67YnZ2dnUVZ_o6dnZ2d@comcast.com>

linbox wrote:
>     if ($pid) {  # parent
>         print "parents pid = $pid \n";
>         sleep (5);
>         $result=kill (9,$pid);

      if ($pid) { # running as the parent
         print "Child's pid = $pid (my pid = $$)\n";
         sleep 5;
         $result = kill(2,$pid) || kill(3,$pid);  #SIGINT, SIGQUIT
	sleep 1;
	kill(0,$pid) and kill(9,$pid);	# SIGKILL if not yet gone


> The variable $pid is still different than the pid of sox.

Probably because 'rec' is not 'sox'.  If 'rec' is a shell script,
then: 1) 'sox' will have a different pid, and 2) sending a nice
signal (not SIGKILL) to 'rec' should be sufficient to get 'rec'
to forward that same signal to 'sox'.

Try this on another window/session:
   pstree; ps axj | egrep 'PPID|rec|sox'

	-Joe


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

Date: 16 Oct 2006 05:26:21 -0700
From: "MoshiachNow" <lev.weissman@creo.com>
Subject: system command - redirect also the STDERR to a file
Message-Id: <1161001581.232047.303950@i3g2000cwc.googlegroups.com>

HI,

Running an AciveState on W2K,I dod not manage to redirect also the
STDERR to a file.STDOUT is in the file "COPY",STDERR is not.

system("xcopy /f /y $_ >COPY 2>&1") ;

Appreciate any help.



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

Date: Mon, 16 Oct 2006 07:27:03 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: trouble merging files using nested loop to read files
Message-Id: <slrnej6ukn.8rr.tadmc@magna.augustmail.com>


[ text rearranged into chronological order ]


theshowmecanuck <theshowmecanuck@no_yahoo_spam.com> wrote:
> Tad McClellan wrote:
>> theshowmecanuck <theshowmecanuck@no_yahoo_spam.com> wrote:
>> 
>>> for $serviceRecord (<FILTERED_SORTED_SERVICE_FILE>) {
>> 
>> 
>>    while ( my $serviceRecord = <FILTERED_SORTED_SERVICE_FILE> ) {
>> 
>> 
>> Reading the entire file into memory when you only need a line at
>> a time in memory is just plain wasteful.
>> 
>> 
>> 
>> [ snip TOFU. Please don't do that.]
                ^^^^^^^^^^^^^^^^^^^^
                ^^^^^^^^^^^^^^^^^^^^  !!

If you don't know what you are being asked to do, then ask what
you are being asked to do.

Please learn the proper way of composing a followup. Soon!

Do not quote an entire article, just quote the parts that you
are going to comment on.

Interleave your comments immediately following the quoted text that
you are going to comment on.

Have you seen the Posting Guidelines that are posted here frequently?


> Never mind... you are talking about the outer loop.


Yes, that is why I snipped everything about the inner loop and
quoted only stuff from the outer loop.

See how easy it is to keep things straight when the followup is
composed in a sensible manner?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 16 Oct 2006 02:57:19 -0700
From: "Haider" <gethaider@gmail.com>
Subject: URGENT NEED FOR PERL PROGRAMMER
Message-Id: <1160992639.722637.22120@k70g2000cwa.googlegroups.com>

Hi All

Please help me in filling this position of Perl Programmer for  MNC
Client of mine the  Position is based in Hyderabad.

Please feel free to  give my contact details to  any one who is willing
to relocate or looking for a change.


Thank you for the help


Regards



Haider Abbas - Manager - (OP)
Prolific Technologies
Phone: 40 27804004
Mobile: 0 998 555 6511
Email: haider@prolifictechnologies.com



Reach me @ reachhaider (Yahoo/MSN)



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9852
***************************************


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