[28445] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9809 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 6 00:06:03 2006

Date: Thu, 5 Oct 2006 21: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           Thu, 5 Oct 2006     Volume: 10 Number: 9809

Today's topics:
        AJAX blocking selecting dropdown value with WWW::Mechan <thedifferenz@gmail.com>
    Re: Archive::Zip - zip file has "invalid" format usenet@DavidFilmer.com
        Complex regular expression jayanthigk2004@yahoo.com
    Re: FAQ 5.2 (Was: inserting lines) jgraber@ti.com
    Re: Hard or Easy? To find string, then grab criterion m <tadmc@augustmail.com>
    Re: How to handle Windows file names under Linux? - SOL <some@body.com>
    Re: How to handle Windows file names under Linux? - SOL <wahab@chemie.uni-halle.de>
        How to handle Windows file names under Linux? <some@body.com>
    Re: How to handle Windows file names under Linux? <someone@example.com>
        New CPerl (Emacs mode for Perl) available <nospam-abuse@ilyaz.org>
        newbie cspan example question ToddAndMargo@gbis.com
        newbie structure question ToddAndMargo@gbis.com
        Notify parent that a background process failed <patty_rv@hotmail.com>
    Re: Notify parent that a background process failed usenet@DavidFilmer.com
    Re: Regarding numeric literals <Jim@Gibson.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Oct 2006 18:50:01 -0700
From: "thedifferenZ" <thedifferenz@gmail.com>
Subject: AJAX blocking selecting dropdown value with WWW::Mechanize
Message-Id: <1160099401.100939.164190@i42g2000cwa.googlegroups.com>

Hi,

I am trying to click a button on a form with two drop downs.

1st Drop down State_Select, this drop down contains two letter
abbreviation of all states, with default 'Select a State'.

2nd Drop down County_Select's value is dynamically loaded by AJAX when
a state is selected in 1st drop down.


All I want to do is, select 'CA' in first drop down, and Los Angeles in
second dropdown and click.

======================
$mech->select('State_Select','CA');
$mech->select('County_Select','Los Angeles');
$mech->click('search');
======================

I am getting this error when I execute the code
==========
Illegal value 'Los Angeles' for field 'County_Select' at
 ..site/lib/WWW/Mechanize.pm line 1199
==========


Question:
Is there any way to tell Mechanize not to check if the dropdown value
is valid or not?

thanks in advance,
Vijoy~



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

Date: 5 Oct 2006 16:02:36 -0700
From: usenet@DavidFilmer.com
Subject: Re: Archive::Zip - zip file has "invalid" format
Message-Id: <1160089356.850607.43200@i3g2000cwc.googlegroups.com>

Mumia W. (reading news) wrote:
> I'm just guessing here, but according to his message, zip files cannot
> contain files larger than 4GB (paraphrased and interpreted)

Or some filesystems (such as standard JFS on AIX) have a 2-GB filesize
limitation.



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

Date: 5 Oct 2006 18:54:07 -0700
From: jayanthigk2004@yahoo.com
Subject: Complex regular expression
Message-Id: <1160099647.398820.249260@i3g2000cwc.googlegroups.com>


Is it possible to write a regular expression for this ?

Pattern: 999-99-999


Where 9 is any number from 0 to 9


However the user need not enter ALL the digits and dashes as given in
the format.


Whatever numbers and dashes he had entered must match the above format,

from left to right, for only the charcters he has entered.


For example
9
99
999
999-
999-9
999-99
999-99-
999-99-9
999-99-99
999-99-999


Any of the above should result in a match


Next, he can also put * before or after or before and after any of the
above combination


Ex


*9
*99
*999
*999-
*999-9
*999-99
*999-99-
*999-99-9
*999-99-99
*999-99-999


Or


9*
99*
999*
999-*
999-9*
999-99*
999-99-*
999-99-9*
999-99-99*
999-99-999*


Or


*9*
*99*
*999*
*999-*
*999-9*
*999-99*
*999-99-*
*999-99-9*
*999-99-99*
*999-99-999*


