[21843] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4047 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 30 11:05:51 2002

Date: Wed, 30 Oct 2002 08:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 30 Oct 2002     Volume: 10 Number: 4047

Today's topics:
    Re: ---looking for suidperl (Tad McClellan)
    Re: Creating a Microsoft Word file with Win32::OLE (alex ortiz)
    Re: flock question addendum <ihave@noemail.com>
        Help understanding Perl logic <ihave@noemail.com>
    Re: Help understanding Perl logic <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Help understanding Perl logic <ihave@noemail.com>
    Re: Help understanding Perl logic <tassilo.parseval@post.rwth-aachen.de>
    Re: How can I remove null entires from an array? <nobull@mail.com>
    Re: How can I remove null entires from an array? <jurgenex@hotmail.com>
    Re: How to pass control character to a telnet session <nobull@mail.com>
    Re: How to pass control character to a telnet session news@roaima.freeserve.co.uk
        Limit output of examine (x) and return (r) in debugger. (tî'pô)
    Re: Limit output of examine (x) and return (r) in debug <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Limit output of examine (x) and return (r) in debug (Peter Scott)
    Re: Matt Wright's FormMail.pl: a little help needed (Helgi Briem)
        Open user-application using PERL (Dennis Mueller)
    Re: Open user-application using PERL <ubl@schaffhausen.de>
        pls help on expand wildcard * in perl <email.erneo@msa.hinet.net>
    Re: pls help on expand wildcard * in perl <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: pls help on expand wildcard * in perl (Helgi Briem)
    Re: POST filter <usenet@dwall.fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 30 Oct 2002 08:18:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ---looking for suidperl
Message-Id: <slrnarvqhe.355.tadmc@magna.augustmail.com>

Bill zhao <zhaoq@onelink.com.cn> wrote:

> Subject: ---looking for suidperl
           ^^^
           ^^^

Please stop tagging your Subject lines.


> I have just installed perl-5.8.0


Did you read perldelta.pod ?


> Now I don't have the suidperl which exist in my old
> perl-5.00503

> Somebody can help me with it?


You could have helped yourself with it.

   grep suidperl *.pod


Finds several interesting mentions:

   After years of trying, suidperl is considered to be too complex to
   ever be considered truly secure.  The suidperl functionality is likely
   to be removed in a future release.

   ...

   suidperl is neither built nor installed by default.

   ...

   The suidperl functionality is most
   probably going to be removed in Perl 5.10.  In any case, suidperl
   should only be used by security experts who know exactly what they are
   doing and why they are using suidperl instead of some other solution
   such as sudo ( see http://www.courtesan.com/sudo/ ).

And in "perltodo.pod":

   C<suidperl> is deprecated in favour of common sense.


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


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

Date: 30 Oct 2002 05:29:25 -0800
From: aort527@hotmail.com (alex ortiz)
Subject: Re: Creating a Microsoft Word file with Win32::OLE
Message-Id: <c3f04d21.0210300529.7dad6723@posting.google.com>

Calvin Wong <cawong@cisco.com> wrote in message news:<3DBF112E.157BA2C5@cisco.com>...
> Hello everyone,
> 
> I have a problem that I hope you guys can help me with.
> What I am trying to do is create a word document and
> populate it with data using Win32::OLE module.
> 
> I have grab code from many different web pages and none
> of them seem to work.
> 
> Can someone please post a simple code to use Microsoft
> word to open a new document, place "hello world" in it, save
> the file, and then close Microsoft word.
> 
> Everytime when I do it, it opens Microword word places the
> text in it and opens a dialog box to save the file, but it doesn't
> save the file nor does it close microsoft word.
> 
> Calvin

try this...
#!\perl 

use strict;
use Win32::OLE::Const 'Microsoft Word';

my $Word = Win32::OLE->new('Word.Application','quit');
$Word->{'Visible'} = 1; #see the app                  
$Word->Documents->Add();  
$Word->Selection->Font->{Size} = 8;  
$Word->Selection->{PageSetup}->{Orientation}=1;
$Word->Selection->{PageSetup}->{LeftMargin}=100;
$Word->Selection->{PageSetup}->{RightMargin}=40;
$Word->Selection->{PageSetup}->{TopMargin}=40;
$Word->Selection->{PageSetup}->{BottomMargin}=20;
$Word->Selection->Font->{Name} = 'Courier new';
$Word->Selection->TypeText("Hello World\n");
$Word->Selection->TypeText("first line\n");
$Word->Selection->TypeText("last World\n");
$Word->ActiveDocument->SaveAs("out.doc");
$Word->ActiveDocument->Close();
$Word->Quit();


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

Date: Wed, 30 Oct 2002 14:16:23 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: flock question addendum
Message-Id: <XQRv9.45$CR7c.19529871@news2.randori.com>

"Alan Barclay" <gorilla@elaine.furryape.com> wrote in message
news:1035894669.498612@elaine.furryape.com...
> In article <FEgv9.50$S23b.16580778@news2.randori.com>,
> TBN <ihave@noemail.com> wrote:
> >Yes, but my computer is down for the afternoon, so I'm working with pen
and
> >paper *gasp* for a few hours and I was trying to work through the problem
> >while I waited for the I.S. goons to come fix my machine.  :-)
>
> I'm amazed that you can post to usenet without a working computer.
>

It's all an illusion.  ;-)

I guess to be fair, I should admit to using a coworkers machine long enough
to send the message.




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

Date: Wed, 30 Oct 2002 14:16:24 GMT
From: "TBN" <ihave@noemail.com>
Subject: Help understanding Perl logic
Message-Id: <YQRv9.46$CR7c.20578326@news2.randori.com>


I wanted to read each line of a file and place it into an array without any
trailing newline characters, so I did this...
open (STUFF, $filespec);
while (<STUFF>) { chomp; push(@myarray,$_); }
close (STUFF);

It works fine, but then I realized some lines have unwanted trailing spaces
as well, so I modified it to...
open (STUFF, $filespec);
while (<STUFF>) { chomp; push(@myarray,$_=~ s/[ ]+$//); }
close (STUFF);

which did not work, but the following does...
open (STUFF, $filespec);
while (<STUFF>) { chomp; $_ =~ s/[ ]+$//; push(@myarray,$_); }
close (STUFF);

Could someone explain to me the difference between the two so that I can
better understand why the former does not work, but the latter does?




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

Date: Wed, 30 Oct 2002 14:35:44 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Help understanding Perl logic
Message-Id: <slrnarvrdo.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <YQRv9.46$CR7c.20578326@news2.randori.com>, TBN wrote:
> 
> I wanted to read each line of a file and place it into an array without any
> trailing newline characters, so I did this...
> open (STUFF, $filespec);


Always make sure open() succeeded:


open (STUFF, $filespec) or die "Can't open $filespec: $!";


> while (<STUFF>) { chomp; push(@myarray,$_); }
> close (STUFF);


Or:


chomp (my @myarray = <STUFF>);


> It works fine, but then I realized some lines have unwanted trailing spaces
> as well, so I modified it to...
> open (STUFF, $filespec);
> while (<STUFF>) { chomp; push(@myarray,$_=~ s/[ ]+$//); }
> close (STUFF);


You have a very weird style of writing code. I'd call it lack of
style, even. :) Isn't the following easier on the eyes:


open (STUFF, $filespec) or die "Can't open $filespec: $!";

while (<STUFF>) {
  chomp;
  s/ +$//; # no need for []s nor for '$_ =~'
  push @myarray, $_;
}


?


Better yet, since you're modifying $_ anyway do the equivalent of
chomp() with the other substituion:


while (<STUFF>) {
  s/[ \n]+$//;
  push @myarray, $_;
}

 
> which did not work, but the following does...


The last one did work, just not as you expected. It pushed the amount
of substitutions done by s/// into the array, because that's what the
=~ operator returns in this case. So even though $_ was modified you
never told Perl that it's what you want to push into the array.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 15:51:05 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: Help understanding Perl logic
Message-Id: <IdTv9.48$CR7c.20054154@news2.randori.com>

Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:slrnarvrdo.hhh.bernard.el-hagin@gdndev25.lido-tech...
> In article <YQRv9.46$CR7c.20578326@news2.randori.com>, TBN wrote:
> >
> > I wanted to read each line of a file and place it into an array without
any
> > trailing newline characters, so I did this...
> > open (STUFF, $filespec);
>
>
> Always make sure open() succeeded:
>
>
> open (STUFF, $filespec) or die "Can't open $filespec: $!";
>
>
> > while (<STUFF>) { chomp; push(@myarray,$_); }
> > close (STUFF);
>
>
> Or:
>
>
> chomp (my @myarray = <STUFF>);
>
>
> > It works fine, but then I realized some lines have unwanted trailing
spaces
> > as well, so I modified it to...
> > open (STUFF, $filespec);
> > while (<STUFF>) { chomp; push(@myarray,$_=~ s/[ ]+$//); }
> > close (STUFF);
>
>
> You have a very weird style of writing code. I'd call it lack of
> style, even. :) Isn't the following easier on the eyes:

It's because I'm new to Perl and come from a Visual BASIC background, so I
program linearly which is counter-Perl.  I'm learning and will undoubtedly
begin to use more Perl "friendly" style as I learn Perl better.

>
>
> open (STUFF, $filespec) or die "Can't open $filespec: $!";
>
> while (<STUFF>) {
>   chomp;
>   s/ +$//; # no need for []s nor for '$_ =~'
>   push @myarray, $_;
> }
>
>
> ?
>
>
> Better yet, since you're modifying $_ anyway do the equivalent of
> chomp() with the other substituion:
>
>
> while (<STUFF>) {
>   s/[ \n]+$//;
>   push @myarray, $_;
> }
>

Thanks, I hadn't considered this obvious improvement.  I haven't quite
figured out complete when I have to reference $_ and when it is implied.
Perl is long learning process for us Windows VBers.

-TBN




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

Date: 30 Oct 2002 16:03:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Help understanding Perl logic
Message-Id: <apovs3$9ae$1@nets3.rz.RWTH-Aachen.DE>

Also sprach TBN:

> Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
> message news:slrnarvrdo.hhh.bernard.el-hagin@gdndev25.lido-tech...

>> Better yet, since you're modifying $_ anyway do the equivalent of
>> chomp() with the other substituion:
>>
>>
>> while (<STUFF>) {
>>   s/[ \n]+$//;
>>   push @myarray, $_;
>> }
>>
> 
> Thanks, I hadn't considered this obvious improvement.  I haven't quite
> figured out complete when I have to reference $_ and when it is implied.

'perldoc -f FUNC' will always tell you whether FUNC implies $_ or not.
You'll be surprised how often you can ditch it.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: 30 Oct 2002 13:22:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How can I remove null entires from an array?
Message-Id: <u9ela8gixl.fsf@wcl-l.bham.ac.uk>

"Melonhead" <tim@melonhead.remove.net> writes rudely in untrimmed jeopardy style:

> Thanks for the prompt reply - that worked great!

If you want to thank someone effectively you should probably refrain
from insulting them in the same breath.

> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
> message news:apo86b$d3e$1@nets3.rz.RWTH-Aachen.DE...
> > Also sprach Melonhead:
> >
> > > for (my $index=0; $index<@emails; $index++) {
> > >      if ($emails[$index] eq "") {
> > >           splice (@emails, $index,1);
> > >           print "spliced - $#emails\n";
> > >           $index=0;
> > >      }
> > > }
> >
> > This is indeed a little questionable. You splice() the array while
> > iterating over it and therefore need to make this contortion of
> > resetting $index.

Of course Melonhead shouldn't be resetting $index=0 he should move it back
by one $index--

Fix that and Melonhead's code should work.

A better approach would be to count down in $index.

for my $index ( reverse 0 .. $#emails ) {
  splice @emails, $index,1 if $emails[$index] eq "";
}

> > Why not a simple grep?
> >
> >     @emails = grep { $_ ne '' } @emails;

That is, of course, a perfectly good answer to the question Melonhead
should have asked: "How can I remove null entrys from a list?".

It is not actually removing null entries from an array.  It is
replacing the entire content of the array with a new list that is
equal to the old content with the nulls removed.

The difference is rarely significant but just in case anyone in future
comes across this thread when they really _do_ want to ask "How can I
remove null entries from an array?" I figured it would be good to
answer that question here :-).

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 30 Oct 2002 15:57:02 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How can I remove null entires from an array?
Message-Id: <ijTv9.46740$wm6.46512@nwrddc01.gnilink.net>

Melonhead wrote:
> My program reads from a | delimited file and stores the values in
> @emails. Quite often some the fields will be empty, i.e. the file
> will be x@abc.com|||b@123.com||me@home.com etc.  For other reasons

I just answered exactly the same question in the other NG.
Please do not multi-post!

jue




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

Date: 30 Oct 2002 13:08:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to pass control character to a telnet session
Message-Id: <u9iszkgjm4.fsf@wcl-l.bham.ac.uk>

pv79@ddsl.net (Prashant Varghese) writes:

> has anyone tried passing control character over telnet session to a
> remote host.

Many people.

> the formats mentioned doesn't seem to work.
> i;ve been trying to find a way to pass '^]' to terminate the telnet
> session in the following manner.
> 
> $r->print ("\c]");
>
> Please tell me if its correct and why it is not working out?

You appear to be confused about the difference between a telnet
session and the telnet program (/usr/bin/telnet on a typical Unix).

The ^] character you are probably thinking of is the telnet program
excape character.  It used in the datastream between the telnet program
and it's controlling terminal to signal that the user wants the telnet
program to stop sending the controlling terminal input to the telnet
session and should rather treat the input as commands to the telnet
program.

This, of course, has nothing to do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 30 Oct 2002 13:11:25 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: How to pass control character to a telnet session
Message-Id: <tplopa.6uh.ln@moldev.cmagroup.co.uk>

Prashant Varghese <pv79@ddsl.net> wrote:
> has anyone tried passing control character over telnet session to a
> remote host.

> I've been trying to find a way to pass '^]' to terminate the telnet
> session in the following manner.

> $r->print ("\c]");

> Please tell me if its correct and why it is not working out?

I don't know what your $r object is supposed to be, so I can only guess
at a possible answer.

    1.	When you type ^] in a telnet client, it and the following text is
	grabbed and interpreted by that local client. None of it gets
	anywhere near the remote host. This means that you can't send a
	^] to a remote host using something like Net::Telnet and expect
	it to work in the same manner. (Net::Telnet has other mechanisms
	for ending a session.)
    
    2.	Are you sure that you should represent ^] by the sequence of
	characters "\c]"? This doesn't feel right to me

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Wed, 30 Oct 2002 14:28:36 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Limit output of examine (x) and return (r) in debugger.
Message-Id: <phfvrugv9olne9emrk6hrepdd2fm4b1ard@4ax.com>

