Perl Glob Function

Perl Glob Function

PPEERRLL GGLLOOBB FFUUNNCCTTIIOONN http://www.tutorialspoint.com/perl/perl_glob.htm Copyright © tutorialspoint.com Description This function returns a list of files matching EXPR as they would be expanded by the standard Bourne shell. If the EXPR does not specify a path, uses the current directory. If EXPR is omitted, the value of $_ is used. From Perl 5.6 on, expansion is done internally, rather than using an external script. Expansion follows the csh andanyderivatives, includingtcshandbash style of expansion, which translates as the following − Files beginning with a single period are ignored unless EXPR explicitly matches. The * character matches zero or more characters of any type. The ? character matches one character of any type. The [..] construct matches the characters listed, including ranges, as per regular expressions. The ~ characters matches the home directory; ~name matches the home directory for the user name. The {..} construct matches against any of the comma-separated words enclosed in the braces. Syntax Following is the simple syntax for this function − glob EXPR glob Return Value This function returns undef on error otherwise First file in the list of expanded names in scalar context and Empty list on error otherwise List of expanded file names in list context. Example Following is the example code showing its basic usage − #!/usr/bin/perl (@file_list) = glob "perl_g*"; print "Returned list of file @file_list\n"; When above code is executed, it produces the following result − Returned list of file Loading [MathJax]/jax/output/HTML-CSS/jax.js.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us