[25377] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7622 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 8 11:05:52 2005

Date: Sat, 8 Jan 2005 08:05:21 -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           Sat, 8 Jan 2005     Volume: 10 Number: 7622

Today's topics:
    Re: Command or script to delete hidden files on ftp? <joe@inwap.com>
    Re: Extarcting And Storing a String <joe@inwap.com>
    Re: Extarcting And Storing a String <joe@inwap.com>
    Re: match regex split <joe@inwap.com>
    Re: Need help with Perl regex <regner@dievision.de>
    Re: Net::SSH::Perl - remoteinteract.pl -> Solution <joe@inwap.com>
    Re: Net::SSH::Perl - remoteinteract.pl -> Solution <news@chaos-net.de>
    Re: Net::SSH::Perl - remoteinteract.pl doesn?t work <joe@inwap.com>
    Re: Net::SSH::Perl - remoteinteract.pl doesn?t work <news@chaos-net.de>
    Re: open linux file with perl <news@chaos-net.de>
    Re: Perl and TeX <bik.mido@tiscalinet.it>
    Re: Printing arrow keys through perl <joe@inwap.com>
    Re: Read a password from keyboard... <joe@inwap.com>
    Re: Read a password from keyboard... <joe@inwap.com>
        reference of $worksheet obj. <sam.wun@authtec.com>
    Re: reference of $worksheet obj. <toddrw69@excite.com>
    Re: Some question?! <joe@inwap.com>
    Re: Some question?! <abigail@abigail.nl>
    Re: specifying use strict <joe@inwap.com>
    Re: Terminal size <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 08 Jan 2005 03:30:42 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Command or script to delete hidden files on ftp?
Message-Id: <ic-dnQz2EYv5WULcRVn-qg@comcast.com>

Jason Priest wrote:
> is there a command or script I can run on my web site to clear out
> hidden files in a directory, files that were accidently chmod' to not
> appear?

It could be the directory which has bad permissions - that could
make *all* of the files in the directory inaccessible.

   print join("\n\t",'before chmod',<$directory/*>),"\n\n";
   chmod 0755,$directory;	# Or 0711
   print join("\n\t",'after  chmod',<$directory/*>),"\n";

	-Joe


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

Date: Sat, 08 Jan 2005 04:40:03 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Extarcting And Storing a String
Message-Id: <YtidnSVVb-Y7SULcRVn-hQ@comcast.com>

mjl69 wrote:
> /.*url:\s+(\S+)\s+.*/;
> but it won't work if there is not at least one space on each side of the
> url.

Then use \s* instead of the first \s+ and get rid of the second.
You want either /.*?url:/ or /url:/ to ignore potential matches
in the garbage field.
	-Joe


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

Date: Sat, 08 Jan 2005 05:22:42 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Extarcting And Storing a String
Message-Id: <2dWdnYYCiIk-Q0LcRVn-jA@comcast.com>

Digger wrote:

> [2004-12-25 9:20:12] FAILED http://hotmail.com/bla
> [2004-12-25 9:25:12] SUCCESS http://hotmail.com/bla
> [2004-12-25 9:26:12] FAILED http://abc.com
> [2004-12-25 9:27:12] FAILED http://123.com

my %status;
while (<>) {
   / (FAILED|SUCCESS) (.*)/ and $status{$2} = $1;
}
print "URLs whose last status was SUCCESS:\n";
$status{$_} eq 'SUCCESS' and print "  $_\n" for sort keys %status;

print "\nURLs whose last status was FAILED:\n";
$status{$_} eq 'FAILED'  and print "  $_\n" for sort keys %status;

	-Joe


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

Date: Sat, 08 Jan 2005 03:17:33 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: match regex split
Message-Id: <EaydnYYBifzNXELcRVn-hw@comcast.com>

MisterX wrote:

> Server date/time: 01/03/05   20:05:57  Last access: 01/02/05
> 20:06:25
> Total number of bytes transferred:    27.42 GB
> Elapsed processing time:           01:04:07

I prefer to put the parsed pieces into variables, then output
the whole thing when the end-of-log-entry is seen.
	-Joe

while (<>) {
   $server_time = $1 if /Server date\/time:\s*(\S+)\s+(\S+)/;
   $last_access = $1 if /Last access:\s*(\S+)\s+(\S+)/;
   $gigabytes   = $1 if /Total number of bytes transferred:\s*(\S+)/;
   print "ST:$server_time LA=$last_access GB=$gigabytes ET=$1\n"
		    if /Elapsed processing time:\s*(\S+)/;
}


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

Date: Sat, 08 Jan 2005 15:28:38 +0100
From: Tom Regner <regner@dievision.de>
Subject: Re: Need help with Perl regex
Message-Id: <41dfedb2$0$30192$4d3ebbfe@news1.pop-hannover.net>

surfking wrote:

>  
> 
> I found this line of code
> which was parsing the /etc/termcap file located on a UNIX system.
[...]
> I realize that the "^" character is used to anchor the pattern match to
> the start of a buffer and that enclosing part of a pattern match within
> a set of parenthesis enables you to retrieve the value of the matched
> segment and that "|" is used as an "logical or" operator, but given the
> format of entries in the /etc/termcap file, I don't see how this pattern
> is successfull. Can anyone out there give me some ideas on this ?

let's see what matches what:

> if (/(^|\|)${term}[:\|]/) {
       ^     ^      ^
       |     |      |
       |     |      |___ 3) colon OR backslash 
       |     |____          OR pipe (character-class) 
       |          2) contents of variable $term
       |
    1) beginning of line OR pipe, capturing
    pipe is escaped here!

and one entry to see the format:

v1|xterm-24|xterms|vs100|24x80 xterm:\
        :li#24:\
        :tc=xterm:


that is a pipe-seperated list of terminal names, followed by a colon
followed by colon-delimited definitions, the backslash at the end of each
lines suggests that these three lines are to be read as one huge line (the
newlines are escaped).

so lets see:
--------code
#!/usr/bin/perl
my $term = 'vs100';
my $tc = <<'EOF'
v1|xterm-24|xterms|vs100|24x80 xterm:\
        :li#24:\
        :tc=xterm:
EOF
;
print "matched\n1) $1\n2) $2\n3) $3\n" if $tc =~ /(^|\|)(${term})([:\|])/;
--------/code
(I'm capturing the three numberd parts for clarification only!)

produces:

[1520]tom@margo perl $ perl  test.pl
matched
1) |
2) vs100
3) |


The maybe unfamiliar "${term}" is explained best (at least the best
explanation I found :-) in perldoc perldata

--------quote
As in some shells, you can enclose the variable name in braces to
disambiguate it from following alphanumerics (and underscores).  You must
also do this when interpolating a variable
       into a string to separate the variable name from a following
double-colon or an apostrophe, since these would be otherwise treated as a
package separator.
--------/quote

hth,
Tom
-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de


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

Date: Sat, 08 Jan 2005 03:00:38 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Net::SSH::Perl - remoteinteract.pl -> Solution
Message-Id: <QO-dnQyXvYbFIELcRVn-og@comcast.com>

Martin Kissner wrote:

> Next step will be, to try remote interaction on my cisco router.
> Thanks again for the help.

Are you intending to re-invent the wheel, or will you be using
Net::Telnet::Cisco for that?

http://nettelnetcisco.sourceforge.net/

	-Joe


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

Date: 8 Jan 2005 13:51:33 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Net::SSH::Perl - remoteinteract.pl -> Solution
Message-Id: <slrnctvpb6.g0.news@maki.homeunix.net>

Joe Smith wrote :
> Martin Kissner wrote:
>
>> Next step will be, to try remote interaction on my cisco router.
>> Thanks again for the help.
>
> Are you intending to re-invent the wheel, or will you be using
> Net::Telnet::Cisco for that?
>
> http://nettelnetcisco.sourceforge.net/
>
> 	-Joe

My first intention is to learn and to practice.
Thanks for the hint to Net::Telnet::Cisco
I will try this as soon as i find the time to do.

I also want to try to find a solution with ssh for secure communication.
This might be a challenge, since my IOS doesn't support ssh v2.
As far as I understand this is a prerequisite for sending more than one
command in one session.