Any help is much appreciated.


Reply =BB


 From:  jayanthigk2...@yahoo.com - view profile
Date:  Thurs, Oct 5 2006 6:52 pm
Email:   jayanthigk2...@yahoo.com
Groups:   microsoft.public.dotnet.languages.csharp
Not yet ratedRating:
show options
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author


Is it possible to write a regular expression for this ?

Pattern: 999-99-999


Where 9 is any number from 0 to 9


However the user need not enter ALL the digits and dashes as given in
the format.


Whatever numbers and dashes he had entered must match the above format,

from left to right, for only the charcters he has entered.


For example
9
99
999
999-
999-9
999-99
999-99-
999-99-9
999-99-99
999-99-999


Any of the above should result in a match


Next, he can also put * before or after or before and after any of the
above combination


Ex


*9
*99
*999
*999-
*999-9
*999-99
*999-99-
*999-99-9
*999-99-99
*999-99-999


Or


9*
99*
999*
999-*
999-9*
999-99*
999-99-*
999-99-9*
999-99-99*
999-99-999*


Or


*9*
*99*
*999*
*999-*
*999-9*
*999-99*
*999-99-*
*999-99-9*=20
*999-99-99*=20
*999-99-999*=20


Any help is much appreciated.



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

Date: 05 Oct 2006 16:41:55 -0500
From: jgraber@ti.com
Subject: Re: FAQ 5.2 (Was: inserting lines)
Message-Id: <yvn4puie8yk.fsf@famous02.dal.design.ti.com>


brian d  foy <brian.d.foy@gmail.com> writes:

> In article <yvnhcyjy3yv.fsf@famous02.dal.design.ti.com>,
> <jgraber@ti.com> wrote:
> 
> > brian d  foy <brian.d.foy@gmail.com> writes:
> > 
> > > In article <031020061558043174%jgibson@mail.arc.nasa.gov>, Jim Gibson
> > > <jgibson@mail.arc.nasa.gov> wrote:
> > 
> > > The basic idea of inserting, changing, or deleting a line from a text
> > > file involves reading and printing the file to the point you want to
> > > make the change, making the change, then reading and printing the rest
> > > of the file. Perl doesn't provide random access to lines (especially
> > > since the record input separator, C<$/>, is mutable), although modules
> > > such as C<Tie::File> can fake it.

I hadn't considered mutable line sep,
The opposite of read is write, although 'print' matches the Perl function.

Here is an alternate text suggestion that mentions copy, slurp, rename,
binary edits, and random access to bytes.
-- begin quote --

The basic idea of inserting, changing, or deleting a line from a text
file involves 
 - reading from the original input file, 
 - modifying as necessary,
 - writing the data to a new output file.
 - possibly renaming the new output file onto the original input file.

If you read the whole original input file into memory before you
modify it, thats known as 'slurping'.

If you slurp the input file and modify it in memory,
then you could write the modified data back to the original file,
if you don't mind at the small risk some finishing incompletely.

Its safer to write to a new file, then rename the new file
to the original name, as done by Module IO::AtomicFile.

While slurping the file is the best or only way to do some kinds
of changes, large files will use large amounts of memory, which 
may cause poor system performance on multi-tasking systems.
Many changes can be made while reading, modifying, and writing
one line at a time, which has much lower memory requirements that 
slurping the whole file at once.

Note that Perl is "8-bit-clean", which means you can easily modify
binary data:  for example, you can search and replace a sequence of bytes
with a different sequence. 

Perl doesn't provide random access to lines (especially
since the record input separator, C<$/>, is mutable), 
although modules such as C<Tie::File> can fake it.
Perl does provide random read/write access to bytes.

-- end quote --

-- 
Joel


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

Date: Thu, 5 Oct 2006 18:08:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Hard or Easy? To find string, then grab criterion matched lines above and below?
Message-Id: <slrneib43v.9e3.tadmc@magna.augustmail.com>

samiam@mytrashmail.com <samiam@mytrashmail.com> wrote:

> I know this is a trivial parse / grep job for any Perl rake worth his
> salt, but does anyone have guidance on how this Perl newbie might pull
> a string from one file and use this string to pull the lines in another
> file out, and also pull the first line before (matching criteria) and
> the first line after (matching criteria.)


If you show us the code you have so far, we will help you fix it.


> At first I thought to use VBScript, but then I realized that Perl is
> portable, doesn't necessarily have to  be installed on the server, and


What "server"?

A server is not normally required to run Perl programs.

Is this a stealth CGI question?

If it is a CGI question, then you _do_ need to have perl installed
on the web server.


> Summary: I need to find CSR numbers in FILE-A that map to registry key
> entries in FILE-B, and report the pertinent surrounding info.


None of the failed CSR numbers in your example FILE-A map to any registry
key entries in FILE-B, so the program must make no output...


> a.) find the lines in *.aud files with "Fail" in them
> b.) Extract the Section number from the beginning of that same line.


Here's how to do that part:

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

while ( <DATA>) {
   my($csr, @fields) = split /~/;
   next unless grep { $_ eq 'FAIL' } @fields;
   print "$csr\n";

}

__DATA__
5.2.4~Local Printers Shared~NA~PASS~NA
5.8.1~FTP Server Installed~NA~PASS~NA
5.6.2~POSIX Subsystem Installed~PASS~PASS~
5.2.2~Posix Subsystem File Components - Posix.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxss.exe Not Found~NA~PASS~NA
5.2.2~Posix Subsystem File Components - Psxdll.dll Not Found~NA~PASS~NA
5.6.1.1~NetMeeting Disable Remote Desktop Sharing~FAIL~FAIL~
5.6.1.2~IE Security Zones are Local Only~FAIL~FAIL~
5.6.1.2.2~Allow User to Change IE Sec Policy~FAIL~FAIL~
5.6.1.2.3~IE Security Zones Map Editing~FAIL~FAIL~
5.6.1.2.4~IE Proxy Settings Set Per User~FAIL~FAIL~
5.6.1.2.5~IE Automatic Installs Disabled~FAIL~FAIL~
5.6.1.2.6~IE Software Update Check~FAIL~FAIL~
-----------------------------------------------



> Then use that CSR# to pull from a 2nd *.dsc file :


I would have done that part too, but I could not be troubled
to come up with a meaningful data file (and neither could you,
it would appear).


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


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

Date: Thu, 05 Oct 2006 19:37:45 -0400
From: somebody <some@body.com>
Subject: Re: How to handle Windows file names under Linux? - SOLUTION
Message-Id: <UfOdnY83Y8bUCrjYnZ2dnUVZ_sidnZ2d@giganews.com>

On Thu, 05 Oct 2006 19:11:11 -0400, somebody wrote:

> I have a perl script that I need to pass some files to via
> the command line under Linux.  The file names may contain
> single quotes and or ampersands like:
> 
> This ain't a linux file.mp3
> This is file 1 & file 2.mp3
> 
> 
> How can I handle the above 2 file names in a perl
> script running under Linux?  I haven't tried yet,
> but I don't believe simply enclosing them in single
> quotes or back tics 0will work like:
> 
> 'This ain't a linux file.mp3'
> 
> 
> -Thanks


So far, all I need to do is enclose the file name in
double quotes, and the perl script handles it without
any problems.  I didn't think it would be that simple!





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

Date: Fri, 06 Oct 2006 01:56:49 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: How to handle Windows file names under Linux? - SOLUTION
Message-Id: <eg46cj$6us$1@mlucom4.urz.uni-halle.de>

Thus spoke somebody (on 2006-10-06 01:37):
> On Thu, 05 Oct 2006 19:11:11 -0400, somebody wrote:
>> I have a perl script that I need to pass some files to via
>> the command line under Linux.  The file names may contain
>> single quotes and or ampersands like:
>> This ain't a linux file.mp3
>> This is file 1 & file 2.mp3
>> 
>> How can I handle the above 2 file names in a perl
>> script running under Linux?  I haven't tried yet,
>> but I don't believe simply enclosing them in single
>> quotes or back tics 0will work like:
> 
> So far, all I need to do is enclose the file name in
> double quotes, and the perl script handles it without
> any problems.  I didn't think it would be that simple!

