KevinADC 192 Practically a Posting Shark

Look into using the WWW::Mechanize module.

KevinADC 192 Practically a Posting Shark

this should be in the shell scripting forum:

http://www.daniweb.com/techtalkforums/forum113.html

KevinADC 192 Practically a Posting Shark

already resolved on another forum.

KevinADC 192 Practically a Posting Shark

look into the Win32 family of modules for doing things in windows with perl.

probably Win32::Process

KevinADC 192 Practically a Posting Shark

download perl and all the documentation comes with it. Just about everything on perldoc should be or is included with perl. Then you can read all that stuff on your local computer without having to be online.

KevinADC 192 Practically a Posting Shark

You're welcome.

KevinADC 192 Practically a Posting Shark

http://learn.perl.org/library/beginning_perl/

search google for more perl tutorials and references on the internet

KevinADC 192 Practically a Posting Shark

i know, i tried to use both ftpvoyager and smartftp but both saids it couldnt do it, so i contacted support and they said they didnt support it, which suggests other hosts do.

Ahh... I misunderstood you. You might have been able to change permissions using a script, but the host probably doesn't want you messing around with file permissions and might not appreciate if you did. You can often do things using a script that the host doesn't want you to be able to do, but if you get caught they might delete your account and not return any money you paid them.

KevinADC 192 Practically a Posting Shark

no host supports chmoding files externally. You have to connect to the server somehow: telnet/shell, FTP, another script, to change permission of files on a server.

KevinADC 192 Practically a Posting Shark
my @data = ();
    my @values = ();
    while(<FILE>){
        my $data = do {local $/; <FILE>};
        @data = split(/\|\|\|/,$data);
 
    }
     
    for (@data) {
       @values = split(/\|\|/);
       #do something with @values
    }
KevinADC 192 Practically a Posting Shark

if the file isn't too big this might do what you want:

open(FH,'file.txt');
my $data = do {local $/; <FH>};
my @data = split(/\|\|\|/,$data);
print "$_\n" for @data;
KevinADC 192 Practically a Posting Shark

Hello everyone. I've run into a problem with regular expressions; the extraction "variables" ($1, $2, $3 etc.) are read only and scoped to the current block. If you need to do two regex extraction operations in the same block, is there a way to reset the ($1, $2, $3 etc.) so they can be reused? Any help appriciated.

Steven.

It sounds like maybe you are using a loop to process more then one line of data in the block. Post the block of code in question.

KevinADC 192 Practically a Posting Shark

you're using the wrong brackets on your hash keys, you use {} not ()

sub test_function {
my($key, %table);
%table = ('word1', 'Perl', 'word2', 'is', 'word3', 'great');
$key = "word3";
print $table{'word1'};
print $table{"word2"};
print $table{$key};
}

not sure what tutorials you have read but if they are telling you to use () instead of {} for hash key look ups they are wrong.

KevinADC 192 Practically a Posting Shark

look intot these operators/functions and decide which is best for your purposes:

system - runs a program but doesn't return program output to the perl script. Returns exit status, if any, of run program instead.

exec - runs a program but exits the perl program as soon as it's called

`` (backtiks) - runs a program and returns program output back to the perl script

qx// - same as backtiks

KevinADC 192 Practically a Posting Shark

You must be fairly new to internet/cgi programming because it seems like you know about programming in general pretty well.

KevinADC 192 Practically a Posting Shark

I'm no accomplished hacker but from what I gather htaccess files are not hard to get passed using scripts/programs to fake http request headers. If you have data you want to protect the best place is above the www root. Your script should still be able to get to any data stored in folders above the www root folder but hackers can't unless they actually hack into your web site account. In which case your dead anyway.

KevinADC 192 Practically a Posting Shark

Each browser is free to interpret and do what it wants with the staus line of an http response header. In my experience, Mozilla 1.5 pretty much ignores them. IE 6 prints a generic error page.

Try this script:

my $q = CGI->new;
print $q->header(-status=>'404',-type=>'text/html'),
      $q->start_html(-title=>'404 Page Not Found'),
		'<hi>500 Internal Server Error. The webmaster is an idiot!</h1>';

Mozilla 1.5 totally ignores the status and prints out what you see above quite literally. IE6 reads the status and prints an error page.

KevinADC 192 Practically a Posting Shark

The status code should be the first line of all http response headers. You must also include a content-type line in the header. If you are using the CGI module you can use the cgi_error method to get any errors the script reports and inlcude them in headers. See the CGI documentation. See also:

http://tools.ietf.org/html/rfc2616#section-6.1

KevinADC 192 Practically a Posting Shark

Not sure where you got that regexp from but it's either a typographical error or just wrong. The first '. When it's inside the character class it means to not match what's in the character class (a negated character class). Maybe it was supposed to be:

/^[^TMC]ow/

in which case it means to match a string that begins with any character followed by 'ow' but not if the character is T or M or C:

my @strings = ('Cows say moo', 'I Mow the grass', 'Tow the line', 'Bow tie', 'Pow wow', '9ow begins with a digit', ' ow begins with a space');

for (@strings) {
   /^[^TMC]ow/ && print "$_\n";
}

prints:

Bow tie
Pow wow
9ow begins with a digit
 ow begins with a space
KevinADC 192 Practically a Posting Shark

iblair,

Are you sure you need to use the -h option? All it does is list the valid options. What is it you are trying to do?

KevinADC 192 Practically a Posting Shark

EDIT: Infact, if you installed ActivePerl properly, it should have appended itself to path automatically.

:)

KevinADC 192 Practically a Posting Shark

with windows 98, open a DOS window (MS-DOS prompt) and cd\ if necessary to get out of the windows directory.

Then type in:

c:\perl\bin\perl.exe name_of_script.pl

or if perl is in the command path:

perl name_of_script.pl

and press the enter key. The script will run and the output will remain on the screen. If it goes beyond one page of output you might be better writing the output to a file.

KevinADC 192 Practically a Posting Shark

I didn't get the impression it was homework/schoolwork but I have no idea how to answer such a question:

what are all the scenarios under which perl is used for software testing

I don't even know what "testing software" means? Testing it for what?

KevinADC 192 Practically a Posting Shark

parsing user input for all possible syntax variations is an excersize in frustration as Matts code above shows. If you want to simply find "pi=3.14" a turn it into 3.14:

s/pi=3\.14/3.14/g;

or if 'pie=3.14' is a possibility too:

s/pie?=3\.14/3.14/g;

and last, if case sensitive matching is not wanted:

s/pie?=3\.14/3.14/ig;
KevinADC 192 Practically a Posting Shark

some of perls native functions are also meant for Unix, such as flock() and chmod() and some functions might return a different value depending on the operating system, like stat().

KevinADC 192 Practically a Posting Shark

if you want real scalability and flexibility the XML files sounds like a good (but a bit complicated) way to go, otherwise, what you are trying to do is easily acomplished using a delimited flat file system.

KevinADC 192 Practically a Posting Shark

.... so if this script is implemented well enough it will out perform all existing forum software solutions.

Steven.

I admire your ambition. Maybe if you post some sample data and what you want to do with that data it will help to clarify your original question. If not, you may want to look into syswrite() or sysseek() and etc.

KevinADC 192 Practically a Posting Shark

It sounds to me like you are trying to do something the hard way. Why would you need to write some new data over old data instead of using a delimited flat file or a real database?

KevinADC 192 Practically a Posting Shark

I've never used perl2exe but others have and reported good results:

http://www.indigostar.com/perl2exe.htm

KevinADC 192 Practically a Posting Shark

You know you're getting then when you can answer your own questions! :)

KevinADC 192 Practically a Posting Shark

whats the value of $timeout?

unless($scp->expect($timeout,-re=>'[Pp]assword.*?:|[Pp]assphrase.*?:')){

KevinADC 192 Practically a Posting Shark
open (PERF, "Perf.txt") or die "can't open perf.txt: $!";
open (DSA, "Neu.txt") or die "Can't open neu.txt: $!";

chomp(@Perf = <PERF>);
chomp(@Neu = <DSA>);
my %seen; # lookup table

# build lookup table
@seen{[B]@Neu[/B]} = ();

foreach $item ([B]@Perf[/B])
{
# print ($item) unless exists $seen{$item};
push (@miss, $item) unless exists $seen{$item};
}

foreach(@miss)
{
print "\nElement found ---> $_";
}
KevinADC 192 Practically a Posting Shark

Sorry, but your question is out of my range of knowledge and experience. A question of this nature might be best asked on the perlmonks website.

KevinADC 192 Practically a Posting Shark

That's good; thanks for that, it works as I'd expect it to.

However, going back to my example...

If this:

my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;
push(@DREF_A,"hippos");

Is changed to this:

my(@DREF_A) = @$REF_A;
push(@DREF_A,"hippos");
my(@DREF_B) = @$REF_B;

Shouldn't that change the contents of @DREF_B? (The data should now be copied after the array is changed) It doesn't though, I've just checked it (same output as before)

No. @DREF_A and @DREF_B are copies of whatever reference you dereferenced at that point. They are entirely seperate from the original data at that point.

Also, the @DREF_B output doesn't match the @DREF_A output even if both @DREF_A and @DREF_B are sourced from the same pointer, as in:

my(@DREF_A) = @$REF_A;
push(@DREF_A,"hippos");
my(@DREF_B) = @$REF_A;

Same reason. @DREF_A has no connection to $REF_A anymore. @DREF_B will have the value of $REF_A. You did not make any changes to $REF_A, you made a copy of it and changed the value of the copy (@DREF_A)'

Although it does work as per your example:

push(@$REF_A,"hippos");
my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;

Seems strange though! Shouldn't @$REF_A evaluate to the same thing whether its a subroutine parameter or a variable assignment?

In the above you changed the value of the original data that $REF_A points to. Then you make two new copies which will both have the same value because $REF_A and $REF_B are pointers to the same data.

:)

MattEvans commented: Good comments & valuable insight; thanks! +1
KevinADC 192 Practically a Posting Shark

you should be able to do something like this:

my $self = {};
my @array = qw(Mary had a little);
$self->{arrayref} = \@array;
push @{$self->{arrayref}},'lamb';#append new element  to array
print join(' ',@{$self->{arrayref}});
print "\n";
$self->{arrayref}->[0] = 'Joe';#change index 0 of array
print join(' ',@{$self->{arrayref}});
KevinADC 192 Practically a Posting Shark

you don't need to make a copy of the array referenced by a reference to use it. But you need to make a copy if you don't want the original variable the reference points to to be affected.

I'd like to know why $REF_DREF_A != $REF_DREF_B

because they are references to two different arrays:

my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;

my($REF_DREF_A) = \@DREF_A;
my($REF_DREF_B) = \@DREF_B;

@DREF_A and @DREF_B are two seperate variables even though they are two copies of the same data. So $REF_DREF_A and $REF_DREF_B are pointer to two seperate bits of data.

KevinADC 192 Practically a Posting Shark

might have something to do with the fact you run the script from the 'e' drive but the perl install is on the 'c' drive? Can you run other scripts on the 'e' drive no problem?

KevinADC 192 Practically a Posting Shark

There are a few ways to get the date/time with perl:

http://perldoc.perl.org/functions/gmtime.html

http://perldoc.perl.org/functions/localtime.html

http://perldoc.perl.org/functions/time.html

or you can use backtiks to get the date from the system date function, something like:

my $date = `/bin/date +"%a, %b %d, %Y"`;
Mushy-pea commented: Good advice, just the job. +1
KevinADC 192 Practically a Posting Shark

has to be like installed like this:

perl\site\lib\Term\Readkey.pm

KevinADC 192 Practically a Posting Shark

perl will drop leading zeros in numbers, but you can stringify numbers to retain the leading zeros or use sprintf() or printf() to pad numbers with leading zeros.

perl will almost always know when to treat digitis as numbers or strings.

my $var = '01';
my $var2 = '03';
print $var + $var2;

prints: 4

my $var = '01';
my $var2 = '03';
print $var . $var2;

prints: 0103

KevinADC 192 Practically a Posting Shark

I don't understand what that sub routine does or what you are asking. Please explain your question some more.

KevinADC 192 Practically a Posting Shark

comment removed, irrelevant.

KevinADC 192 Practically a Posting Shark

I don't know how to do that in perl or why you would even need to do it but I assume you know why and have a legitimate reason. Maybe someone else will know.

KevinADC 192 Practically a Posting Shark

variables always change when you redefine them or use operators or functions on them. Not sure what your question is.

KevinADC 192 Practically a Posting Shark
$datos .= qq~<a href="$me?C=OFERTAS2&EMPRESA=$empresa_param&NREF=$nref" onMouseOver="linkFTecnica(nref2)">~;
sut commented: what can i say? superior solution ;) +1
KevinADC 192 Practically a Posting Shark

I think I need to do something to make the new tty the controlling terminal for the forked process but cannot find out what it is I need to do.

I personally have no idea how to do that. If you get no answers here you may want to post on www.perlmonks.com

KevinADC 192 Practically a Posting Shark

I suppose what i want to do is:

- user clicks login button
- script executes silently
- page refreshes
- user is logged in

Since that is not normal CGI behavior I would suggest against it. Most people expect whan they click a form button something will happen pretty much right away. If it doesn't they will probably click the button again or hit refresh, which might defeat the purpose of what you intend. You may have good reason for what you want to do, but using a CGI form might not be the best way to go about it.

KevinADC 192 Practically a Posting Shark

rumour has it that there is nothing perl can't do ;)

True, but the original question is:

How to convert excel to html in shell prompt
Is there any unix command to do this ? so that I can use that in excel


They specifically are asking for shell/Unix commands so they asked in the wrong forum. :)

KevinADC 192 Practically a Posting Shark

When I was learning the basics of Perl CGI (well, any CGI) I vaugely remember something regarding a header or command that would invoke CGI script (using a standard GET request) WITHOUT changing the page that a user was on.

I think you might be refering to non-parsed header scripts. I am not familiar with writing them or using them but you can probably do a google search for no-parsed header and see if you find anything useful. I know the CGI module does support NPH scripts so you mihgt want to look up the CGI documentation as well.

KevinADC 192 Practically a Posting Shark

they really do the same thing but in a differnt way. Either way will work. My way showed why the code you had was not working, but going with 'require' and replacing '::' with '/' and .pm with .pl is fine.