-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: Sat, 08 Jan 2005 04:24:53 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Net::SSH::Perl - remoteinteract.pl doesn?t work
Message-Id: <hLadnc-tY7uITELcRVn-gg@comcast.com>

Martin Kissner wrote:
> my script hangs
>     $packet->put_str($old_password);

     $packet->put_str($old_password."\n");


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

Date: 8 Jan 2005 13:26:18 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Net::SSH::Perl - remoteinteract.pl doesn?t work
Message-Id: <slrnctvnrr.g0.news@maki.homeunix.net>

Joe Smith wrote :
> Martin Kissner wrote:
>> my script hangs
>>     $packet->put_str($old_password);
>
>      $packet->put_str($old_password."\n");
Yes, this works, too.
	$packet->put_str(i"$old_password\n");
is also possible.

-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: 8 Jan 2005 10:10:10 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: open linux file with perl
Message-Id: <slrnctvcc2.frf.news@maki.homeunix.net>

Roll wrote :
> hi ppl,
> i have program a webpage for ppl to put some data on a file but i have a
> problem of opening the file and input the data onto the specific file. it
> is a dhcp.conf file of the linux operating system.
>
You also have to consifer that the user, under which the webserver runs,
has sufficient file permissions to read and change the file.
Since itīs a conf-file, only root might be able to write to the file by
default.


-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: Sat, 08 Jan 2005 14:35:35 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl and TeX
Message-Id: <8ulvt0tuleremo3aov81m88ck61t834en2@4ax.com>

On Wed, 05 Jan 2005 13:37:27 -0800, Jon Ericson
<Jon.Ericson@jpl.nasa.gov> wrote:

>> something I should have done in the first place (interested readers
>> can check the original thread for reference)...
>
>Add: (iii) it's not entirely clear what is being proposed.  I *think*
>the idea is to implement the tex program in Perl6, in which case I'm
>not sure what the advantage would be.

There's been some talking in the past about limitations of current TeX
engine(s), hypothetical replacements and hypothetical possibilities
for the actual choice of a language for the implementation, always
taking into account the peculiarities of TeX that indeed would most
probably still be there in any "replacement".

Now it occurs to me that (i) Perl6 will be somewhat similar to TeX in
that it will allow the parser to be configurable at compile time, i.e.
it will allow its grammar to be changed on the fly and (ii) it will be
powerful enough to parse at least one language of that complexity:
namely, itself. Please note that this won't be implemented by means of
some exotic as hoc code, but by means of a series of basic features of
the language (rules/grammars).

Now what I was proposing was a highly theoretical (call it vaporware
if you prefer) discussion about wether Perl6 could be a suitable
language for such a TeX-like program or TeX successor.

Of course Perl6 itself or a suitably restricted subset of it may
become the basis for the macro expansion language itself.

>On the other hand, I can see an advantage in replacing (or at least
>augmenting) the TeX macro system with something more perlish.  But we
>already have PerlTeX (on CTAN at macros/latex/contrib/perltex/), which
>scratches that itch (at least for me).

Of course I've tried PerlTeX ("obviously!"), but it wouldn't be too
bad to have a tighter integration, especially taking into account how
much clearer/easier/more powerful _well written_ Perl code is if
compared to the sort of technicalities required to perform even
seemingly simple tasks with TeX.

It was just my opinion, David's opinion is different, and I'm
definitely taking it into account by virtue of his immense knowledge
about TeX. I am still under the impression that he doesn't really know
(please do not take this as an ad homonem argument) about Perl, not to
say Perl6. In particular the claim that Perl wouldn't be well suited
at handling lists IMHO is not well founded. Oh and while we're here
not only Perl6 will have a better support in this sense, but it will
also have -amongst many other things- real macros a la lisp.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Sat, 08 Jan 2005 04:08:06 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Printing arrow keys through perl
Message-Id: <Yrmdne-wqN60UELcRVn-gg@comcast.com>

madhav_a_kelkar@hotmail.com wrote:

>           I am using Perl/Expect and I want to send arrow keys to a
> process running in background. But I was unable to simulate the arrow
> keys through perl by  using their ascii code and the perl chr()

I don't know about your keyboard, but my keyboard sends four
8-bit (not necessarily ASCII) characters for each arrow key
and five for each function key.

perl -MTerm::ReadKey -e '$|=ReadMode('raw');while($_ ne"q"){printf"%02x 
",ord($_=ReadKey 0)}'

	-Joe


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

Date: Sat, 08 Jan 2005 02:55:23 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Read a password from keyboard...
Message-Id: <JMKdnehtk4CDIULcRVn-jA@comcast.com>

Sherm Pendley wrote:
> Dominic Dupuis wrote:
> 
>>   Does anybody have a way to read a password, from a user, and only
>>   display "****" for each character read?!?
> 
> That Question is Frequently Asked, so appears in the FAQ:
> 
> perldoc -q password

But that does not do exactly what the poster asked.

I interpreted it as "How can I read a password a character at a time
so that asterisks can be printed as the password is being typed."

Term::ReadKey has ReadMode('noecho'), but not ReadMode('noecho+cbreak').
It is ReadLine(0) but not ReadLineWithAsterisksPrinted(0).

Of course if the displaying of asterisks is not really needed,
then the FAQ answer is sufficient.
	-Joe


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

Date: Sat, 08 Jan 2005 04:16:03 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Read a password from keyboard...
Message-Id: <hLadncytY7ubUkLcRVn-gg@comcast.com>

Joe Smith wrote:

> I interpreted it as "How can I read a password a character at a time
> so that asterisks can be printed as the password is being typed."

Ignore my previous answer.
This can give the OP something to think about:

perl -MTerm::ReadKey -e 
'$|=ReadMode('raw');print"PW:";for(;;){$_=ReadKey 0;last if$_ 
eq"\n";$p.=$_;printf"%02x*",ord}print "\n$p\n"'

	-Joe


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

Date: Sat, 08 Jan 2005 22:26:47 +0800
From: sam <sam.wun@authtec.com>
Subject: reference of $worksheet obj.
Message-Id: <cros5e$10qu$1@news.hgc.com.hk>


Hi,

I try to use Spreadsheet::WriteExcel in my perl project, but couldn't 
get the ref of $worksheet passed into a subroutine. Please see the code 
below:

#!/usr/bin/perl -w

use strict;
use Spreadsheet::WriteExcel;

sub testing_sub
{
     my ($myvar1,$myvar2,$worksheet,$excel_file) = @_;

     $worksheet->write(0, 1, "testing") if ($worksheet and $excel_file);
     print $myvar1, $myvar2;
}

sub main
{
     # Create a new workbook called simple.xls and add a worksheet
     my $workbook  = Spreadsheet::WriteExcel->new("simple.xls");
     my $worksheet = $workbook->add_worksheet();

     my$excel_file = "./simple.xls";
     $worksheet->write(0, 0,  "Hi Excel!");

     testing_sub("str1","str2",\$worksheet,$excel_file);
#    testing_sub("str1","str2",\$worksheet);
}

main();

What should be the correct way to pass the ref obj of $worksheet?

thanks
Sam


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

Date: Sat, 08 Jan 2005 14:44:12 GMT
From: "Todd W" <toddrw69@excite.com>
Subject: Re: reference of $worksheet obj.
Message-Id: <0lSDd.6477$Vj3.4870@newssvr17.news.prodigy.com>


"sam" <sam.wun@authtec.com> wrote in message
news:cros5e$10qu$1@news.hgc.com.hk...
>
> Hi,
>
> I try to use Spreadsheet::WriteExcel in my perl project, but couldn't
> get the ref of $worksheet passed into a subroutine. Please see the code
> below:
>
> #!/usr/bin/perl -w
>
> use strict;
> use Spreadsheet::WriteExcel;
>
> sub testing_sub
> {
>      my ($myvar1,$myvar2,$worksheet,$excel_file) = @_;
>
>      $worksheet->write(0, 1, "testing") if ($worksheet and $excel_file);
>      print $myvar1, $myvar2;
> }
>
> sub main
> {
>      # Create a new workbook called simple.xls and add a worksheet
>      my $workbook  = Spreadsheet::WriteExcel->new("simple.xls");
>      my $worksheet = $workbook->add_worksheet();
>
>      my$excel_file = "./simple.xls";
>      $worksheet->write(0, 0,  "Hi Excel!");
>
>      testing_sub("str1","str2",\$worksheet,$excel_file);
> #    testing_sub("str1","str2",\$worksheet);
> }
>
> main();
>
> What should be the correct way to pass the ref obj of $worksheet?
>