This won't work if there are backslashes \ in your file,
they will 'garble' your file name.

Try:

  This ain't \a  li\nux file.mp3
  This is \file 1 & \file 2.mp3

and compare with:

    my %f = ( q{This ain't \a  li\nux file.mp3} => undef,
              q{This is \file 1 & \file 2.mp3}  => undef  );

    open( $f{$_}, '>', $_) || die "$_ $!" for keys %f;
    close $f{$_} for keys %f;


    $> ls -la
     ...  This is \file 1 & \file 2.mp3
     ...  This ain't \a  li\nux file.mp3


You could use single quotes '' but need
then of course to escape the internal \'
by backslash:

  'This ain\'t a linux file.mp3'

Regards

Mirco


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

Date: Thu, 05 Oct 2006 19:11:11 -0400
From: somebody <some@body.com>
Subject: How to handle Windows file names under Linux?
Message-Id: <ELadnQ7GK5SSDLjYnZ2dnUVZ_s2dnZ2d@giganews.com>

I have a perl script that I need to pass some files to via
the command line under Linux.  The file names may contain
single quotes and or ampersands like:

This ain't a linux file.mp3
This is file 1 & file 2.mp3


How can I handle the above 2 file names in a perl
script running under Linux?  I haven't tried yet,
but I don't believe simply enclosing them in single
quotes or back tics 0will work like:

'This ain't a linux file.mp3'


-Thanks



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

Date: Thu, 05 Oct 2006 23:52:38 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: How to handle Windows file names under Linux?
Message-Id: <aVgVg.3441$H7.1932@edtnps82>

somebody wrote:
> I have a perl script that I need to pass some files to via
> the command line under Linux.  The file names may contain
> single quotes and or ampersands like:
> 
> This ain't a linux file.mp3
> This is file 1 & file 2.mp3
> 
> 
> How can I handle the above 2 file names in a perl
> script running under Linux?  I haven't tried yet,
> but I don't believe simply enclosing them in single
> quotes or back tics 0will work like:
> 
> 'This ain't a linux file.mp3'

'This ain\'t a linux file.mp3'

q{This ain't a linux file.mp3}

q!This ain't a linux file.mp3!

etc., etc.


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Fri, 6 Oct 2006 03:30:26 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: New CPerl (Emacs mode for Perl) available
Message-Id: <eg4iki$1bsj$1@agate.berkeley.edu>


Yet another release of CPerl Emacs mode for editing Perl is available.
The main target of the last couple of subversions (about 5.22) is to
improve the indentation engine (see the ChangeLog at start of the mode
file).

So if you have problems with indentation, upgrade.  If you still have
problems, let me know (but do not forget to read the mode help, and
description of variables in "customize indentation" part - via M-x
customize).

Enjoy ilyaz.org/software/emacs,
Ilya


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

Date: 5 Oct 2006 17:02:16 -0700
From: ToddAndMargo@gbis.com
Subject: newbie cspan example question
Message-Id: <1160092936.285576.100800@h48g2000cwc.googlegroups.com>

Hi All,

    A am real new to Perl.  My background is Modula2 and Bash scripts.
I love all the examples at CSPAN.

    I have been looking at:
          http://search.cpan.org/~ugansert/Paw-0.54/Paw/Popup.pm

                 @butt=('Okay', 'Cancel');
                 $text=('Do you really want to continue ?');
                 $pu=Popup::new(height=>20, width=>20,
                        buttons=>\@butt, text=>\$text);

Having run the example and being told that something important
was missing (Popup::new) I though I had better ask the following
questions:

1)  On the page, it lists the "source" for popup::new.  Is this a
standard function library that
I have to import into my code (like a library or external module in
Modula2)?
If so, what is the syntax?

2)  Do I instead, copy and paste the source code into the top (or
bottom) of my test program
and simple use it as a subroutine?

