[24920] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7170 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 23 11:07:02 2004

Date: Thu, 23 Sep 2004 08:05: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           Thu, 23 Sep 2004     Volume: 10 Number: 7170

Today's topics:
    Re: CD burning on win32 <usenet@morrow.me.uk>
    Re: Create a chinese directory (folder)  by Perl in Win <usenet@morrow.me.uk>
    Re: Get the list of directories <mritty@gmail.com>
    Re: Get the list of directories <tintin@invalid.invalid>
    Re: Help with my brute force method (krakle)
    Re: How is this Perl Script encrypted? <1usa@llenroc.ude.invalid>
    Re: How is this Perl Script encrypted? <patrice.auffret@intranode.com>
    Re: Mystery message: Undefined subroutine &OS2::Bootdri <rev_1318@hotmail.com>
    Re: new commands written in perl (Anno Siegel)
    Re: new commands written in perl <tzz@lifelogs.com>
        Optionally changing file perms? <dkoleary@olearycomputers.com>
    Re: Optionally changing file perms? (Greg Bacon)
    Re: Optionally changing file perms? <dkoleary@olearycomputers.com>
    Re: parse_html_string reports error <spamtrap@dot-app.org>
    Re: parse_html_string reports error <usenet@morrow.me.uk>
        perl in Windows: using the "Send To" folder and perl (Adam S)
    Re: perl in Windows: using the "Send To" folder and per <1usa@llenroc.ude.invalid>
    Re: perl in Windows: using the "Send To" folder and per <usenet@morrow.me.uk>
    Re: Printing an array of hash refs <usenet@morrow.me.uk>
    Re: Printing an array of hash refs (Tony N.)
    Re: Regexp-matching character n times in the line. (Rodrigo A B Freire)
        Regular expression <a246456@fmr.com>
    Re: translating code to 'mixed' case (Anno Siegel)
        Untainting a filehandle <danmoinescu@yahoo.com>
    Re: Untainting a filehandle (Anno Siegel)
    Re: Untainting a filehandle <danmoinescu@yahoo.com>
    Re: Untainting a filehandle (Greg Bacon)
    Re: Untainting a filehandle (Greg Bacon)
        Using C::Scan : How to ignore #includes ?  <matrix_calling@yahoo.dot.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Sep 2004 13:26:30 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: CD burning on win32
Message-Id: <m0sa22-cc5.ln1@osiris.mauzo.dyndns.org>


Quoth "Dave" <daveandniki@ntlworld.com>:
> 
> "yusufdestina" <joericochuyt@msn.com> wrote in message
> news:cb4fea0ac8dd090d64c6fb1c1d6e24f3@localhost.talkaboutprogramming.com...
> > Is it possible to write data to a cd on a windows platform with Perl?
> > if so, are there any modules for this? or should I stop thinking doing
> > that?
> > tnx in adv.
> >
> 
> I don't know the answer but the key question is perhaps: do any of the cd
> burning programs for windows have an OLE (automation) interface? If there is
> one that has then perl can be used to drive it I should think.

If they don't, then cdrecord can be built under cygwin and works
perfectly well. You will need to install cygwin and cdrtools (which
contains cdrecord and mkisofs) and read the cdrecord and mkisofs man
pages carefully. If you have trouble with ASPI drivers then email me and
I may be able to give you a hand... :)

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk                                    The Levellers, 'Believers'


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

Date: Wed, 22 Sep 2004 10:43:29 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Create a chinese directory (folder)  by Perl in Windows 2000 English OS
Message-Id: <13u722-sn4.ln1@osiris.mauzo.dyndns.org>


Quoth gaolixin@yahoo.com (gaolixin):
> I am a perl newbie, and I am trying to use a perl program to create a
> folder in Window2000. My WINDOWS 2000 is English OS, but setup using
> Chinese (PRC) as default locale. I am able to create chinese folders
> manually, and able to view them.
> 
> The perl program has a statment like
> 
> use strict; $|++;
> my $VERSION = "1.0";
> use File::Spec::Functions;
> ...
> mkdir $dirpath;
> 
> where $dirpath has chinese chars inside using GB2312 encoding. It
> created a folder but the chinese not readiable .
> 
> Can anybody help me through, can you give me a sample program? Thanks
> a lot!!!

Use the Encode module to convert the path into UTF16, which is what M$ use
for international stuff. (completely untested)

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

Date: Thu, 23 Sep 2004 06:20:16 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Get the list of directories
Message-Id: <ciu81c$l8l$1@misc-cct.server.rpi.edu>

Xavier MOGHRABI wrote:

> Hello,
> 
> I'm writing a perl script and I need to get the list of directories of a
> directory.
> 
> I tried few tests but there failed.
> 
> In fact I need this list to open the last directory created.
> 
> For the moment I've writen this but it doesn't work because in my variable
> $retval I don't obtain the list of the directories :
> 
> $retval = system "ls -C $ENV{RESULT_DIR}";
> @rep = split("\t",$retval);

You should check the documentation for functions you use.  In this case, 
you're using system() without understanding what that function returns.
perldoc -f system
(third paragraph)

However, simply changing your program to do what you meant to do will 
still result in a platform-dependent solution.  Far better to use one of 
the methods suggested by other respondents to this post 
(File::Find::Rule or glob()) or one of several other ways, which include 
File::Finder and opendir()/readdir().

Paul Lalli


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

Date: Thu, 23 Sep 2004 23:05:38 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Get the list of directories
Message-Id: <2rfoujF18rr0gU1@uni-berlin.de>


"Graham Wood" <Graham.T.Wood@oracle.com> wrote in message 
news:41529D87.98394BBF@oracle.com...
> Tintin wrote:
>>
>> "Xavier MOGHRABI" <moghrabi@inrialpes.fr> wrote in message
>> news:ciu1ta$bp2$1@trompette.imag.fr...
>> > Hello,
>> >
>> > I'm writing a perl script and I need to get the list of directories of 
>> > a
>> > directory.
>>
>> Many different ways to do this.  One is:
>>
>> my @dirs;
>>
>> foreach my $dir (<$ENV{RESULT_DIR}/*>) {
>>   next unless -f $dir;
>>   push @dirs,$dir;
>> }
>
> Isn't this adding the files rather than directories?  -f is true if $dir
> is a file.  I think you want -d $dir.

Whoops.  Yes, I meant -d 




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

Date: 23 Sep 2004 06:58:35 -0700
From: krakle@visto.com (krakle)
Subject: Re: Help with my brute force method
Message-Id: <237aaff8.0409230558.61d24066@posting.google.com>

larryj@gsu.edu (Larry Felton Johnson) wrote in message news:<4ae7bf57.0409220258.37cf90c8@posting.google.com>...
> "Jeff" <jeff.gilbertson@gmail.com> wrote in message news:<1095715793.375034.285720@k17g2000odb.googlegroups.com>...
> > I have a file (DM.txt) that has the following lines:
> > 
> > 
> > spool cr04 ip11 rm22
> > http web01 web02 web03
> > mail mail01 mail03
> > 
> > 
> > I want to create a variable ($Dis) that looks like this:
> > 
> > cr04|ip11|rm22
> > 
> 
> If this file is always going to be this short efficiency isn't a
> big concern, and for something this straightforward readability of
> the code isn't really an issue, so I usually go with whatever my
> fingers pound out, which was
> 
> use strict;
> 
> my $infile = "DM.txt";
> open INFILE, "$infile" or die "Can't open $infile: $!\n";
> 
> my $Dis;
> while (<INFILE>) {
>     if (/spool\s+(\w+)\s+(\w+)\s+(\w+)$/) {
>         $Dis = $1 . '|' . $2 . '|' . $3;
>     }
> }
> 
> print "$Dis\n";

Do you leave your home door wide open when you enter your house?


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

Date: 23 Sep 2004 12:32:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <Xns956D56E351DB6asu1cornelledu@132.236.56.8>

i6033162556-signup1@yahoo.com.cn wrote in
news:23d1674e.0409230016.7dc67c92@posting.google.com: 

> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> news:<Xns956CAF761B39Aasu1cornelledu@132.236.56.8>... 
>> i6033162556-signup1@yahoo.com.cn wrote in
>> news:23d1674e.0409221119.166cb8de@posting.google.com: 
>> 
>> [ Don't snip attributions ]
>> 
>> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
>> news:Xns956C5659DF5DBasu1cornelledu@132.236.56.8: 
>> 
>> >> Your time working on this is wasted.
>>  
>> > I think I am not wasting time, as this code is 100% protected.
>> > Unbreakable.
>> 
>> That is more a statement about your abilities than the strength of
>> the protection scheme.
>> 
>> > If you don't think so, make a change to the unpacked file and run
>> > it. It gaves errors once the file is changed.
>> 
>> Does it still give errors if you replace the two subs with:
>> 
>> sub key_isValid { return 1; }
>> 
>> sub key_isValid_simple { return 1; }
> 
> YES, SIR. I did all. Not working. 

Then you are doing something else wrong.

> Have you tried it yourself, or just guessing here?

Was just guessing before ... Tried it after seeing you respond so 
insistently.

> Even if I add ONE space, then delete that SPACE.
> Or simply do nothing, but resave the file again. It stopped working.
> Its technology is sooo advanced.

Only when confronted with primitive minds.

>> Sigh.

Again, the time you spend on this is wasted.

Sinan.


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

Date: Thu, 23 Sep 2004 15:29:30 +0200
From: Patrice Auffret <patrice.auffret@intranode.com>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <20040923152930.47cae1cc.patrice.auffret@intranode.com>

On 23 Sep 2004 12:32:29 GMT
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
[..]
> >> sub key_isValid { return 1; }
> >> 
> >> sub key_isValid_simple { return 1; }
> > 
> > YES, SIR. I did all. Not working. 
> 
> Then you are doing something else wrong.
[..]

  Maybe the sub crc32_all() is checking against a valid CRC32 in 
  order to see if the source has been altered.

  So maybe trying to also change this one.


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

Date: Thu, 23 Sep 2004 14:43:04 +0200
From: Polleke <rev_1318@hotmail.com>
Subject: Re: Mystery message: Undefined subroutine &OS2::Bootdrive
Message-Id: <ciugcu$68d$1@voyager.news.surf.net>

on Wednesday 22 September 2004 21:12, Shmuel (Seymour J.) Metz wrote:

[snip]

>  print 'BootDrive=',OS2::BootDrive(),"\n";
                               ^
>  print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
                                    ^
[snip]

>  print  $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
> 
> gives me
> 
>  Undefined subroutine &OS2::Bootdrive called at H:\UTILITY/BWwhois.cmd
> line 61.
> 
> Note that the spelling is identical to the one that worked, 

No it isn't; BootDrive() works, but Bootdrive() doesn't exist. Function
names are always case sensitive!

Paul



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

Date: 23 Sep 2004 13:20:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: new commands written in perl
Message-Id: <ciuijb$hgi$3@mamenchi.zrz.TU-Berlin.DE>

Robert Gamble  <rob_gamble99@hotmail.com> wrote in comp.lang.perl.misc:
> On Wed, 22 Sep 2004 10:27:52 -0400, Ted Zlatanov wrote:
> 
> > On Tue, 21 Sep 2004, emschwar@pobox.com wrote:
> > 
> >> ioneabu@yahoo.com (wana) writes:
> >>> I named my command 'into'.  It just appends a string to a file from
> >>> the command line.
> >> 
> >> You mean, like
> >> 
> >> $ echo "some quick note" >> file
> >> 
> >> or
> >> 
> >> $ cat >>file
> >> some multi-line
> >> text
> >> ^D
> >> 
> >> ?
> > 
> > No, it's NOT the same thing.  His program doesn't use the shell.  It
> > may be trivial, but it's not useless.
> 
> Of course his program uses the shell, what do you think is calling the
> program and passing it the parameters?

cron?  perl?  find?  xargs?  Thousands of programs can start other
programs, not only shells.

Anno



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

Date: Thu, 23 Sep 2004 10:26:15 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: new commands written in perl
Message-Id: <4n7jqljc3c.fsf@lifelogs.com>

On Wed, 22 Sep 2004, rob_gamble99@hotmail.com wrote:

> On Wed, 22 Sep 2004 10:27:52 -0400, Ted Zlatanov wrote: 

>> No, it's NOT the same thing.  His program doesn't use the shell.  It
>> may be trivial, but it's not useless.
> 
> Of course his program uses the shell, what do you think is calling the
> program and passing it the parameters?

Any other program can do it - the shell is a common choice, but not
the only one.

> It may not be totally useless but the point is that this functionality
> already exists with trivial shell operations which addresses the question
> the OP asked.

Sometimes the shell is not a good choice for trivial operations
(e.g. `cat' is a pretty redundant program when you use a shell).

Hell, we don't need 90% of Unix commands because Perl can emulate them
according to your argument.

>> In addition, note the default behavior is to append to ~/.into when no
>> file name is given.
> 
> Maybe there should be a complementing utility called "outof" that will
> read from ~/.into by default to justify using it over cat...

I like the way you glossed over this big difference from the `cat'
approach with a quick "if this goes on..." response.  Good work.

Ted


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

Date: Thu, 23 Sep 2004 13:30:00 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Optionally changing file perms?
Message-Id: <sdA4d.2105$o06.1757@news.flashnewsgroups.com>

God, I hate bit math!  I just can't get my mind around it..

I'm trying to identify new file modes for a variety of 
files and directories on a given system.  The first step is
to ensure directories have execute permissions if the appropriate
read permission is set.  For instance, if a directory has
0660 permissions, I want to change the mode to 0770.

Here's what I have so far:

<<snip>>
open (In, "< $wws") || die "Can't read $wws - ($!)";
while (<In>)
{  chomp;
   my $file = $_;
   next if (! -d $file && ! -f $file); #ensure we're looking at dirs/files
   my ($fmode, $fuid) = (stat($file))[2,4];
   my $pmode = $fmode;
   if ( -d $file)
   {  # ;;
      $pmode |= S_IXUSR ; # if ($pmode & S_IRUSR);
      # $pmode |= S_IXGRP if ($pmode & S_IRGRP);
      # $pmode |= S_IXOTH if ($pmode & S_IROTH);
   }
   # next if (! defined(${$uids}{$fuid}));
   printf ("%04o %04o %s\n", $fmode & 07777,  $pmode & 07777, $file);
}

When I run the script, the $pmode is all 0's:

# ./filter biteme
1777 0000 /tmp
0666 0000 ./testies

If I comment out the $pmode change, $pmode is the same as $fmode,
as I would expect...

   if ( -d $file)
   {  ;;
      # $pmode |= S_IXUSR ; # if ($pmode & S_IRUSR);
      # $pmode |= S_IXGRP if ($pmode & S_IRGRP);
      # $pmode |= S_IXOTH if ($pmode & S_IROTH);
   }

# ./filter biteme
1777 1777 /tmp
0666 0666 ./testies

I hate being such an idiot that I can't figure out a simple concept,
but can someone point out what I'm doing wrong?

Thanks.

Doug


-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 23 Sep 2004 13:58:12 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Optionally changing file perms?
Message-Id: <10l5ljk7c4u7021@corp.supernews.com>

In article <sdA4d.2105$o06.1757@news.flashnewsgroups.com>,
    Doug O'Leary  <dkoleary@olearycomputers.com> wrote:

: Here's what I have so far:
: 
: <<snip>>
: open (In, "< $wws") || die "Can't read $wws - ($!)";
: while (<In>)
: {  chomp;
:    my $file = $_;
:    next if (! -d $file && ! -f $file);
:    my ($fmode, $fuid) = (stat($file))[2,4];
:    my $pmode = $fmode;
:    if ( -d $file)
:    {  # ;;
:       $pmode |= S_IXUSR ; # if ($pmode & S_IRUSR);
:       # $pmode |= S_IXGRP if ($pmode & S_IRGRP);
:       # $pmode |= S_IXOTH if ($pmode & S_IROTH);
:    }
:    # next if (! defined(${$uids}{$fuid}));
:    printf ("%04o %04o %s\n", $fmode & 07777,  $pmode & 07777, $file);
: }
: 
: When I run the script, the $pmode is all 0's:
: 
: # ./filter biteme
: 1777 0000 /tmp
: 0666 0000 ./testies

I can't reproduce that result:

    $ cat try
    #! /usr/local/bin/perl

    use warnings;
    use strict;

    use Fcntl ":mode";

    while (<DATA>)
    {  chomp;
       my $file = $_;
       next if (! -d $file && ! -f $file);
       my ($fmode, $fuid) = (stat($file))[2,4];
       my $pmode = $fmode;
       if ( -d $file)
       {  # ;;
          $pmode |= S_IXUSR ; # if ($pmode & S_IRUSR);
          # $pmode |= S_IXGRP if ($pmode & S_IRGRP);
          # $pmode |= S_IXOTH if ($pmode & S_IROTH);
       }
       # next if (! defined(${$uids}{$fuid}));
       printf ("%04o %04o %s\n", $fmode & 07777, $pmode & 07777, $file);
    }

    __DATA__
    .
    ./foo
    ./bar

    $ ls -l
    total 12
    drwxrwx---    2 gbacon   gbacon       4096 Sep 23 07:54 bar
    drw-rw----    2 gbacon   gbacon       4096 Sep 23 07:53 foo
    -rwxrwxr-x    1 gbacon   gbacon        578 Sep 23 07:54 try

    $ ./try
    0775 0775 .
    0660 0760 ./foo
    0770 0770 ./bar

Hmm.. did you import the S_I* symbols using the Fcntl module?  Is
perl treating them as barewords in your program, in other words?

Greg
-- 
It is not my expectation that when the reader puts down this book he
will cry out, "I know!"  Would to heaven that he might honestly say to
himself, "I don't know!"
    -- Frédéric Bastiat, *Economic Sophisms*


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

Date: Thu, 23 Sep 2004 15:00:01 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Optionally changing file perms?
Message-Id: <RxB4d.2129$o06.824@news.flashnewsgroups.com>

On 2004-09-23, Greg Bacon <gbacon@hiwaay.net> wrote:
>
> I can't reproduce that result:
>
>     0660 0760 ./foo
>     0770 0770 ./bar
>
> Hmm.. did you import the S_I* symbols using the Fcntl module?  Is
> perl treating them as barewords in your program, in other words?

Well, it's good to know the logic is correct.  I tried doing
the use Fcntl thing; however, I get a core dump on my HP 11.00 perl
v5.6.  While browing through documentation, I found 
use POSIX ":fcntl_h".  My half-formed thought was that the POSIX
module was Fcntl's successor.  POSIX *seemed* to work - at least it 
compiled and ran.  Apparently, those constants aren't defined...

I'll see about finding what the constants are defined as in the
fcntl module and use them directly.

Thanks for your help, I appreciate it.

Doug

-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 23 Sep 2004 08:52:08 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: parse_html_string reports error
Message-Id: <M5mdnYe-wqxkW8_cRVn-sA@adelphia.com>

AR John wrote:

> You are right in a sense. I looked into the HTML and found there is an
> "&" NOT amp. like in, <a href=" ....?test=1&v=xyz"> ...</a>

Ampersands need to be encoded - that's why newer guidelines prefer using 
semicolons to separate name/value pairs in URLs. You need either one of 
these:

<a href="...?test=1&amp;v=xyz">

or

<a href="...?test=1;v=xyz">

If you're using CGI.pm on the receiving end of this link, either one 
will work. (It *should* work with other languages & CGI libraries too, 
but I have no experience with them.)

> I am not sure if I am using an old version of LibXML.

Unencoded '&'s have *never* been well-formed XML. It's possible that an 
older version of LibXML didn't catch and report the XML error, but if so 
that behavior was a bug.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 23 Sep 2004 13:30:08 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: parse_html_string reports error
Message-Id: <g7sa22-cc5.ln1@osiris.mauzo.dyndns.org>


Quoth arjohn7681@yahoo.com (AR John):
> Sherm Pendley <spamtrap@dot-app.org> wrote in message 
> > on line 111 of the HTML. Specifically, there's an entity that's missing 
> > the ';' - i.e. "&amp" instead of "&amp;".
> > 
> > sherm--
> 
> Sherm Pendley,
> 
> You are right in a sense. I looked into the HTML and found there is an
> "&" NOT amp. like in, <a href=" ....?test=1&v=xyz"> ...</a>
> 
> I am not sure if I am using an old version of LibXML.

That's not the problem. The HTML file is broken: &s need encoding, even
in double quotes.

You may be able to use ; instead of & (if the cgi the url refers to is
standards-compliant), or you can simply fix the HTML.

BTW, are you aware that ordinary HTML (as opposed to strict XHTML) is
*not* valid XML? You may be better off with an HTML parser.

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: 23 Sep 2004 03:47:36 -0700
From: adam_at_vnl@postmaster.co.uk (Adam S)
Subject: perl in Windows: using the "Send To" folder and perl
Message-Id: <c9164b54.0409230247.18ac7dc9@posting.google.com>

Hi, 

with a few thousand lines worth of Perl programmnig in a Unix
environment behind me I want to create an application in Windows where
I can mark several files and then right-click and do a "Send To" to a
perl application.

When using the "Send To" right-click menu item, all the files I've
marked are supplied on the command line to the executable i.e.

myexecutable file1.txt file2.txt ... fileN.txt

I create my executable by writing a .bat file which in turn supplies
the input argument with a

eval "perl myperlscript.pl @ARGS" statement.

My first version of myperlscript.pl only printed all the file names
supplied to to stdout just to check how many files I can do.

That's where the problem arises, somewhere along the line it only
manages about 5 files (the path names are rather long, about 50
characters.

Somewhere the command line gets very short, I don't exactly know
where, if itäs the .bat command line that's too short or the perl
command line.

Other "proper" applications, such as gVim, don't seem to have a
problem with 50 similar file names being supplied.

If the solution is to create a perlscript.exe, how do I do that so I
can get rid of the .bat file to launch the perl interpreter? In a Unix
environment I would just add a #!/usr/bin/perl and the script itself
would be an executable, but how do I do it in Windows without
involving a .bat file? Or is there an entirely different solution
where I can do a #! like addition to my script?

Thankful for any help.

Best Regards,
Adam


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

Date: 23 Sep 2004 12:45:50 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl in Windows: using the "Send To" folder and perl
Message-Id: <Xns956D59272DAFEasu1cornelledu@132.236.56.8>

adam_at_vnl@postmaster.co.uk (Adam S) wrote in 
news:c9164b54.0409230247.18ac7dc9@posting.google.com:

> with a few thousand lines worth of Perl programmnig in a Unix
> environment behind me I want to create an application in Windows where
> I can mark several files and then right-click and do a "Send To" to a
> perl application.

Well, this is not strictly a Perl question but ...

> When using the "Send To" right-click menu item, all the files I've
> marked are supplied on the command line to the executable i.e.
> 
> myexecutable file1.txt file2.txt ... fileN.txt
> 
> I create my executable by writing a .bat file which in turn supplies
> the input argument with a
> 
> eval "perl myperlscript.pl @ARGS" statement.
> 
> My first version of myperlscript.pl only printed all the file names
> supplied to to stdout just to check how many files I can do.
> 
> That's where the problem arises, somewhere along the line it only
> manages about 5 files (the path names are rather long, about 50
> characters.
> 
> Somewhere the command line gets very short, I don't exactly know
> where, if itäs the .bat command line that's too short or the perl
> command line.

You do not mention which Windows command shell you are using. command.com 
has always been hampered by very short line lengths (numbers like 127 and 
255 come to mind). AFAIK, cmd.exe in XP is better but I don't know how much 
better.

> Other "proper" applications, such as gVim, don't seem to have a
> problem with 50 similar file names being supplied.
> 
> If the solution is to create a perlscript.exe, how do I do that so I
> can get rid of the .bat file to launch the perl interpreter? In a Unix
> environment I would just add a #!/usr/bin/perl and the script itself
> would be an executable, but how do I do it in Windows without
> involving a .bat file? Or is there an entirely different solution
> where I can do a #! like addition to my script?

Untested: A solution that might work regardless of the version of Windows 
you are using is to create a shortcut to wperl.exe and specify the script 
name and command line parameters via that shortcut.

Hope this helps. 

Sinan.


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

Date: Thu, 23 Sep 2004 13:55:37 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl in Windows: using the "Send To" folder and perl
Message-Id: <9nta22-cc5.ln1@osiris.mauzo.dyndns.org>


Quoth adam_at_vnl@postmaster.co.uk (Adam S):
> Hi, 
> 
> with a few thousand lines worth of Perl programmnig in a Unix
> environment behind me I want to create an application in Windows where
> I can mark several files and then right-click and do a "Send To" to a
> perl application.
> 
> When using the "Send To" right-click menu item, all the files I've
> marked are supplied on the command line to the executable i.e.
> 
> myexecutable file1.txt file2.txt ... fileN.txt
> 
> I create my executable by writing a .bat file which in turn supplies
> the input argument with a
> 
> eval "perl myperlscript.pl @ARGS" statement.
> 
> My first version of myperlscript.pl only printed all the file names
> supplied to to stdout just to check how many files I can do.
> 
> That's where the problem arises, somewhere along the line it only
> manages about 5 files (the path names are rather long, about 50
> characters.
> 
> Somewhere the command line gets very short, I don't exactly know
> where, if itäs the .bat command line that's too short or the perl
> command line.

My guess would be it's command.com truncating the command line.

> If the solution is to create a perlscript.exe, how do I do that so I
> can get rid of the .bat file to launch the perl interpreter? In a Unix
> environment I would just add a #!/usr/bin/perl and the script itself
> would be an executable, but how do I do it in Windows without
> involving a .bat file? Or is there an entirely different solution
> where I can do a #! like addition to my script?

You can use pp (install PAR.pm).

Alternatively, have you tried putting a shortcut to 
c:\path\to\perl c:\path\to\script.pl
in send to instead?

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Thu, 23 Sep 2004 13:41:46 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Printing an array of hash refs
Message-Id: <atsa22-cc5.ln1@osiris.mauzo.dyndns.org>


Quoth Shawn Corey <shawn.corey@sympatico.ca>:
> Paul Lalli wrote:
> > "Tony N." <tnitzke@simpson.com> wrote in message
> > news:638483db.0409220735.49486c78@posting.google.com...
> > 
> >>I'm using the following code to print an array of hash refs.  It seems
> >>to me there should be a more concise way to do this.  I don't like the
> >>trailing \t or the extra line of code to get the \n.  Any pointers
> >>would be appreciated.
> >>for my $row (@rows) {
> >>  print "$row->{$_}\t" for sort keys %{$row};
> >>  print "\n";
> >>}
> > 
> > 
> > for my $row (@rows){
> >     print (join ("\t", sort keys %$row), "\n");
> > }
> > 
> > Paul Lalli
> > 
> > 
> Isn't it?
> 
>    print join( "\t", map { $row->{$_} } sort keys %$row ), "\n";

I would prefer

{
    local ($,, $\) = ("\t", "\n");
    print map $row->{$_}, sort keys %$row;
}

or maybe with a hash slice

{
    local ($,, $\) = ("\t", "\n");
    print @{$row}{sort keys %$row};
}

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: 23 Sep 2004 07:54:06 -0700
From: tnitzke@simpson.com (Tony N.)
Subject: Re: Printing an array of hash refs
Message-Id: <638483db.0409230654.41864ac8@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<4152125e.292436952@news.erols.com>...
> tnitzke@simpson.com (Tony N.) wrote:
> 
>     {
>         local($, , $\) = ("\t", "\n");
>         print sort keys %{$rows[0]};
>         print @$_{sort keys %$_} for @rows;
>     }

Thanks Jay.  I liked this technique, so I created a second version of
the program using this (I had already implemented the technique from
Paul and Shawn).

I had to make a modification and was hoping you guys would look at. 
The hash ref array is populated using DBI and my SQL statement was
missing an outer join.  After I fixed that now I have the possibility
of null values coming the DB server.

Thanks to everyone who responded.  I learned a lot from your examples.


Modified version of Jay's technique:
{
	local ($, , $\) = ("\t", "\n");
	print sort keys %{$rows[0]};
	for my $row (@rows) {
		print map {$row->{$_}?$row->{$_}:'' } sort keys %{$row};
	}
}

Modified version of Paul's and Shawn's technique:
print join("\t", sort keys %{$rows[0]}), "\n";
for my $row (@rows) {
	print join("\t", map { $row->{$_} ? $row->{$_}:'' } sort keys %$row),
"\n";

}


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

Date: 23 Sep 2004 06:08:50 -0700
From: nntpstuffs@brasilia.br (Rodrigo A B Freire)
Subject: Re: Regexp-matching character n times in the line.
Message-Id: <74f425c.0409230508.778454ee@posting.google.com>

Brian,

Worked like a charm! ;]

Thank you,
Rod.

Brian McCauley <nobull@mail.com> wrote in message news:<cisinv$h34$1@slavica.ukpost.com>...
> Rodrigo A B Freire wrote:
> > I'm trying to build a regular expression that matches a exact count of
> > a character.
> > I explain.
> > as_2asf_345__e@foo.bar
> > a_b_fefa_or_@foo.bar
> > __fooad3__@foo.bar
> > 
> > The regexp should match every email address containing 4 underscores.
> 
> /^([^_]*_){4}[^_]*$/


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

Date: Thu, 23 Sep 2004 10:53:57 -0400
From: "a246456" <a246456@fmr.com>
Subject: Regular expression
Message-Id: <mnB4d.43$Nq3.36@news-srv1.fmr.com>

Hello,
    I am processing a list from a file which contains different paths to be
processed. for example:
/apps/oracle/a.htm
/apps/user/bin/a.gif
/apps/export/images/sdsd.gif
/apps/images/client/list/wqerew.gif
I want to split the filename and the path. Then i can use the path as input
to fetch the file from a remote machine through ftp.. I am able to get the
filename, but i am not able to get the full path with the slashes in it..
Thanks for your help...
----------------------------------------------------------------------------
--------------
open(LST, "content.txt") || die "File content.txt not found. $!\n";
open(FAIL, ">fail.txt");
$cont=<LST>;
chomp($cont);
while($cont ne "")
{
 @line=split('/', $cont);
 $file=pop(@line);
 print "File Name is $file\n";
 $cont=<LST>;
}
close LST;




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

Date: 23 Sep 2004 12:50:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: translating code to 'mixed' case
Message-Id: <ciugqd$hgi$1@mamenchi.zrz.TU-Berlin.DE>

Michael Friendly  <friendly@yorku.ca> wrote in comp.lang.perl.misc:
> This is a problem I thought there would have been scripts or modules
> I could adapt, but I havent found anything all that useful
> on CPAN or other sources (Perl cookbook, 2nd ed)
> 
> Given code (perl/C/R, ...) with comments, 'strings', "strings"
> and code,
>    - convert all comments to mixed case as sentences, capitalizing
> the first lettter of each '.' delimited sentence, but retain all

Not every period delimits a sentence.  That would capitalize more
than required.

> 'strings' and "strings" within comments in original case.

What about q(), qq(), and here docs?  What about auto-quoted
text in "{}" and before "=>"?

>    - convert all non-comment code to lower case, but retain all
> 'strings' and "strings" within comments in original case.
                          ^^^^^^^^^^^^^^^
I don't think you want that restriction here.

Doing what you plan without a parser for the programming language,
plus at least a rudimentary natural language parser for the comments
would make a mess out of any source text.

Anno


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

Date: Thu, 23 Sep 2004 11:25:33 +0100
From: Dan Moinescu <danmoinescu@yahoo.com>
Subject: Untainting a filehandle
Message-Id: <9yx4d.31824$Z14.10381@news.indigo.ie>

Hello everybody,

I've recently run across a script that opens a directory handle like this:

my $dh = do { local (*DH); };
if(opendir($dh, $somedir))
{
 ...
}

Just for curiosity, how does one untaint such a handle? Normally, I would
say

local *DH;
if(opendir(DH, $somedir))
{
        DH->untaint();
        ...
}, but in this case I tried $dh->untaint(), dh->untaint() and other
variations but all say syntax error.
Any help would be appreciated. 

Regards,
Dan.



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

Date: 23 Sep 2004 10:57:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Untainting a filehandle
Message-Id: <ciua6q$eh9$1@mamenchi.zrz.TU-Berlin.DE>

Dan Moinescu  <danmoinescu@yahoo.com> wrote in comp.lang.perl.misc:
> Hello everybody,
> 
> I've recently run across a script that opens a directory handle like this:
> 
> my $dh = do { local (*DH); };
> if(opendir($dh, $somedir))
> {
> ...
> }

Now $dh is a globref, not an IO::Handle object, so method calls
won't work.

> Just for curiosity, how does one untaint such a handle? Normally, I would
> say
> 
> local *DH;
> if(opendir(DH, $somedir))
> {
>         DH->untaint();
>         ...
> }, but in this case I tried $dh->untaint(), dh->untaint() and other
> variations but all say syntax error.

No.  Some variants are run-time errors.

You need to access the underlying object through a reference, so

    ( \ $dh)->untaint;

will work.  A better solution would be to use the object throughout.

    my $dh = \ do { local *DH };
    open( $dh, $somedir);
    $dh->untaint;

Anno


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

Date: Thu, 23 Sep 2004 12:16:53 +0100
From: Dan Moinescu <danmoinescu@yahoo.com>
Subject: Re: Untainting a filehandle
Message-Id: <iiy4d.31828$Z14.10552@news.indigo.ie>

Anno Siegel wrote:

> Dan Moinescu  <danmoinescu@yahoo.com> wrote in comp.lang.perl.misc:
>> Hello everybody,
>> 
>> I've recently run across a script that opens a directory handle like
>> this:
>> 
>> my $dh = do { local (*DH); };
>> if(opendir($dh, $somedir))
>> {
>> ...
>> }
> 
> Now $dh is a globref, not an IO::Handle object, so method calls
> won't work.
> 
>> Just for curiosity, how does one untaint such a handle? Normally, I would
>> say
>> 
>> local *DH;
>> if(opendir(DH, $somedir))
>> {
>>         DH->untaint();
>>         ...
>> }, but in this case I tried $dh->untaint(), dh->untaint() and other
>> variations but all say syntax error.
> 
> No.  Some variants are run-time errors.
True. I meant just "errors".
> 
> You need to access the underlying object through a reference, so
> 
>     ( \ $dh)->untaint;
> 
> will work.  A better solution would be to use the object throughout.
> 
>     my $dh = \ do { local *DH };
>     open( $dh, $somedir);
>     $dh->untaint;
> 
> Anno

Thanks, that did the trick.
Dan.



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

Date: Thu, 23 Sep 2004 12:49:59 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Untainting a filehandle
Message-Id: <10l5hjnb9579i8f@corp.supernews.com>

In article <9yx4d.31824$Z14.10381@news.indigo.ie>,
    Dan Moinescu  <danmoinescu@yahoo.com> wrote:

: [...]
: Any help would be appreciated. 

I strongly encourage you to use another approach.  The perlsec manpage
also admonishes against what you're trying to do:

    That means using a bit of thought--don't just blindly
    untaint anything, or you defeat the entire mechanism.  It's
    better to verify that the variable has only good characters
    (for certain values of "good") rather than checking whether
    it has any bad characters.  That's because it's far too
    easy to miss bad characters that you never thought of.

I realize you "know" the filenames will always be safe, but please,
please, PLEASE apply the wisdom in the passage above rather than blindly
untainting the dirhandle.

Greg
-- 
In Tyler, Texas, there used to be the most accurately named used car
dealership in American history: Caveat Emptor Motors. "Let the buyer
beware." It was a clever name, but the company went out of business.
I guess the buyers bewore too much.    -- Gary North


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

Date: Thu, 23 Sep 2004 13:14:16 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Untainting a filehandle
Message-Id: <10l5j184dti2l6c@corp.supernews.com>

In article <10l5hjnb9579i8f@corp.supernews.com>,
    Greg Bacon <gbacon@hiwaay.net> wrote:

: I realize you "know" the filenames will always be safe, but please,
: please, PLEASE apply the wisdom in the passage above rather than blindly
: untainting the dirhandle.

Hmm.. rereading Dan's post, I think I may have been too harsh: maybe
he knows that he needs to untaint data but doesn't know a good way to
do it.

The perlsec manpage describes how to untaint data:

    But testing for taintedness gets you only so far.
    Sometimes you have just to clear your data's taintedness.
    The only way to bypass the tainting mechanism is by
    referencing subpatterns from a regular expression match.
    Perl presumes that if you reference a substring using $1,
    $2, etc., that you knew what you were doing when you wrote
    the pattern.

Say you expect filenames to begin with four lowercase, unaccented
letters; followed by a dash; and end with three digits.

    #! /usr/local/bin/perl -T

    use warnings;
    use strict;

    # $dir would also need to be untainted if we had
    # read it as input and not hardcoded it
    my $dir = ".";

    opendir my $dh, $dir or die "$0: opendir $dir: $!\n";

    my @files;

    while (defined(my $file = readdir $dh)) {
        next unless -f "$dir/$file";

        if ($file =~ /^([a-z][a-z][a-z][a-z]-\d\d\d)\z/s) {
            # we can now get an untainted version of $file
            # through $1

            push @files, "$dir/$1";
        }
        else {
            warn "$0: ignoring '$dir/$file'\n";
        }
    }

    # a dummy representative of operations that would
    # choke on tainted data
    foreach my $path (@files) {
        if (open my $fh, $path) {
            local $/;

            my $contents = <$fh>;
            print "$path: ", length($contents), "\n";
        }
        else {
            warn "$0: open $path: $!\n";
            next;
        }
    }

Hope this helps,
Greg
-- 
The one pervading evil of democracy is the tyranny of the majority, or
rather of that party, not always the majority, that succeeds, by force or
fraud, in carrying elections.
    -- Lord Acton


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

Date: Thu, 23 Sep 2004 18:54:24 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Using C::Scan : How to ignore #includes ? 
Message-Id: <_iA4d.39$6E4.112@news.oracle.com>

Hi,

I have a piece of code which parses a file using C::Scan, and takes in the 
declarations :

use strict;
use warnings;
use C::Scan;

    my $c = new C::Scan 'filename' => $name;
    my $fdec = $c->get('fdecls');

I am able to get the declarations in $fdec, but I  also get the following 
warnings:

In file included from :1:
sample_main.oc:4:8: macro names must be identifiers
sample_main.oc:4:15: s.h: No such file or directory
sample_main.oc:8:20: adcore.h: No such file or directory
sample_main.oc:12:20: adxstf.h: No such file or directory

I basically am interested *only* in the *prototypes* of the functions.[1]

How can I remove the warnings given below ? I tried looking through Scan.pm 
and Data/Flow.pm, but without success.

Thanks
Abhinav

[1] : $fdec contains info for functions with only prototypes, as well as 
definitions. I need only the prototypes. I am currently checking if the 
result matches with m/[)]\s*[;]\s*$/ to get what I need. Anyway to do it 
through C::Scan itself?



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

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


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