Because $worksheet is already contains a scalar value, you dont need to take
a reference to it. In other words, drop the '\'.

Todd W.




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

Date: Sat, 08 Jan 2005 05:32:30 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Some question?!
Message-Id: <soednZhEDd1sfULcRVn-uw@comcast.com>

Tanja wrote:
> Please help me:

That was not a very informative Subject: line.

> 1.) Is it possible to run IE and fill web form, with perl program?

Simple answer: No, you run a perl program *instead of* IE.

Other answer: There are some Win32 modules that allow perl to control 
other processes (such as iexplore.exe).

> 3.) Where to find free version of Cron for Windows?

For the cases where the built-in Task Scheduler is not enough,
I use the cron that comes from http://www.cygwin.com/
It is a full-fledged POSIX environment and has its own perl.

	-Joe


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

Date: 08 Jan 2005 13:45:34 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Some question?!
Message-Id: <slrnctvovu.l1l.abigail@alexandra.abigail.nl>

Tanja (tanja@verso.co.izbaciovo) wrote on MMMMCXLVII September MCMXCIII
in <URL:news:41defac5$1@news.s5.net>:
][  Please help me:
][  I have some problem, is perl is good choices for solve it?
][  
][  1.) Is it possible to run IE and fill web form, with perl program?

If IE has an API to allow execution of 'remote commands', then it can
be done from Perl.

But why would you? You can fill out web forms and submit them using
just Perl. No IE needed.

Your question is of the form "can I use a my wife's car to tow my car
so I can visit my grandmother?". It would be much simpler to just take
your wife's car and visit your grandmother that way.

][  2.) How to check subject line in E-mail message in mailbox (on Internet)
][  with perl script
][             (started in Windows based PC)

I'd use LPW or WWW::Mechanize.

][  3.) Where to find free version of Cron for Windows?

Not a Perl question.

][  4.) Can you compare speed of program written in perl, and program written in
][  C or Pascal?
][             In seconds of execution identical program written in different
][  language.

Yes.


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Sat, 08 Jan 2005 02:33:23 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: specifying use strict
Message-Id: <BZednUPDhsdoK0LcRVn-3Q@comcast.com>

g3000 wrote:

> I thought that when I opened the file with my hash in it using
> eval <'my file handle here'>
> that it would bring %rep "into" my code?

No, it will not bring %rep into scope during the compile phase.
The eval stuff isn't parsed until later, but compilation stops
before that.

Either put
   my(%rep,$lstBackupLoc,$bkupID);
in front of the eval, or replace the whole CONFREP thing with
   use 'backupRepository.conf';

	-Joe


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

Date: Sat, 08 Jan 2005 05:19:12 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Terminal size
Message-Id: <2dWdnYcCiIlCQELcRVn-jA@comcast.com>

pradeep wrote:
> Hi all
> 
> use Term::ReadKey;
> ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize() ;
> 
> use Term::ANSIColor ;
> 
> In my perl script these two functions, are working correctly in unix
> environment, But these 2 functions gives me error when i use it in
> solaris

You can't use those modules unless they have been installed.

/usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris/Term/ReadKey.pm

Note the "site_perl" part.  That means that it was not part of
the core perl distribution, and is something I installed later.

   use Term::ReadKey;
   use Term::ANSIColor;
   ($w,$h,$x,$y)=GetTerminalSize();
   print color("bold"),$^O,color("reset")," w=$w h=$h x=$x y=$y\n";

solaris w=80 h=46 x=0 y=0

	-Joe


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

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


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