3)  Are these examples all coded into a standard library that I simple
call out
in my code?  If so, where do I download them?  And, what is the syntax
to import them into my test program?

Many thanks,
--T



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

Date: 5 Oct 2006 16:49:54 -0700
From: ToddAndMargo@gbis.com
Subject: newbie structure question
Message-Id: <1160092194.725824.225910@m7g2000cwm.googlegroups.com>

Hi All,

    A am real new to Perl.  My background is Modula2 and Bash scripts.
Please premit a newbie question:

1)  Under Modula2, best practice (or my practice) was from top
to bottom
   a) make my declarations (which variable did what, etc.),
   b) write all my modules and functions, and
   c) in the body, place my code.

Is this also the proper structure under Perl as well?  (Think,
this is your chance to influence me into good habits!)

Many thanks,
--T



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

Date: 5 Oct 2006 15:37:25 -0700
From: "pat" <patty_rv@hotmail.com>
Subject: Notify parent that a background process failed
Message-Id: <1160087845.052562.155230@m7g2000cwm.googlegroups.com>

Hi,

I have a Perl script that basically takes a list of Unix commands and
executes them one by one, does something with the output and goes to
execute the next, some of these commands have to be executed in the
background, the script does not wait for them to finish, just starts it
and keeps going, the problem is that I do need to know if any of the
background processes fail and the return code. I tried using $SIG{CHLD}
but I get a signal for every one of the commands I run, I'm only
interested in the background ones. Is there a way to do a non-blocking
wait on a specific process id?

 I use fork to start the process:

            if (!defined($pid = fork))
            { # Fork failed
               error_message("Couldn't create new process");
               return 1;
            }
            elsif ($pid==0)
            {
               # Child process block
               print "child proccess id is $pid \n";
               exec("my_child_command", @args);
            }
            else
            {
               # Parent process continues here
               print  "Copa proccess id is $pid \n";
               $status = 0;
               # Make sure process started
               unless (kill 0 => $pid)
               {
                  print "Background process is not running \n";
                  return 1;
               }
               ,,,,,,

Any help will be greatly appreciated
Patricia



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

Date: 5 Oct 2006 15:59:45 -0700
From: usenet@DavidFilmer.com
Subject: Re: Notify parent that a background process failed
Message-Id: <1160089185.893370.277660@m7g2000cwm.googlegroups.com>

pat wrote:
> Any help will be greatly appreciated

Have a read through
   perldoc perlipc

I believe you will find that helpful.

-- 
David Filmer (http://DavidFilmer.com)



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

Date: 5 Oct 2006 15:21:08 -0700
From: "Jim Gibson" <Jim@Gibson.org>
Subject: Re: Regarding numeric literals
Message-Id: <1160086868.216035.95230@e3g2000cwe.googlegroups.com>



On Oct 5, 1:14 pm, Mirco Wahab <w...@chemie.uni-halle.de> wrote:
> Thus spoke Paul Lalli (on 2006-10-05 22:00):
>
> > That's "Programming Perl", by Larry Wall, published by O'Reilly.  And I
> > honestly have no idea if using _ in numeric literals is spelled out in
> > that detail in the Camel or not, because I don't currently have mine on
> > me.It is, its "detailed enogh" for me - and
> says all what we discussed here (Chap.2, 2.6.1):
>
> <Larry>
>    ... because Perl uses the comma as a list separator,
>    you cannot use it to separate the thousands in a large
>    number. Perl does allow you to use an underscore
>    character instead. The underscore only works within
>    literal numbers specified in your program, not for
>    strings functioning as numbers or data read from
>    somewhere else ...
> </Larry>
>
> He then also explains the workings of
> the number system designators (0 & 0x).
>
> (I hope reading a 'quoted part' from a copyrighted
> material in a context with your own eyes is legal
> in =AByour country=BB ...)

Even in a country as authoritarian and repressive as the U. S. of A.,
quoting excerpts of copyrighted works for teaching purposes is
considered "fair use."

http://www.copyright.gov/fls/fl102.html



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

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


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