Sponsored Content
Top Forums Shell Programming and Scripting Beginner Need Help on perl input Post 302555333 by guidely on Wednesday 14th of September 2011 12:31:45 PM
Old 09-14-2011
Beginner Need Help on perl input

Hi, I am beginner perl input I just want to know if I want to make a program that let user input a function such as input " < value " List all files that are less than value The current directory is used. eg input " < 5" list all file that less than 5 in current directory until user input "quit"

how can I get sperate value from < in user input

so here my code for user input two sperate input in once line

Code:
#!/usr/bin/perl -w

print " Welcome to advance search function";

$func = "";

while (( $func ne "quit\n" ) && ( $func2 = "exit\n" ))
{
    print " Enter advance search function :";
    $func = <STDIN>; $func2 = <STDIN>;
    
    
}
print " return to main menu \n";

Thank

Last edited by pludi; 09-14-2011 at 07:36 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting input from perl

Hi, i have just tried something in perl #!/path/to/perl print "login: "; $login = <STDIN>; print "\npassword: "; $password = <STDIN>; print "Username=$login\n"; print "Password=$password\n"; And it doesnt work, anyone know how i can get more than one line? Cheers, Elfyn (2 Replies)
Discussion started by: emcb
2 Replies

2. Shell Programming and Scripting

[Perl] Silent Input

I would like to use the WWW::Mechanize module to access a webpage that is password-protected. I was wondering if there was a way to make the input silent when asked from the script. For example: What is your password: <password> Where <password> is where you put your password, but is silent... (2 Replies)
Discussion started by: eightysix
2 Replies

3. Shell Programming and Scripting

Beginner for Perl

Hi, I'm new in Perl. Can anyone recommend me any e-book which is good for beginners? Thanks. (3 Replies)
Discussion started by: raul15791
3 Replies

4. UNIX for Dummies Questions & Answers

(Beginner) Run c++ .exe with input to file

Hi, I've got this requirement for my homework assignment, but I'm not sure how to meet it: In the comamnd line, I need to type $ <exec-file> <input> <output_file_name> Like: test 1+2 out.txt Which should execute test.exe passing in 1+2 and directing output to out.txt. I know how... (1 Reply)
Discussion started by: JustinT
1 Replies

5. Shell Programming and Scripting

Perl - pass shell-vars into perl for input loop

I need to process a file line-by-line using some value from a shell variable Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.) I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies

6. Shell Programming and Scripting

Beginner Perl help Please

Hi I am trying to generate random names using perl script. First let me post my code #!/usr/bin/perl my $name; my @charset = (('A'..'Z'), ('a'..'z')); my $range = $#charset + 1; print "Enter the limit\n"; $lim = <STDIN>; until ($lim == 0){ for (1..8) { $name .=... (2 Replies)
Discussion started by: srijith
2 Replies

7. Shell Programming and Scripting

User input - Perl need Help

If I want all user input to start with " : " if not display error or what I asking is how to do if statement that control a first letter of string that we want to start with. and not worry about the rest Thank (1 Reply)
Discussion started by: guidely
1 Replies

8. Shell Programming and Scripting

user input in perl?

Please tell me how to write a perl script that asks the user to enter words and that passes them to a variable. In bash, the "read" command would achieve such user interaction. #!/bin/bash read -p "Enter files: " vFiles However, I am looking for perl version of something equivalent... (2 Replies)
Discussion started by: LessNux
2 Replies

9. Shell Programming and Scripting

silent Input in PERL

Hello Experts, I am learning perl. I know ksh/bash/csh... In ksh I use to do this way... to read user input in silent mode so that nothing returns on the screen. stty -echo read -r pswd stty echo Please let me know the way in perl how to do it. Here are my OS and Perl Details... ... (3 Replies)
Discussion started by: explorer007
3 Replies

10. Shell Programming and Scripting

Need help in parsing an input in perl

I am executing a command it is returning me something like this name ip port ------------------------------------ http-listener-1 * 6712 http-listener-2 * 8709 I have a subroutine getListenerName($porttobeChecked) This subroutine returns me the name of the listener if i pass a... (4 Replies)
Discussion started by: javaholics
4 Replies
ReadPassword(3pm)					User Contributed Perl Documentation					 ReadPassword(3pm)

NAME
Term::ReadPassword - Asking the user for a password SYNOPSIS
use Term::ReadPassword; while(1) { my $password = read_password('password: '); redo unless defined $password; if ($password eq 'flubber') { print "Access granted. "; last; } else { print "Access denied. "; redo; } } DESCRIPTION
This module lets you ask the user for a password in the traditional way, from the keyboard, without echoing. This is not intended for use over the web; user authentication over the web is another matter entirely. Also, this module should generally be used in conjunction with Perl's crypt() function, sold separately. The read_password function prompts for input, reads a line of text from the keyboard, then returns that line to the caller. The line of text doesn't include the newline character, so there's no need to use chomp. While the user is entering the text, a few special characters are processed. The character delete (or the character backspace) will back up one character, removing the last character in the input buffer (if any). The character CR (or the character LF) will signal the end of input, causing the accumulated input buffer to be returned. Control-U will empty the input buffer. And, optionally, the character Control-C may be used to terminate the input operation. (See details below.) All other characters, even ones which would normally have special pur- poses, will be added to the input buffer. It is not recommended, though, that you use the as-yet-unspecified control characters in your passwords, as those characters may become meaningful in a future version of this module. Applications which allow the user to set their own passwords may wish to enforce this rule, perhaps with code something like this: { # Naked block for scoping and redo my $new_pw = read_password("Enter your new password: "); if ($new_pw =~ /([^x20-x7E])/) { my $bad = unpack "H*", $1; print "Your password may not contain the "; print "character with hex code $bad. "; redo; } elsif (length($new_pw) < 5) { print "Your password must be longer than that! "; redo; } elsif ($new_pw ne read_password("Enter it again: ")) { print "Passwords don't match. "; redo; } else { &change_password($new_pw); print "Your password is now changed. "; } } The second parameter to read_password is the optional "idle_timeout" value. If it is a non-zero number and there is no keyboard input for that many seconds, the input operation will terminate. Notice that this is not an overall time limit, as the timer is restarted with each new character. The third parameter will optionally allow the input operation to be terminated by the user with Control-C. If this is not supplied, or is false, a typed Control-C will be entered into the input buffer just as any other character. In that case, there is no way from the keyboard to terminate the program while it is waiting for input. (That is to say, the normal ability to generate signals from the keyboard is sus- pended during the call to read_password.) If the input operation terminates early (either because the idle_timeout was exceeded, or because a Control-C was enabled and typed), the return value will be "undef". In either case, there is no way provided to discover what (if anything) was typed before the early termina- tion, or why the input operation was terminated. So as to discourage users from typing their passwords anywhere except at the prompt, any input which has been "typed ahead" before the prompt appears will be discarded. And whether the input operation terminates normally or not, a newline character will be printed, so that the cursor will not remain on the line after the prompt. BUGS
Windows users will want Term::ReadPassword::Win32. This module has a poorly-designed interface, and should be thoroughly rethought and probably re-united with the Windows version. Users who wish to see password characters echoed as stars may set $Term::ReadPassword::USE_STARS to a true value. The bugs are that some terminals may not erase stars when the user corrects an error, and that using stars leaks information to shoulder-surfers. SECURITY
You would think that a module dealing with passwords would be full of security features. You'd think that, but you'd be wrong. For example, perl provides no way to erase a piece of data from memory. (It's easy to erase it so that it can't be accessed from perl, but that's not the same thing as expunging it from the actual memory.) If you've entered a password, even if the variable that contained that password has been erased, it may be possible for someone to find that password, in plaintext, in a core dump. And that's just one potential security hole. In short, if serious security is an issue, don't use this module. LICENSE
This program is free software; you may redistribute it, modify it, or both, under the same terms as Perl itself. AUTHOR
Tom Phoenix <rootbeer@redcat.com>. Copyright (C) 2007 Tom Phoenix. SEE ALSO
Term::ReadLine, "crypt" in perlfunc, and your system's manpages for the low-level I/O operations used here. perl v5.8.8 2008-03-12 ReadPassword(3pm)
All times are GMT -4. The time now is 05:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy