Sign in to follow this  
Followers 0
jimmyjmmy

translate perl to autoit

6 posts in this topic

Hi,

Can someone help me to translate this perl script to autoit.

Thanks

;;;;;;;;;;;;;;script################

open (FILE,'<',"c:\\perl\\id_and_pass.txt") || die "No files found $!\n";

while (<FILE>){

chomp;

($userid, $password) = split /\t/,$_;

}

Share this post


Link to post
Share on other sites



I don't know what the perl function chomp does so this is all I can help you with.

$file = FileOpen("C:\Perl\id_and_pass.txt")
For $i = 1 To FileCountLines($file)
$line = FileReadLine($file,$i)
$user_pass = StringSplit($line,"\t,_") & @CRLF;could be wrong since I don't know perl
Next

Share this post


Link to post
Share on other sites

chomp removes carriage control (as defined by $/ in Perl) from the end of line... you can probably use StringStripCR in AutoIt

$_ represents a line read from the file... in the example above, this would be $line

\t is represented in AutoIt as @tab

so, use the above, but use

$aUser_pass = StringSplit(StringStripCR($line), @tab)

and note that $aUser_pass will be an array with element 0 telling you the number of substrings in the array.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

Can someone help me to translate this perl script to autoit.

Thanks

;;;;;;;;;;;;;;script################

open (FILE,'<',"c:\\perl\\id_and_pass.txt") || die "No files found $!\n";

while (<FILE>){

chomp;

($userid, $password) = split /\t/,$_;

}

Taking a shot at it (with more error checking than the original):
#cs
    open (FILE,'<',"c:\\perl\\id_and_pass.txt") || die "No files found $!\n";
    while (<FILE>){
    chomp;
    ($userid, $password) = split /\t/,$_;
    }
#ce

$hFile = FileOpen("c:\perl\id_and_pass.txt", 0); 0 = read mode
If $hFile = -1 Then
    MsgBox(16, "Error!", "No files found!")
    Exit
Else
    While 1
        $sLine = StringStripWS(FileReadLine($hFile), 2); 2 = strip trailing whitespace
        If @error Then ExitLoop
        $avSplit = StringSplit($sLine, @TAB)
        If $avSplit[0] >= 2 Then 
            MsgBox(64, "Results", "userid = " & $avSplit[1] & @CRLF & "password = " & $avSplit[2])
        Else
            MsgBox(16, "Error!", "Malformed line read:  " & $sLine)
        EndIf
    WEnd
EndIf

FileClose($hFile)

>_<

Bah! Beaten to it! Who let the monkey in here...? :)

Edit: Added FileClose()

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Bah! Beaten to it! Who let the monkey in here...? :)

I may have gotten there first, but you still added value - as usual! >_<

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I may have gotten there first, but you still added value - as usual! >_<

Dale

Bah! Beaten to it! Who let the monkey very perceptive, intelligent, and good looking gorilla in here...? :)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0