Help - Search - Member List - Calendar
Full Version: combinations
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
Support our Sponsors!
John Nestor
Thanks for the help, Dave. As it turns out, it was a data problem--I'm
trying to parse an RTF file, and was getting an unexpected style--for
whatever reason, that was knocking the script for a loop.

I'm using MacPerl 5.6.1 on Mac OS 9.2.2. In desperation, I did some
diagnostics on my machine, and discovered the MacPerl preferences file lost
its resource fork--that probably didn't help things, either.

Out of curiosity, is there a module for parsing RTF files? I try to write to
vanilla perl setups, but it I can see where it might be worthwhile in this
instance.

John


QUOTE
----------
From:  david
Reply To:  [Email Removed]
Sent:  Tuesday, September 2, 2003 1:02 PM
To:  [Email Removed]
Subject:  Re: new, exciting error message III

John Nestor wrote:

A couple of days ago, I sent in some code with an error message:

Can't find unicode character property definition via main->a or a.plFile
'unicode/Is/a.pl'; Line 0

As it turns out, the code sample I included was not the cause of the
problem, apparently. However, if I comment out the following line:

$_=~s#^\par (.+?)$#\par <IDX1>$1</IDX1>n#;

i might have missed your previous message a couple days ago but what
version
of Perl are you working with and on what platform? this line doesn't cause

any problem on my machine, RH 7.3 2.4.18-14 with Perl v5.8.0.

the error message you are describing usually happen when Perl can't find
the
unicode mapping for a certain characters that it can't find. for example,
in a UNIX machine with Perl v5.6.0 and a OpenBSD box with Perl v5.6.1:

[panda] $ perl -e '$_=""; s/par//'
Can't find unicode character property definition via main->a or a.pl at
unicode/Is/a.pl line 1
[panda] $

the 'pa' thing tells Perl to look for a character mapping for the unicode

character 'a' which doesn't exists. your regex actully correctly espace
the
'' with '\' so it shouldn't be a problem at all. are you sure it's not
just a typo somewhere?

david

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]




****************************************************************************

This email may contain confidential material.
If you were not an intended recipient,
please notify the sender and delete all copies.
We may monitor email to and from our network.

****************************************************************************

Paul Kraus
http://search.cpan.org/search?query=rtf&mode=all

-----Original Message-----
From: Nestor, John [mailto:[Email Removed]]
Sent: Wednesday, September 03, 2003 9:10 AM
To: [Email Removed]; '[Email Removed]'
Subject: RE: new, exciting error message III


Thanks for the help, Dave. As it turns out, it was a data problem--I'm
trying to parse an RTF file, and was getting an unexpected style--for
whatever reason, that was knocking the script for a loop.

I'm using MacPerl 5.6.1 on Mac OS 9.2.2. In desperation, I did some
diagnostics on my machine, and discovered the MacPerl preferences file
lost its resource fork--that probably didn't help things, either.

Out of curiosity, is there a module for parsing RTF files? I try to
write to vanilla perl setups, but it I can see where it might be
worthwhile in this instance.

John


QUOTE
----------
From:  david
Reply To:  [Email Removed]
Sent:  Tuesday, September 2, 2003 1:02 PM
To:  [Email Removed]
Subject:  Re: new, exciting error message III

John Nestor wrote:

A couple of days ago, I sent in some code with an error message:

Can't find unicode character property definition via main->a or
a.plFile 'unicode/Is/a.pl'; Line 0

As it turns out, the code sample I included was not the cause of the

problem, apparently. However, if I comment out the following line:

$_=~s#^\par (.+?)$#\par <IDX1>$1</IDX1>n#;

i might have missed your previous message a couple days ago but what
version of Perl are you working with and on what platform? this line
doesn't cause

any problem on my machine, RH 7.3 2.4.18-14 with Perl v5.8.0.

the error message you are describing usually happen when Perl can't
find the unicode mapping for a certain characters that it can't find.
for example, in a UNIX machine with Perl v5.6.0 and a OpenBSD box with

Perl v5.6.1:

[panda] $ perl -e '$_=""; s/par//'
Can't find unicode character property definition via main->a or a.pl
at
unicode/Is/a.pl line 1
[panda] $

the 'pa' thing tells Perl to look for a character mapping for the
unicode

character 'a' which doesn't exists. your regex actully correctly
espace the '' with '\' so it shouldn't be a problem at all. are you
sure it's not just a typo somewhere?

david

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]




************************************************************************

****
This email may contain confidential material.
If you were not an intended recipient,
please notify the sender and delete all copies.
We may monitor email to and from our network.

************************************************************************
****



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

James Edward Gray II
On Tuesday, September 2, 2003, at 11:51 PM, Bryan Harris wrote:

QUOTE
Thanks for the info, James.  Sounds like threading is still a ways
over my
head, but forking sounds interesting.

I have a perl script that does simple find-replaces within all the
files
passed to it (the key parts were written by very kind people on this
list,
actually).  Would it be advantageous for the script to fork so that it
could
be find-replacing on all files simultaneously as opposed to serially?

I seriously doubt it. It's usually a bad idea to make anything more
complicated than strictly needed.

Multiprocessing is a lot of work, mostly because you have to control
how information is shared between the two processes/threads. For
example, even in a simple find and replace script, each part would have
to know which files were being handled by the other processes/threads.

Save forking and threading for when you absolutely must do two or more
things at once, say in servers, complex GUIs, etc.

Hope that helps.

James

Dan Muey
QUOTE
Greetings!

howdy

QUOTE

I uploaded a set of Perl files to the target server and then
started my application.  I got an error message immediately
claiming that it couldn't find one of my module files in
@INC, and then it told me what @INC was.  The last entry in
it was ".", which represents the current directory.  I'm
pretty durn sure I put all the files into the same place.
So, I'd like to know what the host computer thinks "." is.
How can I retrieve the name of the directory "." points to?

print qx(pwd);

HTH
DMuey

QUOTE

Thanks very much!

Rob



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design
software http://sitebuilder.yahoo.com

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



Randal L. Schwartz
QUOTE
"Dan" == Dan Muey <[Email Removed]> writes:

Dan> print qx(pwd);

Which is just a roundabout way to say (while making Perl work harder
in the meanwhile):

system "pwd";

but that'll fail on non-unix systems, so a more portable way is:

use Cwd;
print getcwd, "n";

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +
<[Email Removed]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Surinder
I am getting the same error, did you get work around.
Thanks, Surinder

QUOTE

......

