Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <*> mean in Perl?

Tags:

perl

In the code below, what exactly does the <*> command do?

my @usbHddFileList = <*>;
foreach $usbHddFile (@usbHddFileList)
{
    system("rm -f $curMountDir/$usbHddFile < /dev/null > /dev/null 2>&1");
}
like image 382
Danny Avatar asked Dec 22 '15 17:12

Danny


People also ask

What does $! Mean in Perl?

$! If used in a numeric context, yields the current value of the errno variable, identifying the last system call error. If used in a string context, yields the corresponding system error string.

What does %variable mean in Perl?

Advertisements. Variables are the reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory.


2 Answers

It's a glob. According to perlop:

If what's within the angle brackets is neither a filehandle nor a simple scalar variable containing a filehandle name, typeglob, or typeglob reference, it is interpreted as a filename pattern to be globbed, and either a list of filenames or the next filename in the list is returned, depending on context. This distinction is determined on syntactic grounds alone.

like image 86
Matt Jacob Avatar answered Oct 15 '22 23:10

Matt Jacob


  • <> means readline(ARGV)
  • <IDENTIFIER> means readline(IDENTIFIER)
  • <$IDENTIFIER> means readline($IDENTIFIER)
  • <...> (anything else) means glob(qq<...>)

So <*> means glob(qq<*>) or glob('*').

glob is used to generate a number of strings or file names from a pattern.

In list context, <*> aka glob('*') returns all the files in the current work directory other than those whose name starts with ..

like image 45
ikegami Avatar answered Oct 16 '22 01:10

ikegami