I'm working on a project with rather large data structures, that is
many objects hold references to other objects which also hold
references to still more objects.

My question is this, while using the debugger, when I want to examine
an object using the 'x' or when I'm in a function that returns an
object and I type 'r' I get tons of stuff printed to my terminal. Not
only does this slow me down (it may take up to dozens of seconds each
time) but it also loses all my buffered lines in the xterm.

If I hit ^C as I would in a C[++] debugger the debugger exits.

My question is, is there a way to tell 'x' I only want to follow a
certain number of levels. Or at least to tell the debugger not to
print out the full return value of a function I'm returning from?


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

Date: Wed, 30 Oct 2002 12:34:32 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <slrnarvkaf.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <phfvrugv9olne9emrk6hrepdd2fm4b1ard@4ax.com>, Teh (tî'pô)
wrote:
> I'm working on a project with rather large data structures, that is
> many objects hold references to other objects which also hold
> references to still more objects.
> 
> My question is this, while using the debugger, when I want to examine
> an object using the 'x' or when I'm in a function that returns an
> object and I type 'r' I get tons of stuff printed to my terminal. Not
> only does this slow me down (it may take up to dozens of seconds each
> time) but it also loses all my buffered lines in the xterm.
> 
> If I hit ^C as I would in a C[++] debugger the debugger exits.
                              ^^^^^


Strictly speaking that should probably be


C(\+\+)?


or a variant.


Sorry, I'm bored.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 15:56:43 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <%iTv9.645906$f05.26744395@news1.calgary.shaw.ca>

In article <phfvrugv9olne9emrk6hrepdd2fm4b1ard@4ax.com>,
 "Teh (tî'pô)" <teh@mindless.com> writes:
>I'm working on a project with rather large data structures, that is
>many objects hold references to other objects which also hold
>references to still more objects.
>[snip]
>My question is, is there a way to tell 'x' I only want to follow a
>certain number of levels. Or at least to tell the debugger not to
>print out the full return value of a function I'm returning from?

perldoc perldebug

% perl -de 0
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   0
  DB<1> @a[10] = 42

  DB<2> x @a
0  undef
1  undef
2  undef
3  undef
4  undef
5  undef
6  undef
7  undef
8  undef
9  undef
10  42
  DB<3> O arrayDepth=5
          arrayDepth = '5'
  DB<4> x @a
0  undef
1  undef
2  undef
3  undef
4  undef
 ....
  DB<5> O veryCompact=1
         veryCompact = '1'
  DB<6> x @a
0..10  undef undef undef undef undef ...
  DB<7>

-- 
Peter Scott
http://www.perldebugged.com


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

Date: Wed, 30 Oct 2002 11:29:50 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Matt Wright's FormMail.pl: a little help needed
Message-Id: <3dbfc1d7.1239319967@news.cis.dfn.de>

On Wed, 30 Oct 2002 10:02:10 +0100, Metaverso
<metaverso@nospam.com> wrote:

>I'm an absolute beginner in perl programming, and need a little help for 
>a modification I would like to do to the Matt Wright's FormMail.pl 
>script I've found at the Matt's Script Archive:

Please don't use Matt's scripts.  They are appallingly 
bad and he has even admitted so himself.

For properly written replacements, see the NMS project:
http://nms-cgi.sourceforge.net/

-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 30 Oct 2002 07:17:42 -0800
From: d.mueller@andrae-ag.de (Dennis Mueller)
Subject: Open user-application using PERL
Message-Id: <bb8dc33b.0210300717.d1d7fd4@posting.google.com>

hi ng,

I'd like to offer a msword-document on a homepage. by clicking a link,
this doc should open in MicroSoft Word, not in the IE.

Is there any possibility to realize this in PERL?


thanx in advance
dennis


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

Date: Wed, 30 Oct 2002 16:29:01 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Open user-application using PERL
Message-Id: <app166$cvi$1@news.dtag.de>

Dennis Mueller wrote:
> hi ng,
> 
> I'd like to offer a msword-document on a homepage. by clicking a link,
> this doc should open in MicroSoft Word, not in the IE.
> 
> Is there any possibility to realize this in PERL?

Well, unless you are planning to do a Perl port of IE, there is no way 
to do this, because it is the decision of the client what to do with a 
certain file / type of content.

bye,
->malte


-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Thu, 31 Oct 2002 21:39:40 +0800
From: "PT" <email.erneo@msa.hinet.net>
Subject: pls help on expand wildcard * in perl
Message-Id: <aponh2$bf7@netnews.hinet.net>

any idea on how to rename files with wildcard * in PERL ?

my perl program reads the following one line to remote copy files to the
local host:
#hostname,/log/snap-*.alarms

I have the following files in the local host after the remote copy:
snap-11.alarms
snap-22.alarms
snap-33.alarms

how can I expand the wildcard * to rename those files to a new file name
and move them to another folder in this case?

Thanks in advance!





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

Date: Wed, 30 Oct 2002 13:48:36 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: pls help on expand wildcard * in perl
Message-Id: <slrnarvolb.hhh.bernard.el-hagin@gdndev25.lido-tech>

In article <aponh2$bf7@netnews.hinet.net>, PT wrote:
> any idea on how to rename files with wildcard * in PERL ?
> 
> my perl program reads the following one line to remote copy files to the
> local host:
> #hostname,/log/snap-*.alarms
> 
> I have the following files in the local host after the remote copy:
> snap-11.alarms
> snap-22.alarms
> snap-33.alarms
> 
> how can I expand the wildcard * to rename those files to a new file name
> and move them to another folder in this case?


perldoc -f glob
perldoc -f rename


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Wed, 30 Oct 2002 14:01:53 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: pls help on expand wildcard * in perl
Message-Id: <3dbfe31a.1247835732@news.cis.dfn.de>

On Thu, 31 Oct 2002 21:39:40 +0800, "PT"
<email.erneo@msa.hinet.net> wrote:

>any idea on how to rename files with wildcard * in PERL ?

It's Perl or perl, never PERL.  Humour us.

>my perl program reads the following one line to remote copy files to the
>local host:
>#hostname,/log/snap-*.alarms

You can use the glob function (perldoc -f glob) to read
wildcards, but my inclination would beto do it with grep
and readdir, ie:

my $dir = '/log';
opendir DIR, $dir or die "Cannot opendir $dir:$!\n";
my @files = grep /^stat-.*\.alarm$/,readdir DIR;

>I have the following files in the local host after the remote copy:
>snap-11.alarms
>snap-22.alarms
>snap-33.alarms

>how can I expand the wildcard * 

my @files = glob("/log/*.alarm");

>to rename those files to a new file name
>and move them to another folder in this case?

If they are just being moved to a different folder
on the same disk, rename will do it (perldoc -f rename):

If you need to move the file between disks,
check out the File::Copy module in
perldoc -X File::Copy

-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Wed, 30 Oct 2002 15:20:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: POST filter
Message-Id: <Xns92B76943F5160dkwwashere@216.168.3.30>

hsasshofer <herbert@sasshofer.com> wrote on 30 Oct 2002:

> "David K. Wall" <usenet@dwall.fastmail.fm> wrote in message
> news:<Xns92B675EBE6C0Adkwwashere@216.168.3.30>... 
>> hsasshofer <herbert@sasshofer.com> wrote on 29 Oct 2002:
>> 
>> > I want to write a CGI-script that filters some values of a POST
>> > request and then re-POSTS the data to another script. How do I
>> > transfer the param() values to a HTTP:request with the new post? Do I
>> > have to build an escaped string for the $request->content() call
>> > manually or is there an easier way to pass a hash to a POST request?
>> 
>> Look in lwpcook -- it has an example of posting data to a web server
>> with Perl.  If you don't have LWP installed on your system, you'll need
>> to get it from CPAN.  (I don't remember if LWP is in the standard
>> modules or not.) 
>> 
>> Here's a reference from perldoc.com: 
>> http://www.perldoc.com/perl5.6/lib/lwpcook.html
> 
> Thanks for the help, but I don't have a problem how to do a general
> POST.
> 
> My problem is that my script gets called by some form POSTING quite a
> lot of values, I'll pick a specific one giving me another URL where to
> actually POST the whole stuff (I then have to do some transcoding on
> the resulting answer, so I have to stay in the loop). Now I have a
> foreach loop reading all the param() values, store them in a hash,
> build a string of key=value&... pairs, escape the stuff, and supply
> this to the content() part of a HTTP:Request for the POST.
> 
> Can this be done more easily, getting the param()s back out to the
> next post? Without reading them all in, doing the reformatting, and
> pushing them back out. Is there a way to supply a hash to the POST, or
> only a string. As the keys change I cannot do a manual [key =>
> value,...] type of thing.

I still think you should read the examples in lwpcook.  It sounds like 
you're doing alot of stuff on your own that various modules will do for you 
with less trouble and less chance for error.  For example, the Vars() 
method in CGI.pm is an easy way to get all your parameters into a hash.  
POST() from HTTP::Request::Common is an easy way to build a POST request 
that you can feed to a user agent.  It will accept arrays or hashes as 
input and do all the escaping for you.

Without seeing any code, it seems unlikely that anyone here can help you 
much, least of all me.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

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.  

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


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