......
......
cp demos/images/cursor.mask ../blib/lib/Tk/demos/images/cursor.mask
cp demos/widtrib/progress.pl ../blib/lib/Tk/demos/widtrib/progress.pl
cp widget ../blib/script/widget
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" ../blib/script/widget
make[1]: Leaving directory `/.cpan/build/Tk800.024/demos'
/tools/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
Bundle summary: The following items in bundle Bundle::Tk had installation
problems:
Tk


[Email Removed] (Ramprasad) wrote in message news:<[Email Removed]>...
QUOTE
John Burski wrote:
Greetings, All!

I was going to attempt to learn a bit of Perl/Tk, but I've run into a
bit of trouble installing the Tk module.

Here's some information about my system:  Red Hat 8.0, Perl version 5.8.0.
I downloaded Tk-800.024.tar.gz from CPAN. I gunzipped and extracted
everything OK.
The "perl Makefile.PL" command went off without a hitch.
However, I'm not certain that the "make" command is completing properly.
Here's a snippet from the typescript file:
<snip

Manifying blib/man1/ptked.1
make[1]: Entering directory `/usr/local/src/Tk/Tk800.024/pod'
Sorry no HTML building yet
make[1]: Leaving directory `/usr/local/src/Tk/Tk800.024/pod'
]0;root@natasha:/usr/local/src/Tk/Tk800.024[root@natasha Tk800.024]# [root@natasha Tk800.024]# [root@natasha Tk800.024]#
k[root@natasha Tk800.024]# k[root@natasha Tk800.024]# kk[root@natasha
Tk800.024]# kk[root@natasha Tk800.024]# k [K[root@natasha Tk800.024]# k[root@natasha
Tk800.024]#  [K[root@natasha Tk800.024]# exit


</snip

I searched through the typescript file, but I didn't find anything else
that looked "suspicious".

Thanks for your help.


If you havent done any fancy thing on your redhat (  like upgrading perl
or libc )
get perl-Tk rpms ( from rpmfind.net for eg.) and install them Save
yourself the bother of compiling


Ram


Scott E Robinson
"Wagner, David ---
Senior Programmer To: <[Email Removed]>, <[Email Removed]>
Analyst --- WGO" cc:
<David.Wagner@freight Subject: RE: What's the command to find the name of the file being
.fedex.com> executed?


09/03/03 04:44 PM









[Email Removed] wrote:
QUOTE
What's the simple Perl command to find the name of the file from
which the Perl program is being executed?  It was recently on this
newsgroup but I can't find the article now.

Thanks,

Scott

Scott E. Robinson
SWAT Team
UTC Onsite User Support
RR-
EMB-2813N
$0 holds that info.

Wags ;)


Yes, thanks, I recognize it as soon as you say it.

Thanks,

Scott

Scott E. Robinson
SWAT Team
UTC Onsite User Support
RR-
EMB-2813N

On Thu, 28 Aug 2003, zsdc wrote:

QUOTE
[Email Removed] wrote:

On Thu, 28 Aug 2003, Ramprasad A Padmanabhan wrote:

Which OS?
On Unix like systems, You can find the PID of the script and send the
signal on the shell

like
kill -15 $PID

you could also do:

killall -KILL name_of_application

Don't do that on Solaris... Its version of killall actually kills all.


Sorry about that.. Should have also stated that I'm running under linux..

Dont do much under Solaris any longer..

On Mon, 1 Sep 2003 [Email Removed] wrote:

QUOTE
What is the function of cutting a string from a point until the last character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the sequence
following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

I just want a scalar!





why not try this?

#!/usr/bin/perl
my @test='';
my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

HTH.. Denis

On Wed, 3 Sep 2003 [Email Removed] wrote:

QUOTE
On Mon, 1 Sep 2003 [Email Removed] wrote:

What is the function of cutting a string from a point until the last character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the sequence
following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

I just want a scalar!





why not try this?

#!/usr/bin/perl
my @test='';
my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

HTH.. Denis




FYI


$test1 is not used.. was going to try the script another way and didn't..

Toby Stuart
QUOTE
-----Original Message-----
From: Nigel Peck - MIS Web Design [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 10:26 AM
To: [Email Removed]
Subject: IIS Log File Conversion


Does anyone have a code snippet or a module for converting
the IIS log file format to NCSA Common?

Cheers,
Nigel


Never used it but you can use the 'convlog' program to do that.
If you're on windows type 'convlog' at the command prompt.

Note IIS must be installed on the server for the convlog.exe command-line
tool to work.

http://www.microsoft.com/technet/treeview/...chnet/prodtechn
ol/windowsserver2003/proddocs/standard/log_converting2ncsa.asp

There's also this which may help: http://alan-ng.net/scripts/convlog.htm

Nigel Peck - Mis Web Design
Does anyone have a code snippet or a module for converting the IIS log file format to NCSA Common?

Cheers,
Nigel

Charles K. Clarkson
denis <[Email Removed]> offered this solution:

: why not try this?
:
: #!/usr/bin/perl
: my @test='';
: my $string = "C:/test/me";
: @test = split('/',$string);
: print "@testn";
: print "$test[$#test]n";

The last item of an array can be retrieved
using an index of -1.

print "$test[$#test]n";

becomes

print "$test[-1]n";


We don't need an array at all. We can ask split
to return one item:

@test = split('/',$string);
print "$test[-1]n";

becomes

my $scalar = ( split '/', $string )[-1];
print "$scalarn";


If we're going to do this a lot, we could write
a sub routine:

print strip_to_end( '/', 'C:/test/me' ), "n";

sub strip_to_end {
my( $seperator, $string ) = @_;
return ( split $seperator, $string )[-1]
}

Then, if we find a faster method (like 'substr')
we can change the method without effecting the rest
of the program.


HTH,

Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists


David Wall
--On Wednesday, September 03, 2003 9:20 PM -0600 [Email Removed] wrote:

QUOTE
On Mon, 1 Sep 2003 [Email Removed] wrote:

What is the function of cutting a string from a point until the last
character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the
sequence  following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

Well, that's what split() does. :-)

QUOTE
I just want a scalar!


why not try this?

# !/usr/bin/perl
my @test='';
#> my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

Easier (IMO) and portable:

use File::Basename;
my $string="C:/progra~1/directory1/directory2/file.txt";
my $file = basename $string;

Then you don't need to worry about the directory separator, e.g.;

use File::Basename;
my @p = (
"C:/progra~1/directory1/directory2/file.txt",
'C:progra~1directory1directory2file.txt',
"C:\progra~1\directory1\directory2\file.txt",
"C:/progra~1\directory1\directory2/file.txt"
);
print basename($_), "n" for @p;

prints 'file.txt' four times.

basename is more convenient i think. What do you say?


Quoting [Email Removed]:

QUOTE
On Mon, 1 Sep 2003 [Email Removed] wrote:

What is the function of cutting a string from a point until the last
character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the sequence
following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

I just want a scalar!





why not try this?

#!/usr/bin/perl
my @test='';
my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

HTH.. Denis


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


Rkl
Hi all:

Are these libs: WWW:: Mechanize and HTTP::Cookies in perl or mod_perl?

-rkl

Pablo Fischer writes:

QUOTE
Hi!

Im creating an script that checks for broken links. Im using this modules:

use WWW::Mechanize;
use HTTP::Cookies;

What Im trying to do?, I need to login in a website (cause to check broken
links I need to be loged).

I also checked the cookies once I've loged and they're created, however, when
I try to entrer another website I cant cause the website shows me a pretty
message: "Not Authorized".

My Code:
____________________
#El archivo en el que se guardan las cookies
$cookies = "/home/unmada/cookies.txt";

#El objeto que va a estar escuchando las cookies
$cookie = HTTP::Cookies->new(
        file => $cookies,
        ignore_discard => 1,
        autosave => 1);
#$agent->cookie_jar($cookie);

#El objeto que va a hacerla de navegador
my $agent = WWW::Mechanize->new(agent => 'Mozilla/5.0',
    debug => 1);
#La dirección que se va a visitar (la primera)
my $url = "http://cursos.itesm.mx/webapps/login";

#$agent->redirect_ok();
#Decirle al navegador que las cookies van a ser guardadas en el objeto cookie
$agent->cookie_jar($cookie);

#Cargamos la página
$agent->get($url);
#Mostramos el titulo de la página
print $agent->title(),"n";
#Buscamos el formulario que tiene el nombre de 'login'
$agent->form("login");
#Llenamos el campo de user_id
$agent->field("user_id", "username");
#Llenamos el campo de password
$agent->field("password", "password");
#Le damos ENTER
$agent->submit();

Then to enter another website (in the same domain), I jsut:

$agent->get("otherurl_of_the_same_domain");
____

Thanks!
Pablo
--
Pablo Fischer Sandoval ([Email Removed])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


Freddy sderlund
I think it would be easier to skip the split-function and use substr and
rindex insted. It's shorter code.

#!perl -w

my $path = "C:/program files/directory1/directory2/file.txt";
my $filename = substr($path,(rindex($path,"/")+1));
print $filename;

This code will give you "file.txt" as output.

Hope you will find it usefull.

/Freddy

----- Original Message -----
From: <[Email Removed]>
To: <[Email Removed]>
Cc: "Perl Beginners" <[Email Removed]>
Sent: Thursday, September 04, 2003 5:20 AM
Subject: Re: cutting a string


QUOTE
On Mon, 1 Sep 2003 [Email Removed] wrote:

What is the function of cutting a string from a point until the last
character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the
sequence
following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

I just want a scalar!





why not try this?

#!/usr/bin/perl
my @test='';
my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

HTH.. Denis


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



Nigel Peck - Mis Web Design
Thanks, I found that but I'm looking for a Perl solution, should be possible with a one liner regex substitution AFAIK.

Cheers,
Nigel

MIS Web Design
http://www.miswebdesign.com/

QUOTE
-----Original Message-----
From: Toby Stuart [mailto:[Email Removed]]
Sent: 04 September 2003 04:58
To: 'Nigel Peck - MIS Web Design'
Cc: '[Email Removed]'
Subject: RE: IIS Log File Conversion




-----Original Message-----
From: Nigel Peck - MIS Web Design [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 10:26 AM
To: [Email Removed]
Subject: IIS Log File Conversion


Does anyone have a code snippet or a module for converting
the IIS log file format to NCSA Common?

Cheers,
Nigel


Never used it but you can use the 'convlog' program to do that.
If you're on windows type 'convlog' at the command prompt.

Note IIS must be installed on the server for the convlog.exe command-line
tool to work.

http://www.microsoft.com/technet/treeview/...sp?url=/technet
/prodtechn

ol/windowsserver2003/proddocs/standard/log_converting2ncsa.asp

There's also this which may help: http://alan-ng.net/scripts/convlog.htm

Marcos Rebelo
are you speaking of this?

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

-----Original Message-----
From: LoneWolf [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:38 PM
To: [Email Removed]
Subject: Getting rid of white space...


I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP.
THe files from the SCO box are poorly formatted with extraneous whitespace
(sometimes as much as 30 or more) before and after the text. I need to
parse all of the files I DL and put them into a new file with "_nice" added
at the end.

The files are all pipe-delimited, so I don't have a problem separating the
fields, I just am not sure how to make it remove all extra whitespace. It
needs to keep all Space in the fields " the description of the
file " should still be readable as "the description of the file"

Any help with code examples? I have been looking through a beginning book
and my old code and have come up nil.

Thanks,
Robert

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

Freddy sderlund
Capturing parameters passed to a perl-script on Windows is done using the
special @ARGV variable.

@ARGV can be checked to see how many parameters were passed to your script,
easily by doing so:

die "blah blah blah " unless @ARGV == 2;

This will make your script die with a message unless there were two
parameters passed to your script from the command line.

If you want to access the actual values of the @ARGV it's done something
like so:

my $first_param = $ARGV[0];
my $second_param = $ARGV[1];

You could also "shift" them in:

my $first_param = shift;
my $second_param = shift;

Hope this will help you out!

/Freddy

----- Original Message -----
From: "Mark Weisman" <[Email Removed]>
To: <[Email Removed]>
Sent: Thursday, September 04, 2003 10:18 AM
Subject: Capturing passed Parameters?


How do you capture passed parameters in Perl on Windows? In regular perl
its:
$variable = param('passed');

However, when I tried to run that under windows, it dies a horrible
death? I've looked through perl.org for more information about
converting over my unix scripts to windows, any other good places out
there for information?

Sincerely in Christ,
Mark-Nathaniel Weisman
President / Owner
Outland Domain Group Consulting
Anchorage / Washington DC / Bellevue
[Email Removed]

Rob Anderson
QUOTE
"Mark Weisman" <[Email Removed]> wrote in message
news:[Email Removed]...
How do you capture passed parameters in Perl on Windows? In regular perl
its:
$variable = param('passed');

Hi Mark,

Erm, are you talking about passing parameters on the command line or to a
cgi.

if you calling perl myscript.pl "hello";

then you want

print $ARGV[0];

if yours is a CGI then your right

ie http/..../my.cgi?colour=yellow

use CGI;
print param('colour');
(outputs "yellow")

Cheers, Rob

QUOTE

However, when I tried to run that under windows, it dies a horrible
death? I've looked through perl.org for more information about
converting over my unix scripts to windows, any other good places out
there for information?

Sincerely in Christ,
Mark-Nathaniel Weisman
President / Owner
Outland Domain Group Consulting
Anchorage / Washington DC / Bellevue
[Email Removed]


Bob Showalter
[Email Removed] wrote:
QUOTE
What's the simple Perl command to find the name of the file from
which the Perl program is being executed?  It was recently on this
newsgroup but I can't find the article now.

Check out the FindBin module.

Rob Hanson
mod_perl isn't a language, it is an application server.

If the question is "Is it mod_perl safe?", then that is a different
question. I would think they are, both are OOP, and there is no state that
I am aware of that is outside of the object properties.

Rob

-----Original Message-----
From: rkl [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:40 AM
To: perl
Subject: Re: WWW::Mechanize and Cookies


Hi all:

Are these libs: WWW:: Mechanize and HTTP::Cookies in perl or mod_perl?

-rkl

Pablo Fischer writes:

QUOTE
Hi!

Im creating an script that checks for broken links. Im using this modules:


use WWW::Mechanize;
use HTTP::Cookies;

What Im trying to do?, I need to login in a website (cause to check broken

links I need to be loged).

I also checked the cookies once I've loged and they're created, however,
when
I try to entrer another website I cant cause the website shows me a pretty

message: "Not Authorized".

My Code:
____________________
#El archivo en el que se guardan las cookies
$cookies = "/home/unmada/cookies.txt";

#El objeto que va a estar escuchando las cookies
$cookie = HTTP::Cookies->new(
        file => $cookies,
        ignore_discard => 1,
        autosave => 1);
#$agent->cookie_jar($cookie);

#El objeto que va a hacerla de navegador
my $agent = WWW::Mechanize->new(agent => 'Mozilla/5.0',
    debug => 1);
#La dirección que se va a visitar (la primera)
my $url = "http://cursos.itesm.mx/webapps/login";

#$agent->redirect_ok();
#Decirle al navegador que las cookies van a ser guardadas en el objeto
cookie
$agent->cookie_jar($cookie);

#Cargamos la página
$agent->get($url);
#Mostramos el titulo de la página
print $agent->title(),"n";
#Buscamos el formulario que tiene el nombre de 'login'
$agent->form("login");
#Llenamos el campo de user_id
$agent->field("user_id", "username");
#Llenamos el campo de password
$agent->field("password", "password");
#Le damos ENTER
$agent->submit();

Then to enter another website (in the same domain), I jsut:

$agent->get("otherurl_of_the_same_domain");
____

Thanks!
Pablo
--
Pablo Fischer Sandoval ([Email Removed])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]




--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

Stephen Marshall
I have a similar problem to this , does anyone have another answer? Don't know if its just me but The

QUOTE
use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

Code doesn't work , and the enhanced version with the fancy file handling doesn't work either "trying to read from a closed filehandle error"

Stephen

QUOTE
-----Original Message-----
From: Akens, Anthony [mailto:[Email Removed]]
Sent: 04 September 2003 15:55
To: [Email Removed]; [Email Removed];
[Email Removed]
Subject: RE: Getting rid of white space...


I figured I'd take a stab at fleshing this out into what he
wants... Any comments on things I could do better?  I only
added to what Robert had coded...

Tony




#!/usr/bin/perl -w

use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;

opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^..?$/;
open (OLDFILE, "< $file");
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile");
while ($line = <OLDFILE>)  {
($line) = ($line =~ /^s*(.*)s*n$/);
print NEWFILE "$linen";
}
close OLDFILE;
close NEWFILE;
}


-----Original Message-----
From: [Email Removed]
[mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 8:32 AM
To: [Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


are you speaking of this?

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

-----Original Message-----
From: LoneWolf [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:38 PM
To: [Email Removed]
Subject: Getting rid of white space...


I have about 12 files that I am pulling for a SCO box to a
RedHat box, FTP.
THe files from the SCO box are poorly formatted with
extraneous whitespace (sometimes as much as 30 or more)
before and after the text.  I need to parse all of the files
I DL and put them into a new file with "_nice" added at the end.

The files are all pipe-delimited, so I don't have a problem
separating the fields, I just am not sure how to make it
remove all extra whitespace.  It
needs to keep all Space in the fields "        the
description  of  the
file        " should still be readable as "the description
of the file"

Any help with code examples?  I have been looking through a
beginning book and my old code and have come up nil.

Thanks,
Robert

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


Stephen Marshall
Got it working this way fror the important line, but theres probably a slicker way of doing it.

$line =~ s/(s)+/ /g;

QUOTE
-----Original Message-----
From: Marshall, Stephen
Sent: 04 September 2003 17:07
To: 'Akens, Anthony'; [Email Removed];
[Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


I have a similar problem to this , does anyone have another
answer?  Don't know if its just me but The

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

Code doesn't work , and the enhanced version with the fancy
file handling doesn't work either "trying to read from a
closed filehandle error"

Stephen

-----Original Message-----
From: Akens, Anthony [mailto:[Email Removed]]
Sent: 04 September 2003 15:55
To: [Email Removed]; [Email Removed];
[Email Removed]
Subject: RE: Getting rid of white space...


I figured I'd take a stab at fleshing this out into what he
wants... Any comments on things I could do better?  I only
added to what Robert had coded...

Tony




#!/usr/bin/perl -w

use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;

opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^..?$/;
open (OLDFILE, "< $file");
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile");
while ($line = <OLDFILE>)  {
($line) = ($line =~ /^s*(.*)s*n$/);
print NEWFILE "$linen";
}
close OLDFILE;
close NEWFILE;
}


-----Original Message-----
From: [Email Removed]
[mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 8:32 AM
To: [Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


are you speaking of this?

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

-----Original Message-----
From: LoneWolf [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:38 PM
To: [Email Removed]
Subject: Getting rid of white space...


I have about 12 files that I am pulling for a SCO box to a
RedHat box, FTP.
THe files from the SCO box are poorly formatted with
extraneous whitespace (sometimes as much as 30 or more)
before and after the text.  I need to parse all of the files
I DL and put them into a new file with "_nice" added at the end.

The files are all pipe-delimited, so I don't have a problem
separating the fields, I just am not sure how to make it
remove all extra whitespace.  It
needs to keep all Space in the fields "        the
description  of  the
file        " should still be readable as "the description
of the file"

Any help with code examples?  I have been looking through a
beginning book and my old code and have come up nil.

Thanks,
Robert

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



Bob Showalter
LoneWolf wrote:
QUOTE
I have about 12 files that I am pulling for a SCO box to a RedHat
box, FTP. THe files from the SCO box are poorly formatted with
extraneous whitespace (sometimes as much as 30 or more) before and
after the text. I need to parse all of the files I DL and put them
into a new file with "_nice" added at the end.

The files are all pipe-delimited, so I don't have a problem
separating the fields, I just am not sure how to make it remove all
extra whitespace.  It needs to keep all Space in the fields "
the description  of  the
file        " should still be readable as "the description of the
file"

It's a little unclear what you're asking for. You say you want to keep all
space in the fields, but your example compresses multiple spaces between
words into single spaces.

Anyway, assuming the following:

1. You have split the fields into an array, say @fields, and
2. You want to remove all leading and trailing whitespace, and
3. You want to compress multiple internal whitespace chars into a single
space

I would do:

s/^s+//, s/s+$//, s/ss+/ /g for @fields;

The first two regexes are the canonical way to remove leading and trailing
whitespace. The third compresses the internal whitespace.

QUOTE

Any help with code examples?  I have been looking through a beginning
book and my old code and have come up nil.


Alan Perry
On Thursday, September 04, 2003 11:11, Marshall, Stephen wrote:
QUOTE

Got it working this way fror the important line, but theres probably a
slicker way of doing it.

$line =~ s/(s)+/ /g;


This will work, but may leave an extraneous space at the beginning and/or
end of the line.

This text:

" Test text with lots of extra spaces "

would get changed to:

" Test text with lots of extra spaces "

which may not be what you want.

If you want to eliminate any starting or ending space and trim the rest of
it down to single spaces, I would suggest this:

$line =~ s/s+/ /g; # the parens you had are not necessary
$line =~ s/^ //; # removes any space from the beginning of the line
$line =~ s/ $//; # removes any space from the end of the line

You could probably get fancier on the statements, but I prefer the
simplicity of three separate statements.

HTH,

Alan

Dan Muey
QUOTE
How do you capture passed parameters in Perl on Windows? In
regular perl
its:
$variable = param('passed');

However, when I tried to run that under windows, it dies a
horrible death? I've looked through perl.org for more

What dies a horrible death, and how?
How are you running it? Via browser?
Deos the webserver know what to do with it?
What do the error logs say?
How did you pass it the value of 'passed'?
Did you put use CGI qw(param); in the script?

More details man! I don't theink the Mind::Read module is complete yet :p

QUOTE
information about converting over my unix scripts to windows,
any other good places out there for information?

Sincerely in Christ,
Mark-Nathaniel Weisman
President / Owner
Outland Domain Group Consulting
Anchorage / Washington DC / Bellevue
[Email Removed]



------------------------------------------------
On Thu, 04 Sep 2003 00:39:55 -0700, "rkl" <[Email Removed]> wrote:

QUOTE
Hi all:

Are these libs: WWW:: Mechanize and HTTP::Cookies in perl or mod_perl?


Written in or available in?

Written in: Perl
Available in: yes

They are standard Perl modules, so whereever you can use a Perl module they are available. They are written in Perl (with possibly XS components).

<snip old messages>

http://danconia.org

Anthony Akens
I figured I'd take a stab at fleshing this out into what he wants...
Any comments on things I could do better? I only added to what
Robert had coded...

Tony




#!/usr/bin/perl -w

use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;

opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^..?$/;
open (OLDFILE, "< $file");
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile");
while ($line = <OLDFILE>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print NEWFILE "$linen";
}
close OLDFILE;
close NEWFILE;
}


-----Original Message-----
From: [Email Removed] [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 8:32 AM
To: [Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


are you speaking of this?

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

-----Original Message-----
From: LoneWolf [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:38 PM
To: [Email Removed]
Subject: Getting rid of white space...


I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP.
THe files from the SCO box are poorly formatted with extraneous whitespace
(sometimes as much as 30 or more) before and after the text. I need to
parse all of the files I DL and put them into a new file with "_nice" added
at the end.

The files are all pipe-delimited, so I don't have a problem separating the
fields, I just am not sure how to make it remove all extra whitespace. It
needs to keep all Space in the fields " the description of the
file " should still be readable as "the description of the file"

Any help with code examples? I have been looking through a beginning book
and my old code and have come up nil.

Thanks,
Robert

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

Dan Muey
QUOTE
[Email Removed] wrote:
What's the simple Perl command to find the name of the file
from which
the Perl program is being executed?  It was recently on
this newsgroup
but I can't find the article now.

Do you mean the $0 variable?

You could also do:

use CGI qw(url);
my $self = url(relative=>1);

HTH

DMuey

QUOTE

Check out the FindBin module.

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



Brian Harnish
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 04 Sep 2003 06:37:57 -0700, LoneWolf wrote:

QUOTE
I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP.
THe files from the SCO box are poorly formatted with extraneous whitespace
(sometimes as much as 30 or more) before and after the text.  I need to
parse all of the files I DL and put them into a new file with "_nice" added
at the end.

The files are all pipe-delimited, so I don't have a problem separating the
fields, I just am not sure how to make it remove all extra whitespace.  It
needs to keep all Space in the fields "        the    description  of  the
file        " should still be readable as "the description of the file"

Any help with code examples?  I have been looking through a beginning book
and my old code and have come up nil.

- From your example it appears that you want to remove all whitespace from
the beginning, and end, and duplicates from inside. You can achieve this
easily:

my $text = ' the description of the file ';
for($text) {
s/^s+//;
s/s+$//;
# Perhaps its more effecient to put this next line first?
s/s+/ /g;
}

Also, check "perldoc -q space".

- Brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/V1ohiK/rA3tCpFYRAsGpAJ0XWKLjN9+7MYBnfeFz1g/DBWsqtgCg80v1
COz0Otn5XsqmO3D/ErXKkjQ=
=EgAZ
-----END PGP SIGNATURE-----

Anthony Akens
Try it like this... I was a slacker and didn't have warnings
in place if it couldn't open the file... Should be able
to just change the "/my/stuff/" to your directory and have it
work, I tested it here, and it seems to go fine. (on an aix
box - maybe I have something in place that doesn't work on
windows or other platforms?)

Tony

#!/usr/bin/perl -w

use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;

opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";

while (defined($file = readdir(DIR))) {
next if $file =~ /^..?$/;
open (OLDFILE, "< $file") or die "Can't open $file: $!";
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile") or die "Can't open $newfile: $!";
while ($line = <OLDFILE>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print NEWFILE "$linen";
}
close OLDFILE;
close NEWFILE;
}

-----Original Message-----
From: Marshall, Stephen [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 11:11 AM
To: Marshall, Stephen; Akens, Anthony; '[Email Removed]';
'[Email Removed]'; '[Email Removed]'
Subject: RE: Getting rid of white space...


Got it working this way fror the important line, but theres probably a slicker way of doing it.

$line =~ s/(s)+/ /g;

QUOTE
-----Original Message-----
From: Marshall, Stephen
Sent: 04 September 2003 17:07
To: 'Akens, Anthony'; [Email Removed];
[Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


I have a similar problem to this , does anyone have another
answer?  Don't know if its just me but The

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

Code doesn't work , and the enhanced version with the fancy
file handling doesn't work either "trying to read from a
closed filehandle error"

Stephen

-----Original Message-----
From: Akens, Anthony [mailto:[Email Removed]]
Sent: 04 September 2003 15:55
To: [Email Removed]; [Email Removed];
[Email Removed]
Subject: RE: Getting rid of white space...


I figured I'd take a stab at fleshing this out into what he
wants... Any comments on things I could do better?  I only
added to what Robert had coded...

Tony




#!/usr/bin/perl -w

use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;

opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^..?$/;
open (OLDFILE, "< $file");
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile");
while ($line = <OLDFILE>)  {
($line) = ($line =~ /^s*(.*)s*n$/);
print NEWFILE "$linen";
}
close OLDFILE;
close NEWFILE;
}


-----Original Message-----
From: [Email Removed]
[mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 8:32 AM
To: [Email Removed]; [Email Removed]
Subject: RE: Getting rid of white space...


are you speaking of this?

use strict;
while(my $line = <>) {
($line) = ($line =~ /^s*(.*)s*n$/);
print($line."_nice/n");
}

-----Original Message-----
From: LoneWolf [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 3:38 PM
To: [Email Removed]
Subject: Getting rid of white space...


I have about 12 files that I am pulling for a SCO box to a
RedHat box, FTP.
THe files from the SCO box are poorly formatted with
extraneous whitespace (sometimes as much as 30 or more)
before and after the text.  I need to parse all of the files
I DL and put them into a new file with "_nice" added at the end.

The files are all pipe-delimited, so I don't have a problem
separating the fields, I just am not sure how to make it
remove all extra whitespace.  It
needs to keep all Space in the fields "        the
description  of  the
file        " should still be readable as "the description
of the file"

Any help with code examples?  I have been looking through a
beginning book and my old code and have come up nil.

Thanks,
Robert

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



Tim Johnson
This is a very common mistake, so don't feel bad.

The "=" operator assigns the value on the right to the variable on the left.
The "==" operator checks two numeric values for comparison, returning true
if they match
The "eq" operator checks two string values for comparison, returning true if
they match

So you need to change your code to:

If(@ARGV[0] eq "-q"){
print "It workedn";
}else{
print "It did not workn";
}


-----Original Message-----
From: Thomas Browner [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 2:31 PM
To: [Email Removed]
Subject: help if than else statement


Can some one tell me way this does not work.



if (@ARGV[0] = "-q"){print "it workedn";}

else {print "it did not workn";}



if I use a -w instead of -q it still prints it worked.





Thomas Browner

Digidyne, Inc

Technical Engineer

(

Dan Muey
QUOTE
-----Original Message-----
From: Randal L. Schwartz [mailto:[Email Removed]]
Sent: Thursday, September 04, 2003 12:33 PM
To: [Email Removed]
Subject: Re: Test if browser's allows cookies/has them turned onetc..


"Dan" == Dan Muey <[Email Removed]> writes:

Dan> As much as I hate to do stuff that requires cookies, there is a
Dan> project I'm doing that requires cookies.

This should have been on [Email Removed] instead.
More experts there about this stuff.

Having said that, you should read my "basic cookie
management" column at
<http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.

I'm told that code was made into a module, but I can't seem to find that reference now.

Cool, that's pretty much the method I was using so I guess I'm not crazy!
I agree with your sentiments about cookies in the article. I try to avoid
them when ever possible but this one app will require them, either that or
I have to make sure the data is passed in every invokation of the script
via link or form which might just be worth the trouble. Except a user might
link to it from outside the script and then not have their info available
unless we attempt tossing our cookies.

Thanks for the info!

Dan

John W. Krahn
Lonewolf wrote:
QUOTE

I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP.
THe files from the SCO box are poorly formatted with extraneous whitespace
(sometimes as much as 30 or more) before and after the text.  I need to
parse all of the files I DL and put them into a new file with "_nice" added
at the end.

The files are all pipe-delimited, so I don't have a problem separating the
fields, I just am not sure how to make it remove all extra whitespace.  It
needs to keep all Space in the fields "        the    description  of  the
file        " should still be readable as "the description of the file"

Any help with code examples?  I have been looking through a beginning book
and my old code and have come up nil.

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

( $, $^I ) = ( $/, '.bak' );

while ( <> ) {
s/^s+//; # remove space at beginning of line
s/s+$//; # remove space at end of line
s/s*|s*/|/g; # remove space around pipe separator
print;
if ( eof ) {
close ARGV;
rename $ARGV, "${ARGV}_nice" or warn "Cannot rename $ARGV to ${ARGV}_nice: $!";
}
}

__END__



John
--
use Perl;
program
fulfillment

John W. Krahn
Antonio Jose wrote:
QUOTE

Hello.... I have 3 weeks learning Perl and I am trying to solve a trouble
I need to write my thesis....

I have to read a file where I don't know the content of the first rows
(only strings) and I need to read only data (numbers), I mean, I am going
to read information that begin with blank spaces and numbers, from there,
I have a matrix of 7 columns and n rows (I don't know the exact numbers
of rows), the column 1 correspond to depth and the next 6 columns
correspond to variables in each depth.

But there are cases where I have missing values, represented by -999.25,
in this cases I have to create a couple of columns; one of them
correponding to the variable without the missing value and teh other one
with the corresponding depth.

At the end, I will work with matrices of 2 columns (depth and variable),
called, for example, @rt (variable) and @prof_rt (depth). I write a
subroutine called "guardar" whose parameters are the vector of depth
without missing values, the vector of the variable without missing
values, the vector of the initial variable (with missing values), a
scalar ($p) that indicate the number of the column (variable) I am
working on and a scalar ($long) that indicate the length of the vector
depth without missing values (I could obviate the last two parameters but
I don't know how to do it). The objective of this subroutine is print in
other file columns already mencioned (prof_obj, variable, variable
without missing values) and other column (@intens) obtained by a
processing done in other sub explained down. This process is executed for
each value of prof_obj and this is included in a loop for.

On the other hand, the subroutine "suavizar" do the calculus of @intens;
it takes each value of prof_obj inserted in the sub "guardar" and compare
it with prof_val (depth related to a variable without missing values)
divided by a constant $b, all this is accumulated in $denominador,
previously executed the subroutine "kernel" (explained down), all this is
realized for each element of prof_val (called $long and inserted as
parameter). In the same way a calculus will be accumulated in $numerador
where the value of the sub "kernel" is multiplied by the value of the
variable without missing value. At the end I will obtain a quotient.

In addition to, the subroutine "kernel" only do a simple mathematical
calculus and gives a number to "suavizar".

I think I have troubles to read $long or parameters from other sub's,
there is a ilegal division of numerador/denomimador because there aren't
something assigned to them.

I have checked some web pages and it's difficult to find examples like
this where there is manipulations of matrices or sub's inside others sub's.

I attach the script if you would like to read and correct. Sorry for my
english and thanks a lot!!

#!/fs/pkgs/share/perl/bin/perl -w

You should enable strict as well

use strict;


QUOTE
for ($i=1; $i<=7; ++$i) # y en caso de ser mas o menos columnas, hay que estar sustituyendo aca ????????????
{
$j[$i] = 0; $j1[$i] = 0;
}

You do realize that arrays in perl start at zero and not one?

my @j = my @j1 = ( undef, (0) x 7 );


QUOTE
while (<LAS>)  # Lectura de todas las lineas
{
$linea = $_;
if ($linea=~ /^s*[1-9]/)
{
@tmp = split (/s+/, $linea);  # Recorta la linea en el # de columnas existentes

Why copy $_ to $linea? Do you not consider 0 would be valid in this
situation? You are basing your usage of @j, @j1 and @tmp on the fact
that split( /s+/ ) assigns an empty string to the first element of @tmp
however if you use the correct form of split this wouldn't happen. Also
it looks like you need to test for negative numbers as well.

while ( my $linea = <LAS> ) # Lectura de todas las lineas
{
if ( $linea =~ /^s*-?[1-9]/ )
{
my @tmp = split ' ', $linea; # Recorta la linea en el # de
columnas existentes

Or without $linea:

while ( <LAS> ) # Lectura de todas las lineas
{
if ( /^s*-?[1-9]/ )
{
my @tmp = split; # Recorta la linea en el # de columnas
existentes

Or without the large if block:

while ( <LAS> ) # Lectura de todas las lineas
{
next unless /^s*-?[1-9]/;

my @tmp = split; # Recorta la linea en el # de columnas existentes


QUOTE
print ("Introduzca el ancho de banda (b): ");
$b = <STDIN>;
chop ($b);

You should use chomp instead of chop.


QUOTE
if ($b > 0)
{
printf (SAL "      Prof Obj        Intensidad RTn");
guardar(@prof_rt, @rt, @rt1, 2, $long_rt);
printf (SAL "      Prof Obj        Intensidad VCLn");
...

You should be using print instead of printf.


QUOTE
sub suavizar # el ($$@@) es opcional
{
#$prof_obj    = $_[0];
#$b          = $_[1];
#@$prof_val  = $_[2];
#@$valor      = $_[3];
#$long        = $_[4];
#($prof_obj, $b, @$prof_val, @$valor, $long) = (shift, shift, shift, shift); # Es equivalente a lo de arriba
($prof_obj, $b, @$prof_val, @$valor, $long) = @_; #se puede sustituir por la linea arriba

When you assign a list to an array, the array will be assigned the whole
list. If you have any variables after the array they will not be
assigned any data.

$prof_obj will be assigned the value of $_[0]
$b will be assigned the value of $_[1]
@$prof_val will be assigned the rest of the values in @_
@$valor will not be assigned anything
$long will not be assigned anything

perldoc perlsub


QUOTE
local ($u, $j2, $denominador, $numerador);

You should use my instead of local.



John
--
use Perl;
program
fulfillment

Randal L. Schwartz
QUOTE
"Tim" == Tim Johnson <[Email Removed]> writes:

Tim> So you need to change your code to:

Tim> If(@ARGV[0] eq "-q"){
Tim> print "It workedn";
Tim> }else{
Tim> print "It did not workn";
Tim> }

And you really need to change @ARGV[0] to $ARGV[0], or else
the "don't use an array slice when an element will do" police
will be after you.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +
<[Email Removed]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

David Wall
--On Thursday, September 04, 2003 9:48 AM +0100 Nigel Peck - MIS Web Design
<[Email Removed]> wrote:

QUOTE
Thanks, I found that but I'm looking for a Perl solution, should be
possible with a one liner regex substitution AFAIK.

Doesn't IIS document its log file format somewhere? I know Apache does:
http://httpd.apache.org/docs-2.0/mod/mod_log_config.html
(or the equivalent on the docs that Apache installs by default)

R. Joseph Newton
Paul Archer wrote:

QUOTE
4:09pm, Ramprasad A Padmanabhan wrote:

And the problem is not simply a puzzle, nor is it homework. If you had read
my post more carefully, you would see that I am 1) *teaching* the class, and
2) want to be able to show off one concept (the range operator) before we
have talked about another concept (the 'reverse' statement).

Even more reason, if you are in the position of a teacher, not to use the range
operator for this purpose. It is simply inappropriate. Unless there is only a
certain subset of elements in the array for which you want to do magic, the foreach
(@array_name) format communicates intent much more clearly.

I'm a little surprised that no one has yet posted what seems to me the most direct
and transparent soltion: [note the sample does make use of the range operator in a
more appropriate context]

Greetings! E:d_driveperlStuff>perl -w
my @keeper = (1..15);
{
my @temp;
push @temp, pop @keeper while @keeper;
@keeper = @temp;
}
print "$_ " for @keeper;
^Z
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

I like the above because:

1. It is transparent. You can "see" the data being moved.
2. It is process efficient. Each element is moved only once, and an array name is
redirected. It does what it takes--no more and no less.
3. It minimizes memory demands painlessly. The original storage for @keeper is
returned to the store when it is re-assigned, and @temp disappears entirely outside
the {...} closure, leaving @keeper pointing to the reversed array.

Hmmm...

On second thought, I'm not sure about process efficiency here, Perl may re-copy the
whole array in the assignment. In which case, the more efficient and elegant
solution would use references:

Greetings! E:d_driveperlStuff>perl -w
my $keeper = [1..15];
{
my $temp = []; # " = []" Not strictly neccesary. The first push() would
autovivify @$temp
push @$temp, pop @$keeper while @$keeper;
$keeper = $temp;
}
print "$_ " for @$keeper;
print "n";
^Z
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

As a side exercise, you might have your students add the implicit parens.

Joseph

Shishir Saxena
Well since you've asked for it how about doing this,

I want to make a cross-platform utility that when provided with the location
of a directory structure generates the following log,

1) Date of creation
2) Size on Disk
3) Build number of the component / executable.
4) Copyright info (if included in the resource file)


So what do you think ?

-----Original Message-----
From: Ged [mailto:[Email Removed]]
Sent: Friday, September 05, 2003 3:59 PM
To: [Email Removed]
Subject: perl questions / exercices


Hi all,

I am currently learning perl reading all the material I can get my hands on,
but have no use for it on a daily basis.

Because of this I am not getting the practice I need on a day-to-day basis
to gain more knowledge.

Having covered all the questions in books like 'Learning Perl' etc I need
more exercises, if not small projects to further my skills.

Its not easy to think up usefull projects, so my question is, does anybody
know of anything on the net to challenge me

Thanks,

Ged.

(p.s. I am still in the early stages so long complicated projects are still
a little out of my reach at the moment.)

-----------------------------------------
Email provided by http://www.ntlhome.com/



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

Paul Johnson
Gary Stainburn said:
QUOTE
Hi folks,

I've got a problem I hope you can help me with.

I've got to tidy some data, including converting case.  I need to convert

ANOTHER COMPANY NAME LTD      **

to

Another Company Name Ltd      **

while retaining spaces.

I've tried using split / join / lc / ucfirst which does most of the work
but
loses the spacings.

I guess that there's a regex that will do this but I'm at a loss how.

s/(w+)/uL$1/g

or

s/(w+)/ucfirst lc $1/eg

--
Paul Johnson - [Email Removed]
http://www.pjcj.net

Marcos Rebelo
delete($hash{key})

-----Original Message-----
From: Paul Kraus [mailto:[Email Removed]]
Sent: Friday, September 05, 2003 3:29 PM
To: [Email Removed]
Subject: Undef hash


How can I kill a hash? I don't want to kill the entire hash just one
element.

$hash{key}=value <- I just want to remove this one not all of %hash.

Paul Kraus


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

Paul Johnson
Jenda Krynicky said:
QUOTE
From: Gary Stainburn <[Email Removed]
I've got to tidy some data, including converting case.  I need to
convert

ANOTHER COMPANY NAME LTD      **

to

Another Company Name Ltd      **

while retaining spaces.

$text =~ s/(w+)/Lu$1/g;$y

Lu -- isn't perl clever?

--
Paul Johnson - [Email Removed]
http://www.pjcj.net

Jenda Krynicky
From: Ramprasad A Padmanabhan <[Email Removed]>
QUOTE
Suppose I have a huge array of filenames and I want to move them I
would like to  move 1 chunk at a time on 'n' elements

How Can I efficiently do it ?

something like

@allfiles  = (....)  # 10000 files
@smallchunks = split_to_chunks(@allfiles,100);
#  This function is what I want to write

foreach (@smallchunks) {
my $filelist = join(" ",@{$_});
....
.....
}

my $chunk_size = 100;
for( my $i = 0; $i * $chunk_size <= $#allfiles; $i++) {
my $filelist = join( " ", @allfiles[$i*$chunk_size ..
(($i+1)*$chunk_size - 1)]);
...
}

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Sorry, lack of sleep.. but isn't File::Basename usally installed in the
standard Perl install?

Denis

On Fri, 5 Sep 2003 [Email Removed] wrote:

QUOTE
On Thu, 4 Sep 2003 [Email Removed] wrote:

basename is more convenient i think. What do you say?

Only if you can load the module on the system. running into issues here at
work where I can load modules (security llama's)

Denis


Quoting [Email Removed]:

On Mon, 1 Sep 2003 [Email Removed] wrote:

What is the function of cutting a string from a point until the last
character?

For example
$string="C:/progra~1/directory1/directory2/file.txt";

i want to find the last backslash (/) of the string and keep the sequence
following it (file.txt)

Is it simple?

I tried with the split function but it returns a list.

I just want a scalar!





why not try this?

#!/usr/bin/perl
my @test='';
my $test1='';
my $string = "C:/test/me";
@test = split('/',$string);
print "@testn";
print "$test[$#test]n";

HTH.. Denis


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]









Ged
Sounds interesting. I'll give it a whirl.

Hope you won't be waiting for me to code it though as it might take me a while to get it running smoothly, esspeically with it being cross platform.

QUOTE

From: Shishir Saxena <[Email Removed]
Date: 2003/09/05 Fri AM 10:33:56 GMT
To: Ged <[Email Removed]>,  [Email Removed]
Subject: RE: perl questions / exercices

Well since you've asked for it how about doing this,

I want to make a cross-platform utility that when provided with the location
of a directory structure generates the following log,

1) Date of creation
2) Size on Disk
3) Build number of the component / executable.
4) Copyright info (if included in the resource file)


So what do you think ?

-----Original Message-----
From: Ged [mailto:[Email Removed]]
Sent: Friday, September 05, 2003 3:59 PM
To: [Email Removed]
Subject: perl questions / exercices


Hi all,

I am currently learning perl reading all the material I can get my hands on,
but have no use for it on a daily basis.

Because of this I am not getting the practice I need on a day-to-day basis
to gain more knowledge.

Having covered all the questions in books like 'Learning Perl' etc I need
more exercises, if not small projects to further my skills.

Its not easy to think up usefull projects, so my question is, does anybody
know of anything on the net to challenge me

Thanks,

Ged.

(p.s. I am still in the early stages so long complicated projects are still
a little out of my reach at the moment.)

-----------------------------------------
Email provided by http://www.ntlhome.com/



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]



-----------------------------------------
Email provided by http://www.ntlhome.com/

James Edward Gray II
On Friday, September 5, 2003, at 08:14 AM, Gary Stainburn wrote:

QUOTE
Hi folks,

I've got a problem I hope you can help me with.

I've got to tidy some data, including converting case.  I need to
convert

ANOTHER COMPANY NAME LTD      **

to

Another Company Name Ltd      **

while retaining spaces.

I've tried using split / join / lc / ucfirst which does most of the
work but
loses the spacings.

That's how I would do it. Just put parenthesis around your split
pattern and it will return the spaces in its list. It won't hurt to
change the case of spaces and when you re-join them it'll be just like
it was. You can handle that without me typing out the line, right? ;)

James

Gary Stainburn
On Friday 05 Sep 2003 2:25 pm, Jenda Krynicky wrote:
QUOTE
From: Gary Stainburn <[Email Removed]

I've got to tidy some data, including converting case.  I need to
convert

ANOTHER COMPANY NAME LTD      **

to

Another Company Name Ltd      **

while retaining spaces.

$text =~ s/(w+)/Lu$1/g;$y

Thanks Jenda,

BTW, I did get the split/join verysion working - don't know what I'd done
wrong.

Which method would be quickest?

Eventually, I'll be using this to convert/tidy three years work of customer
details, which I'm guessing will be extensive.

QUOTE

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

Randal L. Schwartz
QUOTE
"Shishir" == Shishir Saxena <[Email Removed]> writes:

Shishir> I want to make a cross-platform utility that when provided
Shishir> with the location of a directory structure generates the
Shishir> following log,

Shishir> 1) Date of creation

Not possible in Unix.


--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +
<[Email Removed]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.