Results 1 to 3 of 3

Thread: PErl FuNcTiOn

  1. #1

    PErl FuNcTiOn

    this is as i think the best tutorial has ever made in perl function with alphabetical oreder
    let play
    PHP Code:
    abs 
    Returns the absolute value of its argument. If VALUE is omitted,
    PHP Code:
    accept 
    accept NEWSOCKET,GENERICSOCKET
    DESCRIPTION
    Accepts an incoming socket connect, just as the accept(2) system call does. Returns the packed address if it succeeded, false otherwise
    PHP Code:
    alarm 
    SYNOPSIS
    alarm SECONDS

    alarm

    DESCRIPTION
    Arranges to have a SIGALRM delivered to this process after the specified number of seconds have elapsed. If SECONDS is not specified, the value stored in $_ is used. (On some machines, unfortunately, the elapsed time may be up to one second less than you specified because of how seconds are counted.) Only one timer may be counting at once. Each call disables the previous timer, and an argument of 0 may be supplied to cancel the previous timer without starting a new one. The returned value is the amount of time remaining on the previous timer.

    For delays of finer granularity than one second, you may use Perl's four-argument version of select() leaving the first three arguments undefined, or you might be able to use the syscall interface to access setitimer(2) if your system supports it. The Time::HiRes module from CPAN may also prove useful.

    It is usually a mistake to intermix alarm and sleep calls. (sleep may be internally implemented in your system with alarm)

    If you want to use alarm to time out a system call you need to use an eval/die pair. You can't rely on the alarm causing the system call to fail with $! set to EINTR because Perl sets up signal handlers to restart system calls on some systems.
    PHP Code:
    eval {
            
    local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
            
    alarm $timeout;
            
    $nread sysread SOCKET$buffer$size;
            
    alarm 0;
        };
        if ($@) {
            die 
    unless $@ eq "alarm\n";   # propagate unexpected errors
            # timed out
        
    }
        else {
            
    # didn't
        

    PHP Code:
    atan2 
    SYNOPSIS
    atan2 Y,X

    DESCRIPTION
    Returns the arctangent of Y/X in the range -PI to PI.

    For the tangent operation, you may use the Math::Trig::tan function, or use the familiar relation:

    sub tan { sin($_[0]) / cos($_[0]) }

    PHP Code:
    bind 
    SYNOPSIS
    bind SOCKET,NAME

    DESCRIPTION
    Binds a network address to a socket, just as the bind system call does. Returns true if it succeeded, false otherwise. NAME should be a packed address of the appropriate type for the socket

    PHP Code:
    binmode 
    SYNOPSIS
    binmode FILEHANDLE, DISCIPLINE

    binmode FILEHANDLE

    DESCRIPTION
    Arranges for FILEHANDLE to be read or written in ``binary'' or ``text'' mode on systems where the run-time libraries distinguish between binary and text files. If FILEHANDLE is an expression, the value is taken as the name of the filehandle. DISCIPLINE can be either of ":raw" for binary mode or ":crlf" for ``text'' mode. If the DISCIPLINE is omitted, it defaults to ":raw".

    binmode() should be called after open() but before any I/O is done on the filehandle.

    On many systems binmode() currently has no effect, but in future, it will be extended to support user-defined input and output disciplines. On some systems binmode() is necessary when you're not working with a text file. For the sake of portability it is a good idea to always use it when appropriate, and to never use it when it isn't appropriate.

    In other words: Regardless of platform, use binmode() on binary files, and do not use binmode() on text files.

    The open pragma can be used to establish default disciplines

    The operating system, device drivers, C libraries, and Perl run-time system all work together to let the programmer treat a single character (\n) as the line terminator, irrespective of the external representation. On many operating systems, the native text file representation matches the internal representation, but on some platforms the external representation of \n is made up of more than one character.

    Mac OS and all variants of Unix use a single character to end each line in the external representation of text (even though that single character is not necessarily the same across these platforms). Consequently binmode() has no effect on these operating systems. In other systems like VMS, MS-DOS and the various flavors of MS-Windows your program sees a \n as a simple \cJ, but what's stored in text files are the two characters \cM\cJ. That means that, if you don't use binmode() on these systems, \cM\cJ sequences on disk will be converted to \n on input, and any \n in your program will be converted back to \cM\cJ on output. This is what you want for text files, but it can be disastrous for binary files.

    Another consequence of using binmode() (on some systems) is that special end-of-file markers will be seen as part of the data stream. For systems from the Microsoft family this means that if your binary data contains \cZ, the I/O subsystem will regard it as the end of the file, unless you use binmode().

    PHP Code:
    bless 
    SYNOPSIS
    bless REF,CLASSNAME

    bless REF

    DESCRIPTION
    This function tells the thingy referenced by REF that it is now an object in the CLASSNAME package. If CLASSNAME is omitted, the current package is used. Because a bless is often the last thing in a constructor, it returns the reference for convenience. Always use the two-argument version if the function doing the blessing might be inherited by a derived class

    and now we can know that it`s main job is creating an object
    PHP Code:
    caller 
    SYNOPSIS
    caller EXPR

    caller

    DESCRIPTION
    Returns the context of the current subroutine call. In scalar context, returns the caller's package name if there is a caller, that is, if we're in a subroutine or eval or require, and the undefined value otherwise. In list context, returns

    ($package, $filename, $line) = caller;
    With EXPR, it returns some extra information that the debugger uses to print a stack trace. The value of EXPR indicates how many call frames to go back before the current one.

    ($package, $filename, $line, $subroutine, $hasargs,
    $wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($i);
    Here $subroutine may be (eval) if the frame is not a subroutine call, but an eval. In such a case additional elements $evaltext and $is_require are set: $is_require is true if the frame is created by a require or use statement, $evaltext contains the text of the eval EXPR statement. In particular, for an eval BLOCK statement, $filename is (eval), but $evaltext is undefined. (Note also that each use statement creates a require frame inside an eval EXPR) frame. $hasargs is true if a new instance of @_ was set up for the frame. $hints and $bitmask contain pragmatic hints that the caller was compiled with. The $hints and $bitmask values are subject to change between versions of Perl, and are not meant for external use.

    Furthermore, when called from within the DB package, caller returns more detailed information: it sets the list variable @DB::args to be the arguments with which the subroutine was invoked.

    Be aware that the optimizer might have optimized call frames away before caller had a chance to get the information. That means that caller(N) might not return information about the call frame you expect it do, for N > 1. In particular, @DB::args might have information from the previous time caller was called.

    PHP Code:
    chdir 
    SYNOPSIS
    chdir EXPR


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

    DESCRIPTION
    Changes the working directory to EXPR, if possible. If EXPR is omitted, changes to the directory specified by $ENV{HOME}, if set; if not, changes to the directory specified by $ENV{LOGDIR}. If neither is set, chdir does nothing. It returns true upon success, false otherwise. See the example under die.

    PHP Code:
    chmod 
    SYNOPSIS
    chmod LIST

    DESCRIPTION
    Changes the permissions of a list of files. The first element of the list must be the numerical mode, which should probably be an octal number, and which definitely should not a string of octal digits: 0644 is okay, '0644' is not. Returns the number of files successfully changed
    PHP Code:
        $cnt chmod 0755'foo''bar';
        
    chmod 0755, @executables;
        
    $mode '0644'chmod $mode'foo';      # !!! sets mode to
                                                 # --w----r-T
        
    $mode '0644'chmod oct($mode), 'foo'# this is better
        
    $mode 0644;   chmod $mode'foo';      # this is best 
    You can also import the symbolic S_I* constants from the Fcntl module:
    PHP Code:
        use Fcntl ':mode';
        
    chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables
    # This is identical to the chmod 0755 of the above example.
    PHP Code:
    chomp 
    SYNOPSIS
    chomp VARIABLE

    chomp LIST

    chomp
    description

    removes any trailing string that corresponds to the current value
    $/ (also known as $INPUT_RECORD_SEPARATOR in the English module). It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record when you're worried that the final record may be missing its newline. When in paragraph mode ($/ = ""), it removes all trailing newlines from the string. When in slurp mode ($/ = undef) or fixed-length record mode ($/ is a reference to an integer or the like,
    chomp() won't remove anything. If VARIABLE is omitted, it chomps
    Example:

    while (<&gt {
    chomp; # avoid \n on last field
    @array = split(/:/);
    # ...
    }

    If VARIABLE is a hash, it chomps the hash's values, but not its keys.

    You can actually chomp anything that's an lvalue, including an assignment:

    chomp($cwd = `pwd`);
    chomp($answer = <STDIN>
    If you chomp a list, each element is chomped, and the total number of characters removed is returned.

    thats for now and the next day i well post mor3 well thanks u very much and i hope all enjoy my first lesson
    ch33rs
    M_SPAWN

  2. #2
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,323
    So this is just a copy and paste from: http://perldoc.perl.org/functions/binmode.html
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage

  3. #3
    Senior Member
    Join Date
    Oct 2001
    Posts
    872
    Originally posted here by MsMittens
    So this is just a copy and paste from: http://perldoc.perl.org/functions/binmode.html
    I can't find any similarity between the two documents, can you point them out for me? binmode is mentioned absoutely nowhere in his text, nor does it have anything to do with binmode.


    However, this is a straight cut-and-paste from perldoc.


    edit: i see now what you were saying about binmode, MsMittens.
    ...This Space For Rent.

    -[WebCarnage]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •